Skip to content

Commit

Permalink
# 优化推送集成
Browse files Browse the repository at this point in the history
  • Loading branch information
vapao committed Nov 13, 2023
1 parent 60e7ab8 commit 06d6bb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
11 changes: 1 addition & 10 deletions spug_api/apps/alarm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,10 @@ def handle_test(request):
).parse(request.body)
if error is None:
notify = Notification(None, '1', 'https://spug.cc', 'Spug官网(测试)', '这是一条测试告警信息', None)
if form.mode in ('1', '2', '4') and not notify.spug_key:
return json_response(error='未配置调用凭据(系统设置/基本设置),请配置后再尝试。')

if form.mode == '1':
notify.monitor_by_wx([form.value])
elif form.mode == '2':
return json_response(error='目前暂不支持短信告警,请关注后续更新。')
elif form.mode == '3':
if form.mode == '3':
notify.monitor_by_dd([form.value])
elif form.mode == '4':
notify.monitor_by_email([form.value])
elif form.mode == '5':
notify.monitor_by_qy_wx([form.value])
else:
return json_response(error='不支持的报警方式')
return json_response(error=error)
6 changes: 3 additions & 3 deletions spug_api/apps/monitor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def post(self, request):
Argument('notify_mode', type=list, help='请选择报警方式'),
).parse(request.body)
if error is None:
if set(form.notify_mode).intersection(['1', '2', '4']):
if not AppSetting.get_default('spug_key') and not AppSetting.get_default('spug_push_key'):
return json_response(error='报警方式 微信、短信、邮件需要配置调用凭据(系统设置/基本设置)或推送服务(系统设置/推送服务设置),请配置后再启用该报警方式。')
if set(form.notify_mode).intersection(['1', '2', '6']):
if not AppSetting.get_default('spug_push_key'):
return json_response(error='报警方式微信、短信、电话需要配置推送服务(系统设置/推送服务设置),请配置后再启用该报警方式。')

form.targets = json.dumps(form.targets)
form.notify_grp = json.dumps(form.notify_grp)
Expand Down
8 changes: 0 additions & 8 deletions spug_web/src/pages/alarm/contact/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ export default observer(function () {
</Form.Item>
<Test mode="4" name="email"/>
</Form.Item>
<Form.Item label="微信Token" extra={
<a target="_blank" rel="noopener noreferrer"
href="https://spug.cc/docs/alarm-contact/">如何获取微信 Token ?</a>}>
<Form.Item noStyle name="wx_token">
<Input placeholder="请输入微信token"/>
</Form.Item>
<Test mode="1" name="wx_token"/>
</Form.Item>
<Form.Item label="钉钉" extra={<span>
钉钉收不到通知?请参考
<a target="_blank" rel="noopener noreferrer"
Expand Down

0 comments on commit 06d6bb9

Please sign in to comment.