From 8c95bc35f7082821c2aba8c297480ae27df4e3b4 Mon Sep 17 00:00:00 2001 From: vapao Date: Thu, 14 Oct 2021 18:11:29 +0800 Subject: [PATCH] fix issue --- spug_api/apps/schedule/utils.py | 21 ++++++++++++--------- spug_api/libs/spug.py | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/spug_api/apps/schedule/utils.py b/spug_api/apps/schedule/utils.py index f175dda..dd45b44 100644 --- a/spug_api/apps/schedule/utils.py +++ b/spug_api/apps/schedule/utils.py @@ -31,9 +31,11 @@ def _do_notify(task, mode, url, msg): 'markdown': { 'title': '任务执行失败通知', 'text': '\n\n'.join(texts) + }, + 'at': { + 'isAtAll': True } } - requests.post(url, json=data) elif mode == '2': data = { 'task_id': task.id, @@ -42,7 +44,6 @@ def _do_notify(task, mode, url, msg): 'message': msg or '请在任务计划执行历史中查看详情', 'created_at': human_datetime() } - requests.post(url, json=data) elif mode == '3': texts = [ '## 任务执行失败通知', @@ -58,10 +59,12 @@ def _do_notify(task, mode, url, msg): 'content': '\n'.join(texts) } } - res = requests.post(url, json=data) - if res.status_code != 200: - Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回状态码:{res.status_code}, 请求URL:{url}') - if mode in ['1', '3']: - res = res.json() - if res.get('errcode') != 0: - Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回数据:{res}') + else: + return + res = requests.post(url, json=data) + if res.status_code != 200: + Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回状态码:{res.status_code}, 请求URL:{url}') + if mode in ['1', '3']: + res = res.json() + if res.get('errcode') != 0: + Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回数据:{res}') diff --git a/spug_api/libs/spug.py b/spug_api/libs/spug.py index b0bed93..d389a60 100644 --- a/spug_api/libs/spug.py +++ b/spug_api/libs/spug.py @@ -121,6 +121,9 @@ class Notification: 'markdown': { 'title': '监控告警通知', 'text': '\n\n'.join(texts) + '\n\n> ###### 来自 Spug运维平台' + }, + 'at': { + 'isAtAll': True } } for url in users: