fix issue

pull/410/head
vapao 2021-10-14 18:11:29 +08:00
parent 76b5ea39de
commit 8c95bc35f7
2 changed files with 15 additions and 9 deletions

View File

@ -31,9 +31,11 @@ def _do_notify(task, mode, url, msg):
'markdown': { 'markdown': {
'title': '任务执行失败通知', 'title': '任务执行失败通知',
'text': '\n\n'.join(texts) 'text': '\n\n'.join(texts)
},
'at': {
'isAtAll': True
} }
} }
requests.post(url, json=data)
elif mode == '2': elif mode == '2':
data = { data = {
'task_id': task.id, 'task_id': task.id,
@ -42,7 +44,6 @@ def _do_notify(task, mode, url, msg):
'message': msg or '请在任务计划执行历史中查看详情', 'message': msg or '请在任务计划执行历史中查看详情',
'created_at': human_datetime() 'created_at': human_datetime()
} }
requests.post(url, json=data)
elif mode == '3': elif mode == '3':
texts = [ texts = [
'## <font color="warning">任务执行失败通知</font>', '## <font color="warning">任务执行失败通知</font>',
@ -58,6 +59,8 @@ def _do_notify(task, mode, url, msg):
'content': '\n'.join(texts) 'content': '\n'.join(texts)
} }
} }
else:
return
res = requests.post(url, json=data) res = requests.post(url, json=data)
if res.status_code != 200: if res.status_code != 200:
Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回状态码:{res.status_code}, 请求URL{url}') Notify.make_notify('schedule', '1', '任务执行通知发送失败', f'返回状态码:{res.status_code}, 请求URL{url}')

View File

@ -121,6 +121,9 @@ class Notification:
'markdown': { 'markdown': {
'title': '监控告警通知', 'title': '监控告警通知',
'text': '\n\n'.join(texts) + '\n\n> ###### 来自 Spug运维平台' 'text': '\n\n'.join(texts) + '\n\n> ###### 来自 Spug运维平台'
},
'at': {
'isAtAll': True
} }
} }
for url in users: for url in users: