Do not send push notifications for channels being actively viewed (#3931)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
eb0111f6bb
Коммит
f32eb525f3
@@ -846,8 +846,16 @@ func updateLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["channel_id"]
|
||||
|
||||
data := model.StringInterfaceFromJson(r.Body)
|
||||
|
||||
var active bool
|
||||
var ok bool
|
||||
if active, ok = data["active"].(bool); !ok {
|
||||
active = true
|
||||
}
|
||||
|
||||
doClearPush := false
|
||||
if *utils.Cfg.EmailSettings.SendPushNotifications && !c.Session.IsMobileApp() {
|
||||
if *utils.Cfg.EmailSettings.SendPushNotifications && !c.Session.IsMobileApp() && active {
|
||||
if result := <-Srv.Store.User().GetUnreadCountForChannel(c.Session.UserId, id); result.Err != nil {
|
||||
l4g.Error(utils.T("api.channel.update_last_viewed_at.get_unread_count_for_channel.error"), c.Session.UserId, id, result.Err.Error())
|
||||
} else {
|
||||
@@ -857,6 +865,12 @@ func updateLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := SetActiveChannel(c.Session.UserId, id); err != nil {
|
||||
l4g.Error(err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
Srv.Store.Channel().UpdateLastViewedAt(id, c.Session.UserId)
|
||||
|
||||
// Must be after update so that unread count is correct
|
||||
|
||||
Ссылка в новой задаче
Block a user