From 35b816b92217237de922c928a6623b5ac426655a Mon Sep 17 00:00:00 2001 From: enahum Date: Tue, 6 Sep 2016 15:48:43 -0300 Subject: PLT-3921 Fix System Console Recent Active Users (#3856) * PLT-3921 System Console Recent Active Users --- model/client.go | 11 +++++++++++ model/user.go | 1 + 2 files changed, 12 insertions(+) (limited to 'model') diff --git a/model/client.go b/model/client.go index 2c3fb5aca..e54f61347 100644 --- a/model/client.go +++ b/model/client.go @@ -820,6 +820,17 @@ func (c *Client) GetClusterStatus() ([]*ClusterInfo, *AppError) { } } +// GetRecentlyActiveUsers returns a map of users including lastActivityAt using user id as the key +func (c *Client) GetRecentlyActiveUsers(teamId string) (*Result, *AppError) { + if r, err := c.DoApiGet("/admin/recently_active_users/"+teamId, "", ""); err != nil { + return nil, err + } else { + defer closeBody(r) + return &Result{r.Header.Get(HEADER_REQUEST_ID), + r.Header.Get(HEADER_ETAG_SERVER), UserMapFromJson(r.Body)}, nil + } +} + func (c *Client) GetAllAudits() (*Result, *AppError) { if r, err := c.DoApiGet("/admin/audits", "", ""); err != nil { return nil, err diff --git a/model/user.go b/model/user.go index 434ce2732..680bc48c9 100644 --- a/model/user.go +++ b/model/user.go @@ -48,6 +48,7 @@ type User struct { Locale string `json:"locale"` MfaActive bool `json:"mfa_active,omitempty"` MfaSecret string `json:"mfa_secret,omitempty"` + LastActivityAt int64 `db:"-" json:"last_activity_at,omitempty"` } // IsValid validates the user and returns an error if it isn't configured -- cgit v1.2.3-1-g7c22