diff --git a/main.go b/main.go index 52d62bdb..c9767a41 100644 --- a/main.go +++ b/main.go @@ -234,7 +234,7 @@ func main() { return } - if _, err := notify.PushToHuawei(req, cfg); err != nil { + if _, err := notify.PushToHuawei(g.ShutdownContext(), req, cfg); err != nil { return } diff --git a/notify/notification.go b/notify/notification.go index 8ea0a322..fcd9dfda 100644 --- a/notify/notification.go +++ b/notify/notification.go @@ -243,7 +243,7 @@ func SendNotification( case core.PlatFormAndroid: resp, err = PushToAndroid(ctx, v, cfg) case core.PlatFormHuawei: - resp, err = PushToHuawei(v, cfg) + resp, err = PushToHuawei(ctx, v, cfg) } if cfg.Core.FeedbackURL != "" { diff --git a/notify/notification_hms.go b/notify/notification_hms.go index e976e5fc..a44e9224 100644 --- a/notify/notification_hms.go +++ b/notify/notification_hms.go @@ -158,7 +158,7 @@ func GetHuaweiNotification(req *PushNotification) (*model.MessageRequest, error) } // PushToHuawei provide send notification to Android server. -func PushToHuawei(req *PushNotification, cfg *config.ConfYaml) (resp *ResponsePush, err error) { +func PushToHuawei(ctx context.Context, req *PushNotification, cfg *config.ConfYaml) (resp *ResponsePush, err error) { logx.LogAccess.Debug("Start push notification for Huawei") var ( @@ -192,7 +192,7 @@ Retry: notification, _ := GetHuaweiNotification(req) - res, err := client.SendMessage(context.Background(), notification) + res, err := client.SendMessage(ctx, notification) if err != nil { // Send Message error errLog := logPush(cfg, core.FailedPush, req.Topic, req, err)