diff --git a/notify/notification_apns.go b/notify/notification_apns.go index d1b2a9d0c..87811259b 100644 --- a/notify/notification_apns.go +++ b/notify/notification_apns.go @@ -368,6 +368,13 @@ func GetIOSNotification(req *PushNotification) *apns2.Notification { notification.Payload = payload + jsonMarshall, err := json.Marshal(notification) + if err != nil { + logx.LogError.Warnf("Failed to marshal the default message! Error: %v", err) + } else { + logx.LogAccess.Debugf("Default message going to APNs is %s", string(jsonMarshall)) + } + return notification } diff --git a/notify/notification_fcm.go b/notify/notification_fcm.go index 772393b12..6e3c68bc2 100644 --- a/notify/notification_fcm.go +++ b/notify/notification_fcm.go @@ -101,6 +101,13 @@ func GetAndroidNotification(req *PushNotification) *fcm.Message { notification.Apns = req.Apns } + jsonMarshall, err := json.Marshal(notification) + if err != nil { + logx.LogError.Warnf("Failed to marshal the default message! Error: %v", err) + } else { + logx.LogAccess.Debugf("Default message going to FCM server is %s", string(jsonMarshall)) + } + return notification } diff --git a/notify/notification_hms.go b/notify/notification_hms.go index 12cf80afc..89b3c9a76 100644 --- a/notify/notification_hms.go +++ b/notify/notification_hms.go @@ -66,7 +66,7 @@ func InitHMSClient(cfg *config.ConfYaml, appSecret, appID string) (*client.HMSCl // GetHuaweiNotification use for define HMS notification. // HTTP Connection Server Reference for HMS // https://developer.huawei.com/consumer/en/doc/development/HMS-References/push-sendapi -func GetHuaweiNotification(req *PushNotification) (*model.MessageRequest, error) { +func GetHuaweiNotification(req *PushNotification) *model.MessageRequest { msgRequest := model.NewNotificationMsgRequest() msgRequest.Message.Android = model.GetDefaultAndroid() @@ -155,14 +155,14 @@ func GetHuaweiNotification(req *PushNotification) (*model.MessageRequest, error) } } - b, err := json.Marshal(msgRequest) + jsonMarshall, err := json.Marshal(msgRequest) if err != nil { - logx.LogError.Error("Failed to marshal the default message! Error is " + err.Error()) - return nil, err + logx.LogError.Warnf("Failed to marshal the default message! Error: %v", err) + } else { + logx.LogAccess.Debugf("Default message going to Huawei Push server is %s", string(jsonMarshall)) } - logx.LogAccess.Debugf("Default message is %s", string(b)) - return msgRequest, nil + return msgRequest } // PushToHuawei provide send notification to Android server. @@ -199,7 +199,7 @@ func PushToHuawei(req *PushNotification, cfg *config.ConfYaml) (resp *ResponsePu Retry: isError := false - notification, _ := GetHuaweiNotification(req) + notification := GetHuaweiNotification(req) res, err := client.SendMessage(context.Background(), notification) if err != nil { diff --git a/storage/redis/redis.go b/storage/redis/redis.go index 45001a1f8..6f6e70af1 100644 --- a/storage/redis/redis.go +++ b/storage/redis/redis.go @@ -48,11 +48,9 @@ func (s *Storage) Init() error { }) } - if err := s.client.Ping(s.ctx).Err(); err != nil { - return err - } + err := s.client.Ping(s.ctx).Err() - return nil + return err } // Close the storage connection