Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions notify/notification_apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
7 changes: 7 additions & 0 deletions notify/notification_fcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
14 changes: 7 additions & 7 deletions notify/notification_hms.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions storage/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down