MM-36687 CRT push notifications (#18347)
* CRT changes * Lint fix * Moved postId check * Moved postId check * Lint fix * Misc * Added test case for badge count while clearing notifications * Fixed count when CRT is on and added isCRTEnabled, teamId to isIdLoaded notifications * test fix * isCRTEnabledForUser capitalised Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
929caaff3d
Коммит
65c670a4c9
@@ -511,11 +511,6 @@ func pushNotificationAck(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, appErr := c.App.GetPostIfAuthorized(ack.PostId, c.AppContext.Session()); appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
|
||||
if !*c.App.Config().EmailSettings.SendPushNotifications {
|
||||
c.Err = model.NewAppError("pushNotificationAck", "api.push_notification.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
@@ -533,21 +528,28 @@ func pushNotificationAck(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
}
|
||||
|
||||
notificationInterface := c.App.Notification()
|
||||
// Return post data only when PostId is passed.
|
||||
if ack.PostId != "" && ack.NotificationType == model.PushTypeMessage {
|
||||
if _, appErr := c.App.GetPostIfAuthorized(ack.PostId, c.AppContext.Session()); appErr != nil {
|
||||
c.Err = appErr
|
||||
return
|
||||
}
|
||||
|
||||
if notificationInterface == nil {
|
||||
c.Err = model.NewAppError("pushNotificationAck", "api.system.id_loaded.not_available.app_error", nil, "", http.StatusFound)
|
||||
return
|
||||
}
|
||||
notificationInterface := c.App.Notification()
|
||||
|
||||
msg, appError := notificationInterface.GetNotificationMessage(&ack, c.AppContext.Session().UserId)
|
||||
if appError != nil {
|
||||
c.Err = model.NewAppError("pushNotificationAck", "api.push_notification.id_loaded.fetch.app_error", nil, appError.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if notificationInterface == nil {
|
||||
c.Err = model.NewAppError("pushNotificationAck", "api.system.id_loaded.not_available.app_error", nil, "", http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
if err2 := json.NewEncoder(w).Encode(msg); err2 != nil {
|
||||
mlog.Warn("Error while writing response", mlog.Err(err2))
|
||||
msg, appError := notificationInterface.GetNotificationMessage(&ack, c.AppContext.Session().UserId)
|
||||
if appError != nil {
|
||||
c.Err = model.NewAppError("pushNotificationAck", "api.push_notification.id_loaded.fetch.app_error", nil, appError.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if err2 := json.NewEncoder(w).Encode(msg); err2 != nil {
|
||||
mlog.Warn("Error while writing response", mlog.Err(err2))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Ссылка в новой задаче
Block a user