summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-09-02 12:50:15 -0400
committerGitHub <noreply@github.com>2016-09-02 12:50:15 -0400
commitf32eb525f3fa0828a23f589d765c267e3b2aea86 (patch)
treed4b76aecf89143029af080b3e1b4d87398e0adc5 /api/channel.go
parenteb0111f6bbe2b0bf160a674dfe1b4d089f905cb9 (diff)
downloadchat-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.go16
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