summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-23 06:34:22 -0400
committerGeorge Goldberg <george@gberg.me>2017-03-23 10:34:22 +0000
commit2a753949f10f70de26dba9fbff7c5ef9583d6c86 (patch)
tree4430844f254e62afdcf7b0e61da5870f2c8f7061 /model
parent7e2e8238842c7d158211faafe03f814bffa78a8f (diff)
downloadchat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.tar.gz
chat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.tar.bz2
chat-2a753949f10f70de26dba9fbff7c5ef9583d6c86.zip
Implement POST /users/search endpoint for APIv4 (#5822)
* Implement POST /users/search endpoint for APIv4 * PLT-2713 Added store functions for searching users that don't have a team * PLT-2713 Added 'without_team' option when searching users * PLT-2713 Added 'without_team' option when searching users (v4)
Diffstat (limited to 'model')
-rw-r--r--model/client4.go10
-rw-r--r--model/user_search.go1
2 files changed, 11 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index f6d665e1c..420b8d510 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -487,6 +487,16 @@ func (c *Client4) GetUsersByIds(userIds []string) ([]*User, *Response) {
}
}
+// SearchUsers returns a list of users based on some search criteria.
+func (c *Client4) SearchUsers(search *UserSearch) ([]*User, *Response) {
+ if r, err := c.DoApiPost(c.GetUsersRoute()+"/search", search.ToJson()); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return UserListFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// UpdateUser updates a user in the system based on the provided user struct.
func (c *Client4) UpdateUser(user *User) (*User, *Response) {
if r, err := c.DoApiPut(c.GetUserRoute(user.Id), user.ToJson()); err != nil {
diff --git a/model/user_search.go b/model/user_search.go
index 4bbd2bd78..1ef881130 100644
--- a/model/user_search.go
+++ b/model/user_search.go
@@ -14,6 +14,7 @@ type UserSearch struct {
InChannelId string `json:"in_channel_id"`
NotInChannelId string `json:"not_in_channel_id"`
AllowInactive bool `json:"allow_inactive"`
+ WithoutTeam bool `json:"without_team"`
}
// ToJson convert a User to a json string