mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user