From 2114e96f0045376f41d5c318f7cf45b6b50141dc Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 27 Jun 2018 17:19:06 -0400 Subject: Reset status to away after web conn disconnect if necessary (#8988) --- app/status.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/status.go') diff --git a/app/status.go b/app/status.go index e2367a396..460cbbbd0 100644 --- a/app/status.go +++ b/app/status.go @@ -161,6 +161,22 @@ func (a *App) GetUserStatusesByIds(userIds []string) ([]*model.Status, *model.Ap return statusMap, nil } +// SetStatusLastActivityAt sets the last activity at for a user on the local app server and updates +// status to away if needed. Used by the WS to set status to away if an 'online' device disconnects +// while an 'away' device is still connected +func (a *App) SetStatusLastActivityAt(userId string, activityAt int64) { + var status *model.Status + var err *model.AppError + if status, err = a.GetStatus(userId); err != nil { + return + } + + status.LastActivityAt = activityAt + + a.AddStatusCacheSkipClusterSend(status) + a.SetStatusAwayIfNeeded(userId, false) +} + func (a *App) SetStatusOnline(userId string, sessionId string, manual bool) { if !*a.Config().ServiceSettings.EnableUserStatuses { return -- cgit v1.2.3-1-g7c22