[MM 7970] Support maintaining online status while the Desktop App is in the background ... and other things. (#11312)

* receive os-level user status updates via websocket

* removing debugging
This commit is contained in:
Dean Whillier
2019-06-21 17:46:06 -04:00
committed by GitHub
parent 0d8377cc59
commit cfd9d314a3

View File

@@ -9,6 +9,7 @@ import (
func (api *API) InitUser() {
api.Router.Handle("user_typing", api.ApiWebSocketHandler(api.userTyping))
api.Router.Handle("user_update_active_status", api.ApiWebSocketHandler(api.userUpdateActiveStatus))
}
func (api *API) userTyping(req *model.WebSocketRequest) (map[string]interface{}, *model.AppError) {
@@ -33,3 +34,24 @@ func (api *API) userTyping(req *model.WebSocketRequest) (map[string]interface{},
return nil, nil
}
func (api *API) userUpdateActiveStatus(req *model.WebSocketRequest) (map[string]interface{}, *model.AppError) {
var ok bool
var userIsActive bool
if userIsActive, ok = req.Data["user_is_active"].(bool); !ok {
return nil, NewInvalidWebSocketParamError(req.Action, "user_is_active")
}
var manual bool
if manual, ok = req.Data["manual"].(bool); !ok {
manual = false
}
if userIsActive {
api.App.SetStatusOnline(req.Session.UserId, manual)
} else {
api.App.SetStatusAwayIfNeeded(req.Session.UserId, manual)
}
return nil, nil
}