summaryrefslogtreecommitdiffstats
path: root/api/status.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-12-21 16:35:01 -0500
committerChristopher Speller <crspeller@gmail.com>2016-12-21 16:35:01 -0500
commitba6e370ca71abacaa30234cb164427d27c86df13 (patch)
tree2379b6dab897deef1226f66772b8f05e0bb08f9c /api/status.go
parent139cb52c99ac525f44a280803447bbbd88369f23 (diff)
downloadchat-ba6e370ca71abacaa30234cb164427d27c86df13.tar.gz
chat-ba6e370ca71abacaa30234cb164427d27c86df13.tar.bz2
chat-ba6e370ca71abacaa30234cb164427d27c86df13.zip
PLT-5012 Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API (#4840)
* Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API * Remove preference DB writes
Diffstat (limited to 'api/status.go')
-rw-r--r--api/status.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/api/status.go b/api/status.go
index a0ad4cd76..99d5bc417 100644
--- a/api/status.go
+++ b/api/status.go
@@ -37,7 +37,6 @@ func InitStatus() {
BaseRoutes.Users.Handle("/status", ApiUserRequired(getStatusesHttp)).Methods("GET")
BaseRoutes.Users.Handle("/status/ids", ApiUserRequired(getStatusesByIdsHttp)).Methods("POST")
- BaseRoutes.Users.Handle("/status/set_active_channel", ApiUserRequired(setActiveChannel)).Methods("POST")
BaseRoutes.WebSocket.Handle("get_statuses", ApiWebSocketHandler(getStatusesWebSocket))
BaseRoutes.WebSocket.Handle("get_statuses_by_ids", ApiWebSocketHandler(getStatusesByIdsWebSocket))
}
@@ -305,42 +304,3 @@ func DoesStatusAllowPushNotification(user *model.User, status *model.Status, cha
return false
}
-
-func setActiveChannel(c *Context, w http.ResponseWriter, r *http.Request) {
- data := model.MapFromJson(r.Body)
-
- var channelId string
- var ok bool
- if channelId, ok = data["channel_id"]; !ok || len(channelId) > 26 {
- c.SetInvalidParam("setActiveChannel", "channel_id")
- return
- }
-
- if err := SetActiveChannel(c.Session.UserId, channelId); err != nil {
- c.Err = err
- return
- }
-
- ReturnStatusOK(w)
-}
-
-func SetActiveChannel(userId string, channelId string) *model.AppError {
- status, err := GetStatus(userId)
- if err != nil {
- status = &model.Status{userId, model.STATUS_ONLINE, false, model.GetMillis(), channelId}
- } else {
- status.ActiveChannel = channelId
- if !status.Manual {
- status.Status = model.STATUS_ONLINE
- }
- status.LastActivityAt = model.GetMillis()
- }
-
- AddStatusCache(status)
-
- if result := <-Srv.Store.Status().SaveOrUpdate(status); result.Err != nil {
- return result.Err
- }
-
- return nil
-}