Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change UpdateUserGroupMembers to accept slice of group members #1172

Open
painhardcore opened this issue Feb 16, 2023 · 0 comments · May be fixed by #1173
Open

Change UpdateUserGroupMembers to accept slice of group members #1172

painhardcore opened this issue Feb 16, 2023 · 0 comments · May be fixed by #1173

Comments

@painhardcore
Copy link

It's really inconvenient api to get members of the group

slack/usergroups.go

Lines 271 to 283 in 1edf0c7

// GetUserGroupMembersContext will retrieve the current list of users in a group with a custom context
func (api *Client) GetUserGroupMembersContext(ctx context.Context, userGroup string) ([]string, error) {
values := url.Values{
"token": {api.token},
"usergroup": {userGroup},
}
response, err := api.userGroupRequest(ctx, "usergroups.users.list", values)
if err != nil {
return []string{}, err
}
return response.Users, nil
}

And then if I need to perform an update - I need to do extra things

slack/usergroups.go

Lines 285 to 302 in 1edf0c7

// UpdateUserGroupMembers will update the members of an existing user group
func (api *Client) UpdateUserGroupMembers(userGroup string, members string) (UserGroup, error) {
return api.UpdateUserGroupMembersContext(context.Background(), userGroup, members)
}
// UpdateUserGroupMembersContext will update the members of an existing user group with a custom context
func (api *Client) UpdateUserGroupMembersContext(ctx context.Context, userGroup string, members string) (UserGroup, error) {
values := url.Values{
"token": {api.token},
"usergroup": {userGroup},
"users": {members},
}
response, err := api.userGroupRequest(ctx, "usergroups.users.update", values)
if err != nil {
return UserGroup{}, err
}
return response.UserGroup, nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants