slack-go / slack

Slack API in Go, originally by @nlopes; Maintainers needed, contact @parsley42
https://pkg.go.dev/github.com/slack-go/slack
BSD 2-Clause "Simplified" License
4.69k stars 1.14k forks source link

Fixes updateUserGroup cannot clear the description and the default channels #1082

Closed jmatsu closed 2 years ago

jmatsu commented 2 years ago

Fix: https://github.com/slack-go/slack/issues/1081

Expected

We can clear the description and the default channels of usergroups by sending empty strings.

Actual

updateUserGroup ignores empty strings so this never sends empty strings to the server.

Examples

The followings are examples using curl. ref: https://api.slack.com/methods/usergroups.update

Set Up

curl -F token=... -F usergroup=SJ6JQHVBN --url 'https://slack.com/api/usergroups.update' -F description="this is a description" -F handle="zz__test_usergroup" -F name="this is a name" -F channels=C92MKCRPU {"usergroup":{"id":"SJ6JQHVBN","name":"this is a name","description":"this is a description","handle":"zz__test_usergroup","prefs":{"channels":["C92MKCRPU"],"groups":[]}}, ...}

Clear the default channels

curl -F token=... -F usergroup=SJ6JQHVBN --url 'https://slack.com/api/usergroups.update' -F description="this is a description" -F handle="zz__test_usergroup" -F name="this is a name" -F channels= {"usergroup":{"id":"SJ6JQHVBN","name":"this is a name","description":"this is a description","handle":"zz__test_usergroup","prefs":{"channels":[],"groups":[]}}, ...}

Clear the description

curl -F token=... -F usergroup=SJ6JQHVBN --url 'https://slack.com/api/usergroups.update' -F description= -F handle="zz__test_usergroup" -F name="this is a name" -F channels= {"usergroup":{"id":"SJ6JQHVBN","name":"this is a name","description":"","handle":"zz__test_usergroup","prefs":{"channels":[],"groups":[]}}, ...}


PR preparation

✅ Ran make pr-prop on HEAD (38367d1)

Should this be an issue instead
API changes

Since API changes have to be maintained they undergo a more detailed review and are more likely to require changes.

Examples of API changes that do not meet guidelines:

N/A

jmatsu commented 2 years ago

@kanata2 Thanks for your review. Could you please have a look again?

kanata2 commented 2 years ago

Released! https://github.com/slack-go/slack/releases/tag/v0.11.2