diff options
author | lisakycho <lisakycho@gmail.com> | 2018-06-07 09:45:49 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-06-07 12:45:49 -0400 |
commit | e09b3c566b2de1da1d916d3e209c96d43be739e2 (patch) | |
tree | 3a9629a4fdac0a6e43382a17484458cc60ce2a25 /api4/user.go | |
parent | c8d95958335c8daf8e67aa021c2c82f78bf4abd4 (diff) | |
download | chat-e09b3c566b2de1da1d916d3e209c96d43be739e2.tar.gz chat-e09b3c566b2de1da1d916d3e209c96d43be739e2.tar.bz2 chat-e09b3c566b2de1da1d916d3e209c96d43be739e2.zip |
Get the count of the all system users at endpoint /users/stats (#8847)
* Get the count of the all system users at endpoint /users/stats
* Added GetTotalUsersStats test in api4
* Changed pluralization and added the test back.
Diffstat (limited to 'api4/user.go')
-rw-r--r-- | api4/user.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/api4/user.go b/api4/user.go index 2292544c4..39d2eac61 100644 --- a/api4/user.go +++ b/api4/user.go @@ -22,6 +22,7 @@ func (api *API) InitUser() { api.BaseRoutes.Users.Handle("/usernames", api.ApiSessionRequired(getUsersByNames)).Methods("POST") api.BaseRoutes.Users.Handle("/search", api.ApiSessionRequired(searchUsers)).Methods("POST") api.BaseRoutes.Users.Handle("/autocomplete", api.ApiSessionRequired(autocompleteUsers)).Methods("GET") + api.BaseRoutes.Users.Handle("/stats", api.ApiSessionRequired(getTotalUsersStats)).Methods("GET") api.BaseRoutes.User.Handle("", api.ApiSessionRequired(getUser)).Methods("GET") api.BaseRoutes.User.Handle("/image", api.ApiSessionRequiredTrustRequester(getProfileImage)).Methods("GET") @@ -278,6 +279,20 @@ func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { ReturnStatusOK(w) } +func getTotalUsersStats(c *Context, w http.ResponseWriter, r *http.Request) { + if c.Err != nil { + return + } + + if stats, err := c.App.GetTotalUsersStats(); err != nil { + c.Err = err + return + } else { + w.Write([]byte(stats.ToJson())) + return + } +} + func getUsers(c *Context, w http.ResponseWriter, r *http.Request) { inTeamId := r.URL.Query().Get("in_team") notInTeamId := r.URL.Query().Get("not_in_team") |