MM-25263 Add group members to search and get users and create getGroupStats endpoint (#14733)

Add tests for SearchInGroup
Этот коммит содержится в:
Farhan Munshi
2020-06-18 10:22:35 -04:00
коммит произвёл GitHub
родитель f6c934d7e0
Коммит 77bee1d4f1
18 изменённых файлов: 517 добавлений и 2 удалений

Просмотреть файл

@@ -994,6 +994,17 @@ func (c *Client4) GetUsersWithoutTeam(page int, perPage int, etag string) ([]*Us
return UserListFromJson(r.Body), BuildResponse(r)
}
// GetUsersInGroup returns a page of users in a group. Page counting starts at 0.
func (c *Client4) GetUsersInGroup(groupID string, page int, perPage int, etag string) ([]*User, *Response) {
query := fmt.Sprintf("?in_group=%v&page=%v&per_page=%v", groupID, page, perPage)
r, err := c.DoApiGet(c.GetUsersRoute()+query, etag)
if err != nil {
return nil, BuildErrorResponse(r, err)
}
defer closeBody(r)
return UserListFromJson(r.Body), BuildResponse(r)
}
// GetUsersByIds returns a list of users based on the provided user ids.
func (c *Client4) GetUsersByIds(userIds []string) ([]*User, *Response) {
r, err := c.DoApiPost(c.GetUsersRoute()+"/ids", ArrayToJson(userIds))
@@ -5127,3 +5138,13 @@ func (c *Client4) RequestTrialLicense(users int) (bool, *Response) {
defer closeBody(r)
return CheckStatusOK(r), BuildResponse(r)
}
// GetGroupStats retrieves stats for a Mattermost Group
func (c *Client4) GetGroupStats(groupID string) (*GroupStats, *Response) {
r, appErr := c.DoApiGet(c.GetGroupRoute(groupID)+"/stats", "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
return GroupStatsFromJson(r.Body), BuildResponse(r)
}

Просмотреть файл

@@ -94,6 +94,11 @@ type PageOpts struct {
PerPage int
}
type GroupStats struct {
GroupID string `json:"group_id"`
TotalMemberCount int64 `json:"total_member_count"`
}
func (group *Group) Patch(patch *GroupPatch) {
if patch.Name != nil {
group.Name = patch.Name
@@ -208,3 +213,9 @@ func GroupPatchFromJson(data io.Reader) *GroupPatch {
json.NewDecoder(data).Decode(&groupPatch)
return groupPatch
}
func GroupStatsFromJson(data io.Reader) *GroupStats {
var groupStats *GroupStats
json.NewDecoder(data).Decode(&groupStats)
return groupStats
}

Просмотреть файл

@@ -12,6 +12,8 @@ type UserGetOptions struct {
InChannelId string
// Filters the users not in the channel
NotInChannelId string
// Filters the users in the group
InGroupId string
// Filters the users group constrained
GroupConstrained bool
// Filters the users without a team

Просмотреть файл

@@ -18,6 +18,7 @@ type UserSearch struct {
NotInTeamId string `json:"not_in_team_id"`
InChannelId string `json:"in_channel_id"`
NotInChannelId string `json:"not_in_channel_id"`
InGroupId string `json:"in_group_id"`
GroupConstrained bool `json:"group_constrained"`
AllowInactive bool `json:"allow_inactive"`
WithoutTeam bool `json:"without_team"`