Differentiate remove device error from push proxy (#27998)
* Differentiate remove device error from push proxy * Fix variable name
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
62adae14d1
Коммит
e121bebba5
@@ -47,11 +47,15 @@ func (a *App) NotifySessionsExpired() error {
|
||||
|
||||
errPush := a.sendToPushProxy(tmpMessage, session)
|
||||
if errPush != nil {
|
||||
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypePush, model.NotificationReasonPushProxySendError, tmpMessage.Platform)
|
||||
reason := model.NotificationReasonPushProxySendError
|
||||
if errPush.Error() == notificationErrorRemoveDevice {
|
||||
reason = model.NotificationReasonPushProxyRemoveDevice
|
||||
}
|
||||
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypePush, reason, tmpMessage.Platform)
|
||||
a.NotificationsLog().Error("Failed to send to push proxy",
|
||||
mlog.String("type", model.NotificationTypePush),
|
||||
mlog.String("status", model.NotificationStatusNotSent),
|
||||
mlog.String("reason", model.NotificationReasonPushProxySendError),
|
||||
mlog.String("reason", reason),
|
||||
mlog.String("ack_id", tmpMessage.AckId),
|
||||
mlog.String("push_type", tmpMessage.Type),
|
||||
mlog.String("user_id", session.UserId),
|
||||
|
||||
@@ -37,6 +37,8 @@ const (
|
||||
notificationTypeMessage notificationType = "message"
|
||||
notificationTypeUpdateBadge notificationType = "update_badge"
|
||||
notificationTypeDummy notificationType = "dummy"
|
||||
|
||||
notificationErrorRemoveDevice = "device was reported as removed"
|
||||
)
|
||||
|
||||
type PushNotificationsHub struct {
|
||||
@@ -184,11 +186,15 @@ func (a *App) sendPushNotificationToAllSessions(rctx request.CTX, msg *model.Pus
|
||||
|
||||
err = a.sendToPushProxy(tmpMessage, session)
|
||||
if err != nil {
|
||||
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypePush, model.NotificationReasonPushProxySendError, tmpMessage.Platform)
|
||||
reason := model.NotificationReasonPushProxySendError
|
||||
if err.Error() == notificationErrorRemoveDevice {
|
||||
reason = model.NotificationReasonPushProxyRemoveDevice
|
||||
}
|
||||
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypePush, reason, tmpMessage.Platform)
|
||||
a.NotificationsLog().Error("Failed to send to push proxy",
|
||||
mlog.String("type", model.NotificationTypePush),
|
||||
mlog.String("status", model.NotificationStatusNotSent),
|
||||
mlog.String("reason", model.NotificationReasonPushProxySendError),
|
||||
mlog.String("reason", reason),
|
||||
mlog.String("ack_id", tmpMessage.AckId),
|
||||
mlog.String("push_type", tmpMessage.Type),
|
||||
mlog.String("user_id", session.UserId),
|
||||
@@ -523,7 +529,7 @@ func (a *App) sendToPushProxy(msg *model.PushNotification, session *model.Sessio
|
||||
case model.PushStatusRemove:
|
||||
a.AttachDeviceId(session.Id, "", session.ExpiresAt)
|
||||
a.ClearSessionCacheForUser(session.UserId)
|
||||
return errors.New("device was reported as removed")
|
||||
return errors.New(notificationErrorRemoveDevice)
|
||||
case model.PushStatusFail:
|
||||
return errors.New(pushResponse[model.PushStatusErrorMsg])
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ const (
|
||||
NotificationReasonParseError NotificationReason = "json_parse_error"
|
||||
NotificationReasonPushProxyError NotificationReason = "push_proxy_error"
|
||||
NotificationReasonPushProxySendError NotificationReason = "push_proxy_send_error"
|
||||
NotificationReasonPushProxyRemoveDevice NotificationReason = "push_proxy_remove_device"
|
||||
NotificationReasonRejectedByPlugin NotificationReason = "rejected_by_plugin"
|
||||
NotificationReasonSessionExpired NotificationReason = "session_expired"
|
||||
NotificationReasonChannelMuted NotificationReason = "channel_muted"
|
||||
|
||||
Ссылка в новой задаче
Block a user