MM-24694: Add getGroupsByUserId to API layer (#14443)

* add getGroupsByUserId to API layer

* update for lint errors

* add check for contextId = userId or ManageSystem Permission

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Scott Bishel
2020-05-07 13:35:56 -06:00
коммит произвёл GitHub
родитель 882b0324b5
Коммит bdd0e9febb
3 изменённых файлов: 113 добавлений и 0 удалений

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

@@ -3793,6 +3793,22 @@ func (c *Client4) GetGroups(opts GroupSearchOpts) ([]*Group, *Response) {
return GroupsFromJson(r.Body), BuildResponse(r)
}
// GetGroupsByUserId retrieves Mattermost Groups for a user
func (c *Client4) GetGroupsByUserId(userId string) ([]*Group, *Response) {
path := fmt.Sprintf(
"%s/%v/groups",
c.GetUsersRoute(),
userId,
)
r, appErr := c.DoApiGet(path, "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
return GroupsFromJson(r.Body), BuildResponse(r)
}
// Audits Section
// GetAudits returns a list of audits for the whole system.