diff options
author | samogot <samogot@gmail.com> | 2016-07-14 15:19:27 +0300 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-07-14 08:19:27 -0400 |
commit | 9b9facd3d21a7ab341dd6d80fd8b53fb852ae036 (patch) | |
tree | 11418f04ce57bb6083797c29ceba690b97302e15 /api/channel.go | |
parent | 6abc9601bec18e5005ff16dd4147bf038dafb264 (diff) | |
download | chat-9b9facd3d21a7ab341dd6d80fd8b53fb852ae036.tar.gz chat-9b9facd3d21a7ab341dd6d80fd8b53fb852ae036.tar.bz2 chat-9b9facd3d21a7ab341dd6d80fd8b53fb852ae036.zip |
PLT-3366 Holding down the ALT key and clicking on a message adds a new messages indicator (squashed) (#3374)
Diffstat (limited to 'api/channel.go')
-rw-r--r-- | api/channel.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/api/channel.go b/api/channel.go index 2a5b6f8b0..3fef273e5 100644 --- a/api/channel.go +++ b/api/channel.go @@ -44,6 +44,7 @@ func InitChannel() { BaseRoutes.NeedChannel.Handle("/add", ApiUserRequired(addMember)).Methods("POST") BaseRoutes.NeedChannel.Handle("/remove", ApiUserRequired(removeMember)).Methods("POST") BaseRoutes.NeedChannel.Handle("/update_last_viewed_at", ApiUserRequired(updateLastViewedAt)).Methods("POST") + BaseRoutes.NeedChannel.Handle("/set_last_viewed_at", ApiUserRequired(setLastViewedAt)).Methods("POST") } func createChannel(c *Context, w http.ResponseWriter, r *http.Request) { @@ -791,6 +792,34 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) { } } +func setLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + id := params["channel_id"] + + data := model.StringInterfaceFromJson(r.Body) + newLastViewedAt := int64(data["last_viewed_at"].(float64)) + + Srv.Store.Channel().SetLastViewedAt(id, c.Session.UserId, newLastViewedAt) + + preference := model.Preference{ + UserId: c.Session.UserId, + Category: model.PREFERENCE_CATEGORY_LAST, + Name: model.PREFERENCE_NAME_LAST_CHANNEL, + Value: id, + } + + Srv.Store.Preference().Save(&model.Preferences{preference}) + + message := model.NewWebSocketEvent(c.TeamId, id, c.Session.UserId, model.WEBSOCKET_EVENT_CHANNEL_VIEWED) + message.Add("channel_id", id) + + go Publish(message) + + result := make(map[string]string) + result["id"] = id + w.Write([]byte(model.MapToJson(result))) +} + func updateLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) id := params["channel_id"] |