File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- v0.4.4
1+ v0.4.5
Original file line number Diff line number Diff line change @@ -406,6 +406,10 @@ func pushModelUptime(modelName string) error {
406406 return nil
407407 }
408408
409+ if config .UptimeKuma .ModelURL == nil {
410+ return nil
411+ }
412+
409413 pushURL , ok := config .UptimeKuma .ModelURL [modelName ]
410414 if ! ok {
411415 return fmt .Errorf ("找不到模型 %s 的推送地址" , modelName )
@@ -435,6 +439,10 @@ func pushChannelUptime(channelID int) error {
435439 return nil
436440 }
437441
442+ if config .UptimeKuma .ChannelURL == nil {
443+ return nil
444+ }
445+
438446 pushURL , ok := config .UptimeKuma .ChannelURL [fmt .Sprintf ("%d" , channelID )]
439447 if ! ok {
440448 return fmt .Errorf ("找不到渠道 %d 的推送地址" , channelID )
Original file line number Diff line number Diff line change @@ -19,19 +19,33 @@ type ChannelChange struct {
1919}
2020
2121func sendNotification (change ChannelChange ) error {
22- if config .Notification .SMTP .Enabled {
23- if err := sendEmailNotification (change ); err != nil {
24- return fmt .Errorf ("发送邮件通知失败: %v" , err )
25- }
26- }
22+ var e1 , e2 error
2723
28- if config .Notification .Webhook .Enabled {
29- if err := sendWebhookNotification (change ); err != nil {
30- return fmt .Errorf ("发送Webhook通知失败 : %v" , err )
31- }
32- }
24+ if config .Notification .SMTP .Enabled {
25+ if err := sendEmailNotification (change ); err != nil {
26+ e1 = fmt .Errorf ("发送邮件通知失败 : %v" , err )
27+ }
28+ }
3329
34- return nil
30+ if config .Notification .Webhook .Enabled {
31+ if err := sendWebhookNotification (change ); err != nil {
32+ e2 = fmt .Errorf ("发送Webhook通知失败: %v" , err )
33+ }
34+ }
35+
36+ if e1 != nil && e2 != nil {
37+ return fmt .Errorf ("%v\n %v" , e1 , e2 )
38+ }
39+
40+ if e1 != nil {
41+ return e1
42+ }
43+
44+ if e2 != nil {
45+ return e2
46+ }
47+
48+ return nil
3549}
3650
3751func sendEmailNotification (change ChannelChange ) error {
You can’t perform that action at this time.
0 commit comments