mirror of https://github.com/veops/cmdb.git
feat: get messenger url from common setting
This commit is contained in:
parent
501d86341a
commit
d7bbc3ccf8
|
@ -8,6 +8,7 @@ from flask import current_app
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
from markdownify import markdownify as md
|
from markdownify import markdownify as md
|
||||||
|
|
||||||
|
from api.lib.common_setting.notice_config import NoticeConfigCRUD
|
||||||
from api.lib.mail import send_mail
|
from api.lib.mail import send_mail
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +42,14 @@ def _request_messenger(subject, body, tos, sender, payload):
|
||||||
|
|
||||||
params['content'] = json.dumps(dict(content=content))
|
params['content'] = json.dumps(dict(content=content))
|
||||||
|
|
||||||
resp = requests.post(current_app.config.get('MESSENGER_URL'), json=params)
|
url = current_app.config.get('MESSENGER_URL') or NoticeConfigCRUD.get_messenger_url()
|
||||||
|
if not url:
|
||||||
|
raise Exception("no messenger url")
|
||||||
|
|
||||||
|
if not url.endswith("message"):
|
||||||
|
url = "{}/v1/message".format(url)
|
||||||
|
|
||||||
|
resp = requests.post(url, json=params)
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
raise Exception(resp.text)
|
raise Exception(resp.text)
|
||||||
|
|
||||||
|
|
|
@ -97,4 +97,3 @@ BOOL_TRUE = ['true', 'TRUE', 'True', True, '1', 1, "Yes", "YES", "yes", 'Y', 'y'
|
||||||
|
|
||||||
# # messenger
|
# # messenger
|
||||||
USE_MESSENGER = True
|
USE_MESSENGER = True
|
||||||
MESSENGER_URL = "http://{messenger_url}/v1/message"
|
|
||||||
|
|
|
@ -346,11 +346,6 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
async getNoticeConfigAppBot() {
|
|
||||||
await getNoticeConfigAppBot().then((res) => {
|
|
||||||
this.appBot = res
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getNoticeConfigAppBot() {
|
async getNoticeConfigAppBot() {
|
||||||
await getNoticeConfigAppBot().then((res) => {
|
await getNoticeConfigAppBot().then((res) => {
|
||||||
this.appBot = res
|
this.appBot = res
|
||||||
|
|
Loading…
Reference in New Issue