Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add request logs for iOS:APNs and Android:FCM #639

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 @@

notification.Payload = payload

jsonMarshall, err := json.Marshal(notification)
if err != nil {
logx.LogError.Warnf("Failed to marshal the default message! Error: %v", err)

Check warning on line 373 in notify/notification_apns.go

View check run for this annotation

Codecov / codecov/patch

notify/notification_apns.go#L373

Added line #L373 was not covered by tests
} 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 @@
notification.Apns = req.Apns
}

jsonMarshall, err := json.Marshal(notification)
if err != nil {
logx.LogError.Warnf("Failed to marshal the default message! Error: %v", err)

Check warning on line 106 in notify/notification_fcm.go

View check run for this annotation

Codecov / codecov/patch

notify/notification_fcm.go#L106

Added line #L106 was not covered by tests
} 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 @@
// 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 {

Check warning on line 69 in notify/notification_hms.go

View check run for this annotation

Codecov / codecov/patch

notify/notification_hms.go#L69

Added line #L69 was not covered by tests
msgRequest := model.NewNotificationMsgRequest()

msgRequest.Message.Android = model.GetDefaultAndroid()
Expand Down Expand Up @@ -155,14 +155,14 @@
}
}

b, err := json.Marshal(msgRequest)
jsonMarshall, err := json.Marshal(msgRequest)

Check warning on line 158 in notify/notification_hms.go

View check run for this annotation

Codecov / codecov/patch

notify/notification_hms.go#L158

Added line #L158 was not covered by tests
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))

Check warning on line 162 in notify/notification_hms.go

View check run for this annotation

Codecov / codecov/patch

notify/notification_hms.go#L160-L162

Added lines #L160 - L162 were not covered by tests
}

logx.LogAccess.Debugf("Default message is %s", string(b))
return msgRequest, nil
return msgRequest

Check warning on line 165 in notify/notification_hms.go

View check run for this annotation

Codecov / codecov/patch

notify/notification_hms.go#L165

Added line #L165 was not covered by tests
}

// PushToHuawei provide send notification to Android server.
Expand Down Expand Up @@ -199,7 +199,7 @@
Retry:
isError := false

notification, _ := GetHuaweiNotification(req)
notification := GetHuaweiNotification(req)

Check warning on line 202 in notify/notification_hms.go

View check run for this annotation

Codecov / codecov/patch

notify/notification_hms.go#L202

Added line #L202 was not covered by tests

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()
keremoge marked this conversation as resolved.
Show resolved Hide resolved

return nil
return err
}

// Close the storage connection
Expand Down