diff --git a/notify/notification.go b/notify/notification.go index f2eeb66..e299a30 100644 --- a/notify/notification.go +++ b/notify/notification.go @@ -250,6 +250,15 @@ func SendNotification(req queue.QueuedMessage, cfg config.ConfYaml) (resp *Respo resp, err = PushToHuawei(*v, cfg) } + if cfg.Core.FeedbackURL != "" { + for _, l := range resp.Logs { + err := DispatchFeedback(l, cfg.Core.FeedbackURL, cfg.Core.FeedbackTimeout) + if err != nil { + logx.LogError.Error(err) + } + } + } + return } diff --git a/notify/notification_apns.go b/notify/notification_apns.go index e434c51..058e351 100644 --- a/notify/notification_apns.go +++ b/notify/notification_apns.go @@ -21,7 +21,6 @@ import ( "github.com/sideshow/apns2/certificate" "github.com/sideshow/apns2/payload" "github.com/sideshow/apns2/token" - "github.com/sirupsen/logrus" "golang.org/x/net/http2" ) @@ -391,10 +390,6 @@ func getApnsClient(cfg config.ConfYaml, req PushNotification) (client *apns2.Cli func PushToIOS(req PushNotification, cfg config.ConfYaml) (resp *ResponsePush, err error) { logx.LogAccess.Debug("Start push notification for iOS") - if cfg.Core.Sync && !core.IsLocalQueue(core.Queue(cfg.Queue.Engine)) { - cfg.Core.Sync = false - } - var ( retryCount = 0 maxRetry = cfg.Ios.MaxRetry @@ -431,16 +426,7 @@ Retry: // apns server error errLog := logPush(cfg, core.FailedPush, token, req, err) - if cfg.Core.Sync { - resp.Logs = append(resp.Logs, errLog) - } else if cfg.Core.FeedbackURL != "" { - go func(logger *logrus.Logger, log logx.LogPushEntry, url string, timeout int64) { - err := DispatchFeedback(log, url, timeout) - if err != nil { - logger.Error(err) - } - }(logx.LogError, errLog, cfg.Core.FeedbackURL, cfg.Core.FeedbackTimeout) - } + resp.Logs = append(resp.Logs, errLog) status.StatStorage.AddIosError(1) // We should retry only "retryable" statuses. More info about response: diff --git a/notify/notification_fcm.go b/notify/notification_fcm.go index 2401b13..bd5e8ce 100644 --- a/notify/notification_fcm.go +++ b/notify/notification_fcm.go @@ -10,7 +10,6 @@ import ( "github.com/appleboy/gorush/status" "github.com/appleboy/go-fcm" - "github.com/sirupsen/logrus" ) // InitFCMClient use for initialize FCM Client. @@ -109,10 +108,6 @@ func GetAndroidNotification(req PushNotification) *fcm.Message { func PushToAndroid(req PushNotification, cfg config.ConfYaml) (resp *ResponsePush, err error) { logx.LogAccess.Debug("Start push notification for Android") - if cfg.Core.Sync && !core.IsLocalQueue(core.Queue(cfg.Queue.Engine)) { - cfg.Core.Sync = false - } - var ( client *fcm.Client retryCount = 0 @@ -154,30 +149,12 @@ Retry: if req.IsTopic() { errLog := logPush(cfg, core.FailedPush, req.To, req, err) - if cfg.Core.Sync { - resp.Logs = append(resp.Logs, errLog) - } else if cfg.Core.FeedbackURL != "" { - go func(logger *logrus.Logger, log logx.LogPushEntry, url string, timeout int64) { - err := DispatchFeedback(log, url, timeout) - if err != nil { - logger.Error(err) - } - }(logx.LogError, errLog, cfg.Core.FeedbackURL, cfg.Core.FeedbackTimeout) - } + resp.Logs = append(resp.Logs, errLog) status.StatStorage.AddAndroidError(1) } else { for _, token := range req.Tokens { errLog := logPush(cfg, core.FailedPush, token, req, err) - if cfg.Core.Sync { - resp.Logs = append(resp.Logs, errLog) - } else if cfg.Core.FeedbackURL != "" { - go func(logger *logrus.Logger, log logx.LogPushEntry, url string, timeout int64) { - err := DispatchFeedback(log, url, timeout) - if err != nil { - logger.Error(err) - } - }(logx.LogError, errLog, cfg.Core.FeedbackURL, cfg.Core.FeedbackTimeout) - } + resp.Logs = append(resp.Logs, errLog) } status.StatStorage.AddAndroidError(int64(len(req.Tokens))) } @@ -209,16 +186,7 @@ Retry: } errLog := logPush(cfg, core.FailedPush, to, req, result.Error) - if cfg.Core.Sync { - resp.Logs = append(resp.Logs, errLog) - } else if cfg.Core.FeedbackURL != "" { - go func(logger *logrus.Logger, log logx.LogPushEntry, url string, timeout int64) { - err := DispatchFeedback(log, url, timeout) - if err != nil { - logger.Error(err) - } - }(logx.LogError, errLog, cfg.Core.FeedbackURL, cfg.Core.FeedbackTimeout) - } + resp.Logs = append(resp.Logs, errLog) continue } @@ -240,9 +208,7 @@ Retry: } else { // failure errLog := logPush(cfg, core.FailedPush, to, req, res.Error) - if cfg.Core.Sync { - resp.Logs = append(resp.Logs, errLog) - } + resp.Logs = append(resp.Logs, errLog) } } @@ -251,9 +217,7 @@ Retry: newTokens = append(newTokens, res.FailedRegistrationIDs...) errLog := logPush(cfg, core.FailedPush, notification.To, req, errors.New("device group: partial success or all fails")) - if cfg.Core.Sync { - resp.Logs = append(resp.Logs, errLog) - } + resp.Logs = append(resp.Logs, errLog) } if len(newTokens) > 0 && retryCount < maxRetry { diff --git a/notify/notification_hms.go b/notify/notification_hms.go index 1960067..31525ec 100644 --- a/notify/notification_hms.go +++ b/notify/notification_hms.go @@ -169,10 +169,6 @@ func GetHuaweiNotification(req PushNotification) (*model.MessageRequest, error) func PushToHuawei(req PushNotification, cfg config.ConfYaml) (resp *ResponsePush, err error) { logx.LogAccess.Debug("Start push notification for Huawei") - if cfg.Core.Sync && !core.IsLocalQueue(core.Queue(cfg.Queue.Engine)) { - cfg.Core.Sync = false - } - var ( client *client.HMSClient retryCount = 0