From 14c61a9e33302908eba621012d8a70d9fffa91c2 Mon Sep 17 00:00:00 2001 From: Leo Q Date: Tue, 16 Nov 2021 11:27:23 +0800 Subject: [PATCH] add multiple webhooks support (#93) * add multiple webhooks support * donot change method name --- helpdesk/config.py | 2 ++ helpdesk/libs/notification.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/helpdesk/config.py b/helpdesk/config.py index 70117ae2..f7de8f8c 100644 --- a/helpdesk/config.py +++ b/helpdesk/config.py @@ -45,6 +45,8 @@ NOTIFICATION_TITLE_PREFIX = '' NOTIFICATION_METHODS = [] +LARK_WEBHOOK_URL = "" + OPENID_PRIVIDERS = {} AUTHORIZED_EMAIL_DOMAINS = [] diff --git a/helpdesk/libs/notification.py b/helpdesk/libs/notification.py index cc7fbda0..84ed1da6 100644 --- a/helpdesk/libs/notification.py +++ b/helpdesk/libs/notification.py @@ -11,6 +11,7 @@ from helpdesk.config import ( NOTIFICATION_TITLE_PREFIX, WEBHOOK_URL, + LARK_WEBHOOK_URL, ADMIN_EMAIL_ADDRS, FROM_EMAIL_ADDR, SMTP_SERVER, @@ -134,7 +135,7 @@ class LarkWebhookNotification(Notification): method = 'webhook' async def send(self): - if not WEBHOOK_URL: + if not LARK_WEBHOOK_URL: return title, content = self.render() msg = { @@ -154,7 +155,7 @@ async def send(self): } } } - r = requests.post(WEBHOOK_URL, json={"msg_type": "interactive", "card": msg}) + r = requests.post(LARK_WEBHOOK_URL, json={"msg_type": "interactive", "card": msg}) if r.status_code == 200 and r.json()["StatusCode"] == 0: return else: