diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-03 15:17:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-03 15:17:34 -0500 |
commit | 7ff2aef7facdeb025a1651ef411fceb3d81932c1 (patch) | |
tree | 7ea2f7b89e4b4c1acf3ca021377b0166089ba397 /api | |
parent | 948b557453550646ad3213cb4144055eb7db0d69 (diff) | |
download | chat-7ff2aef7facdeb025a1651ef411fceb3d81932c1.tar.gz chat-7ff2aef7facdeb025a1651ef411fceb3d81932c1.tar.bz2 chat-7ff2aef7facdeb025a1651ef411fceb3d81932c1.zip |
Implement GET /users endpoint for APIv4 (#5277)
Diffstat (limited to 'api')
-rw-r--r-- | api/command_loadtest.go | 2 | ||||
-rw-r--r-- | api/user.go | 29 |
2 files changed, 6 insertions, 25 deletions
diff --git a/api/command_loadtest.go b/api/command_loadtest.go index 5ad2736a0..3b9ebfe47 100644 --- a/api/command_loadtest.go +++ b/api/command_loadtest.go @@ -291,7 +291,7 @@ func (me *LoadTestProvider) PostsCommand(c *Context, channelId string, message s var usernames []string if result := <-app.Srv.Store.User().GetProfiles(c.TeamId, 0, 1000); result.Err == nil { - profileUsers := result.Data.(map[string]*model.User) + profileUsers := result.Data.([]*model.User) usernames = make([]string, len(profileUsers)) i := 0 for _, userprof := range profileUsers { diff --git a/api/user.go b/api/user.go index 6f40388b2..c6d9e5c25 100644 --- a/api/user.go +++ b/api/user.go @@ -442,14 +442,10 @@ func getProfiles(c *Context, w http.ResponseWriter, r *http.Request) { return } - if profiles, err := app.GetUsers(offset, limit); err != nil { + if profiles, err := app.GetUsersMap(offset, limit, c.IsSystemAdmin()); err != nil { c.Err = err return } else { - for k, p := range profiles { - profiles[k] = sanitizeProfile(c, p) - } - w.Header().Set(model.HEADER_ETAG_SERVER, etag) w.Write([]byte(model.UserMapToJson(profiles))) } @@ -482,14 +478,10 @@ func getProfilesInTeam(c *Context, w http.ResponseWriter, r *http.Request) { return } - if profiles, err := app.GetUsersInTeam(teamId, offset, limit); err != nil { + if profiles, err := app.GetUsersInTeamMap(teamId, offset, limit, c.IsSystemAdmin()); err != nil { c.Err = err return } else { - for k, p := range profiles { - profiles[k] = sanitizeProfile(c, p) - } - w.Header().Set(model.HEADER_ETAG_SERVER, etag) w.Write([]byte(model.UserMapToJson(profiles))) } @@ -523,17 +515,10 @@ func getProfilesInChannel(c *Context, w http.ResponseWriter, r *http.Request) { return } - var profiles map[string]*model.User - var profileErr *model.AppError - - if profiles, err = app.GetUsersInChannel(channelId, offset, limit); profileErr != nil { - c.Err = profileErr + if profiles, err := app.GetUsersInChannelMap(channelId, offset, limit, c.IsSystemAdmin()); err != nil { + c.Err = err return } else { - for k, p := range profiles { - profiles[k] = sanitizeProfile(c, p) - } - w.Write([]byte(model.UserMapToJson(profiles))) } } @@ -566,14 +551,10 @@ func getProfilesNotInChannel(c *Context, w http.ResponseWriter, r *http.Request) return } - if profiles, err := app.GetUsersNotInChannel(c.TeamId, channelId, offset, limit); err != nil { + if profiles, err := app.GetUsersNotInChannelMap(c.TeamId, channelId, offset, limit, c.IsSystemAdmin()); err != nil { c.Err = err return } else { - for k, p := range profiles { - profiles[k] = sanitizeProfile(c, p) - } - w.Write([]byte(model.UserMapToJson(profiles))) } } |