feat: get messenger url from common setting

This commit is contained in:
pycook 2023-10-09 20:25:27 +08:00
parent 501d86341a
commit d7bbc3ccf8
3 changed files with 9 additions and 7 deletions

View File

@ -8,6 +8,7 @@ from flask import current_app
from jinja2 import Template
from markdownify import markdownify as md
from api.lib.common_setting.notice_config import NoticeConfigCRUD
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))
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:
raise Exception(resp.text)

View File

@ -97,4 +97,3 @@ BOOL_TRUE = ['true', 'TRUE', 'True', True, '1', 1, "Yes", "YES", "yes", 'Y', 'y'
# # messenger
USE_MESSENGER = True
MESSENGER_URL = "http://{messenger_url}/v1/message"

View File

@ -346,11 +346,6 @@ export default {
},
mounted() {},
methods: {
async getNoticeConfigAppBot() {
await getNoticeConfigAppBot().then((res) => {
this.appBot = res
})
},
async getNoticeConfigAppBot() {
await getNoticeConfigAppBot().then((res) => {
this.appBot = res