diff options
Diffstat (limited to 'api/channel.go')
-rw-r--r-- | api/channel.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/api/channel.go b/api/channel.go index faa39e13c..e2c67f18b 100644 --- a/api/channel.go +++ b/api/channel.go @@ -846,8 +846,24 @@ func updateLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) id := params["channel_id"] + doClearPush := false + if *utils.Cfg.EmailSettings.SendPushNotifications && !c.Session.IsMobileApp() { + 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 { + if result.Data.(int64) > 0 { + doClearPush = true + } + } + } + Srv.Store.Channel().UpdateLastViewedAt(id, c.Session.UserId) + // Must be after update so that unread count is correct + if doClearPush { + go clearPushNotification(c.Session.UserId, id) + } + preference := model.Preference{ UserId: c.Session.UserId, Category: model.PREFERENCE_CATEGORY_LAST, |