@@ -37,10 +37,10 @@ def send_notification(self, title: str, message: str, priority: int = 5):
37
37
headers = {'X-Gotify-Key' : self .token }
38
38
39
39
try :
40
- response = requests .post (f"{ self .url } /message" , data = payload , headers = headers )
40
+ response = requests .post (f"{ self .url } /message" , json = payload , headers = headers , timeout = 10 )
41
41
response .raise_for_status ()
42
42
logging .info (f"Gotify notification sent: { title } - { message } " )
43
- except requests . exceptions . RequestException as e :
43
+ except Exception as e :
44
44
logging .error (f"Gotify notification failed: { e } " )
45
45
46
46
# Email notification implementation
@@ -71,7 +71,7 @@ def send_notification(self, title: str, message: str, priority: int = 5):
71
71
msg ['To' ] = ', ' .join (self .to_addrs )
72
72
73
73
try :
74
- with smtplib .SMTP (self .smtp_server , self .port ) as server :
74
+ with smtplib .SMTP (self .smtp_server , self .port , timeout = 10 ) as server :
75
75
server .starttls () # Encrypt the connection
76
76
server .login (self .username , self .password ) # Authenticate with the SMTP server
77
77
server .sendmail (self .from_addr , self .to_addrs , msg .as_string ()) # Send the email
@@ -97,13 +97,11 @@ def send_notification(self, title: str, message: str, priority: int = 5):
97
97
priority (int): Unused, but kept for interface consistency.
98
98
"""
99
99
try :
100
- response = requests .get (self .webhook_url )
101
- if response .status_code == 200 :
102
- logging .info ("Uptime Kuma notification sent successfully" )
103
- else :
104
- logging .error (f"Failed to send Uptime Kuma notification: { response .status_code } " )
100
+ response = requests .post (self .webhook_url , json = {'title' : title , 'message' : message , 'priority' : priority }, timeout = 10 )
101
+ response .raise_for_status ()
102
+ logging .info ("Uptime Kuma notification sent successfully" )
105
103
except Exception as e :
106
- logging .error (f"Error sending Uptime Kuma notification: { e } " )
104
+ logging .error (f"Failed to send Uptime Kuma notification: { e } " )
107
105
108
106
# Send notification to all initialized notifiers
109
107
def send_notification (title , message , priority = 5 ):
0 commit comments