mirror of https://github.com/openspug/spug
F 修复某些情况下告警未正常发出的问题
parent
9fb2a9405f
commit
c08fad5b35
|
@ -22,7 +22,7 @@ class Notify(models.Model, ModelMixin):
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
source = models.CharField(max_length=10, choices=SOURCES)
|
source = models.CharField(max_length=10, choices=SOURCES)
|
||||||
type = models.CharField(max_length=2, choices=TYPES)
|
type = models.CharField(max_length=2, choices=TYPES)
|
||||||
content = models.CharField(max_length=255, null=True)
|
content = models.TextField(null=True)
|
||||||
unread = models.BooleanField(default=True)
|
unread = models.BooleanField(default=True)
|
||||||
link = models.CharField(max_length=255, null=True)
|
link = models.CharField(max_length=255, null=True)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ from apps.setting.utils import AppSetting
|
||||||
from apps.notify.models import Notify
|
from apps.notify.models import Notify
|
||||||
from libs.mail import Mail
|
from libs.mail import Mail
|
||||||
from libs.utils import human_datetime
|
from libs.utils import human_datetime
|
||||||
from threading import Thread
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ class Notification:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def handle_request(url, data, mode=None):
|
def handle_request(url, data, mode=None):
|
||||||
try:
|
try:
|
||||||
res = requests.post(url, json=data, timeout=30)
|
res = requests.post(url, json=data, timeout=15)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Notify.make_system_notify('通知发送失败', f'接口调用异常: {e}')
|
return Notify.make_system_notify('通知发送失败', f'接口调用异常: {e}')
|
||||||
if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
|
|
Loading…
Reference in New Issue