summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
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