diff options
author | Stephen Kiers <stephen@stephenkiers.com> | 2018-03-09 05:48:30 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-03-09 07:48:30 -0500 |
commit | 302dae5bb982aad14324a4df61a018557f3dd24e (patch) | |
tree | 8e1b8b52b3c717dd90ade42ad6dd1e3a265d9903 /api4/user.go | |
parent | 31532f7feb4055f42538e23d48d4f0c941609db1 (diff) | |
download | chat-302dae5bb982aad14324a4df61a018557f3dd24e.tar.gz chat-302dae5bb982aad14324a4df61a018557f3dd24e.tar.bz2 chat-302dae5bb982aad14324a4df61a018557f3dd24e.zip |
MM-9274- Sort Users in Channel by status (#8181)
* sort by lastActivity
* added status ordering to Users
* sort offline before dnd
* remove data not needed
* added seperate call for when order=‘status’ is on GetUser request
* remove PrintLn
* styling fix
* remove mistake
* mistake 2
* better comment
* explicit if statemnt
* writing tests
* removed manually added mocks
* generated mock
* ICU-668 Added unit tests
* style fix
* sort by lastActivity
* added status ordering to Users
* sort offline before dnd
* remove data not needed
* added seperate call for when order=‘status’ is on GetUser request
* remove PrintLn
* styling fix
* remove mistake
* mistake 2
* better comment
* explicit if statemnt
* writing tests
* removed manually added mocks
* generated mock
* ICU-668 Added unit tests
* style fix
* reverse dnd and offline
* Fixed app.SaveStatusAndBroadcast
* Fixed incorrect merge
* Fixing incorrect merge again
Diffstat (limited to 'api4/user.go')
-rw-r--r-- | api4/user.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/api4/user.go b/api4/user.go index f82a6e3d5..8f8f08c75 100644 --- a/api4/user.go +++ b/api4/user.go @@ -290,16 +290,21 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) { return } - if sort != "" && sort != "last_activity_at" && sort != "create_at" { + if sort != "" && sort != "last_activity_at" && sort != "create_at" && sort != "status" { c.SetInvalidUrlParam("sort") return } // Currently only supports sorting on a team + // or sort="status" on inChannelId if (sort == "last_activity_at" || sort == "create_at") && (inTeamId == "" || notInTeamId != "" || inChannelId != "" || notInChannelId != "" || withoutTeam != "") { c.SetInvalidUrlParam("sort") return } + if sort == "status" && inChannelId == "" { + c.SetInvalidUrlParam("sort") + return + } var profiles []*model.User var err *model.AppError @@ -355,8 +360,11 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) { c.SetPermissionError(model.PERMISSION_READ_CHANNEL) return } - - profiles, err = c.App.GetUsersInChannelPage(inChannelId, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin()) + if sort == "status" { + profiles, err = c.App.GetUsersInChannelPageByStatus(inChannelId, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin()) + } else { + profiles, err = c.App.GetUsersInChannelPage(inChannelId, c.Params.Page, c.Params.PerPage, c.IsSystemAdmin()) + } } else { // No permission check required |