diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-03-30 17:09:39 +0200 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-03-30 08:09:39 -0700 |
commit | 29e6db5713c57d7bb46d7aea38b1001b9e8a1212 (patch) | |
tree | 66d0a06a35068ce26024b0b9c030de0b1c8bab5c /api4/status.go | |
parent | ee3b983a6344d78bafa553607133020e8e1fb0ed (diff) | |
download | chat-29e6db5713c57d7bb46d7aea38b1001b9e8a1212.tar.gz chat-29e6db5713c57d7bb46d7aea38b1001b9e8a1212.tar.bz2 chat-29e6db5713c57d7bb46d7aea38b1001b9e8a1212.zip |
Implement POST /users/status/ids for apiv4 (#5894)
Diffstat (limited to 'api4/status.go')
-rw-r--r-- | api4/status.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/api4/status.go b/api4/status.go index 5cd6a4536..142f5ce5a 100644 --- a/api4/status.go +++ b/api4/status.go @@ -17,6 +17,7 @@ func InitStatus() { l4g.Debug(utils.T("api.status.init.debug")) BaseRoutes.User.Handle("/status", ApiHandler(getUserStatus)).Methods("GET") + BaseRoutes.Users.Handle("/status/ids", ApiHandler(getUserStatusesByIds)).Methods("POST") } @@ -26,6 +27,8 @@ func getUserStatus(c *Context, w http.ResponseWriter, r *http.Request) { return } + // No permission check required + if statusMap, err := app.GetUserStatusesByIds([]string{c.Params.UserId}); err != nil { c.Err = err return @@ -38,3 +41,21 @@ func getUserStatus(c *Context, w http.ResponseWriter, r *http.Request) { } } } + +func getUserStatusesByIds(c *Context, w http.ResponseWriter, r *http.Request) { + userIds := model.ArrayFromJson(r.Body) + + if len(userIds) == 0 { + c.SetInvalidParam("user_ids") + return + } + + // No permission check required + + if statusMap, err := app.GetUserStatusesByIds(userIds); err != nil { + c.Err = err + return + } else { + w.Write([]byte(model.StatusListToJson(statusMap))) + } +} |