diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-09-02 12:50:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-02 12:50:15 -0400 |
commit | f32eb525f3fa0828a23f589d765c267e3b2aea86 (patch) | |
tree | d4b76aecf89143029af080b3e1b4d87398e0adc5 /api/channel.go | |
parent | eb0111f6bbe2b0bf160a674dfe1b4d089f905cb9 (diff) | |
download | chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.tar.gz chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.tar.bz2 chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.zip |
Do not send push notifications for channels being actively viewed (#3931)
Diffstat (limited to 'api/channel.go')
-rw-r--r-- | api/channel.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/api/channel.go b/api/channel.go index e2c67f18b..c477a5ee4 100644 --- a/api/channel.go +++ b/api/channel.go @@ -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 |