[MM-13500] Adds channel /search_group endpoint (#10805)

* [MM-13500] Adds channel /search_group endpoint

* Add LIMIT to the queries

* Fix i18n extract

* Fix tests

* Add a new endpoint to get profiles by group channel ids

* Rebase fix
This commit is contained in:
Miguel de la Cruz
2019-06-22 00:14:21 +01:00
committed by GitHub
parent 604e247135
commit 9e9b008f3d
15 changed files with 655 additions and 5 deletions

View File

@@ -946,6 +946,20 @@ func (c *Client4) GetUsersByUsernames(usernames []string) ([]*User, *Response) {
return UserListFromJson(r.Body), BuildResponse(r)
}
// GetUsersByGroupChannelIds returns a map with channel ids as keys
// and a list of users as values based on the provided user ids.
func (c *Client4) GetUsersByGroupChannelIds(groupChannelIds []string) (map[string][]*User, *Response) {
r, err := c.DoApiPost(c.GetUsersRoute()+"/group_channels", ArrayToJson(groupChannelIds))
if err != nil {
return nil, BuildErrorResponse(r, err)
}
defer closeBody(r)
usersByChannelId := map[string][]*User{}
json.NewDecoder(r.Body).Decode(&usersByChannelId)
return usersByChannelId, BuildResponse(r)
}
// SearchUsers returns a list of users based on some search criteria.
func (c *Client4) SearchUsers(search *UserSearch) ([]*User, *Response) {
r, err := c.doApiPostBytes(c.GetUsersRoute()+"/search", search.ToJson())
@@ -2056,6 +2070,16 @@ func (c *Client4) SearchAllChannels(search *ChannelSearch) (*ChannelListWithTeam
return ChannelListWithTeamDataFromJson(r.Body), BuildResponse(r)
}
// SearchGroupChannels returns the group channels of the user whose members' usernames match the search term.
func (c *Client4) SearchGroupChannels(search *ChannelSearch) ([]*Channel, *Response) {
r, err := c.DoApiPost(c.GetChannelsRoute()+"/group/search", search.ToJson())
if err != nil {
return nil, BuildErrorResponse(r, err)
}
defer closeBody(r)
return ChannelSliceFromJson(r.Body), BuildResponse(r)
}
// DeleteChannel deletes channel based on the provided channel id string.
func (c *Client4) DeleteChannel(channelId string) (bool, *Response) {
r, err := c.DoApiDelete(c.GetChannelRoute(channelId))