From fc9e5d8510a26d6b4a89b45f5b8b2779d82f62a9 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Tue, 28 Feb 2017 20:19:19 -0500 Subject: Fixing removing push tokens and logging error messages (#5551) --- app/notification.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'app/notification.go') diff --git a/app/notification.go b/app/notification.go index ae365b417..56b5ec336 100644 --- a/app/notification.go +++ b/app/notification.go @@ -552,7 +552,7 @@ func ClearPushNotification(userId string, channelId string) *model.AppError { return nil } -func sendToPushProxy(msg model.PushNotification, session *model.Session) *model.AppError { +func sendToPushProxy(msg model.PushNotification, session *model.Session) { msg.ServerId = utils.CfgDiagnosticId tr := &http.Transport{ @@ -563,22 +563,24 @@ func sendToPushProxy(msg model.PushNotification, session *model.Session) *model. request, _ := http.NewRequest("POST", *utils.Cfg.EmailSettings.PushNotificationServer+model.API_URL_SUFFIX_V1+"/send_push", strings.NewReader(msg.ToJson())) if resp, err := httpClient.Do(request); err != nil { - return model.NewLocAppError("sendToPushProxy", "api.post.send_notifications_and_forget.push_notification.error", map[string]interface{}{"DeviceId": msg.DeviceId, "Error": err.Error()}, "") + l4g.Error("Device push reported as error for UserId=%v SessionId=%v message=%v", session.UserId, session.Id, err.Error()) } else { - m := model.MapFromJson(resp.Body) + pushResponse := model.PushResponseFromJson(resp.Body) if resp.Body != nil { ioutil.ReadAll(resp.Body) resp.Body.Close() } - if m[model.STATUS] == model.STATUS_REMOVE { + if pushResponse[model.PUSH_STATUS] == model.PUSH_STATUS_REMOVE { l4g.Info("Device was reported as removed for UserId=%v SessionId=%v removing push for this session", session.UserId, session.Id) AttachDeviceId(session.Id, "", session.ExpiresAt) ClearSessionCacheForUser(session.UserId) } - } - return nil + if pushResponse[model.PUSH_STATUS] == model.PUSH_STATUS_FAIL { + l4g.Error("Device push reported as error for UserId=%v SessionId=%v message=%v", session.UserId, session.Id, pushResponse[model.PUSH_STATUS_ERROR_MSG]) + } + } } func getMobileAppSessions(userId string) ([]*model.Session, *model.AppError) { -- cgit v1.2.3-1-g7c22