summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nlopes/slack/channels.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-01-31 17:06:36 +0100
committerWim <wim@42.be>2019-01-31 17:06:36 +0100
commitc81c0dd22a7779148c4890cfd4bbf490054f06f1 (patch)
tree06ce6fcdc8f3a2278a2f3050ba42088dd2e64485 /vendor/github.com/nlopes/slack/channels.go
parentf8a1ab4622a5b833282e9ee42f382451d17c1a06 (diff)
downloadmatterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.gz
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.bz2
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.zip
Update vendor, move to labstack/echo/v4 Fixes #698
Diffstat (limited to 'vendor/github.com/nlopes/slack/channels.go')
-rw-r--r--vendor/github.com/nlopes/slack/channels.go50
1 files changed, 41 insertions, 9 deletions
diff --git a/vendor/github.com/nlopes/slack/channels.go b/vendor/github.com/nlopes/slack/channels.go
index 007985bc..711ae7c5 100644
--- a/vendor/github.com/nlopes/slack/channels.go
+++ b/vendor/github.com/nlopes/slack/channels.go
@@ -38,6 +38,29 @@ func channelRequest(ctx context.Context, client httpClient, path string, values
return response, nil
}
+type channelsConfig struct {
+ values url.Values
+}
+
+// GetChannelsOption option provided when getting channels.
+type GetChannelsOption func(*channelsConfig) error
+
+// GetChannelsOptionExcludeMembers excludes the members collection from each channel.
+func GetChannelsOptionExcludeMembers() GetChannelsOption {
+ return func(config *channelsConfig) error {
+ config.values.Add("exclude_members", "true")
+ return nil
+ }
+}
+
+// GetChannelsOptionExcludeArchived excludes archived channels from results.
+func GetChannelsOptionExcludeArchived() GetChannelsOption {
+ return func(config *channelsConfig) error {
+ config.values.Add("exclude_archived", "true")
+ return nil
+ }
+}
+
// ArchiveChannel archives the given channel
// see https://api.slack.com/methods/channels.archive
func (api *Client) ArchiveChannel(channelID string) error {
@@ -150,8 +173,9 @@ func (api *Client) GetChannelInfo(channelID string) (*Channel, error) {
// see https://api.slack.com/methods/channels.info
func (api *Client) GetChannelInfoContext(ctx context.Context, channelID string) (*Channel, error) {
values := url.Values{
- "token": {api.token},
- "channel": {channelID},
+ "token": {api.token},
+ "channel": {channelID},
+ "include_locale": {strconv.FormatBool(true)},
}
response, err := channelRequest(ctx, api.httpclient, "channels.info", values, api)
@@ -247,21 +271,29 @@ func (api *Client) KickUserFromChannelContext(ctx context.Context, channelID, us
// GetChannels retrieves all the channels
// see https://api.slack.com/methods/channels.list
-func (api *Client) GetChannels(excludeArchived bool) ([]Channel, error) {
- return api.GetChannelsContext(context.Background(), excludeArchived)
+func (api *Client) GetChannels(excludeArchived bool, options ...GetChannelsOption) ([]Channel, error) {
+ return api.GetChannelsContext(context.Background(), excludeArchived, options...)
}
// GetChannelsContext retrieves all the channels with a custom context
// see https://api.slack.com/methods/channels.list
-func (api *Client) GetChannelsContext(ctx context.Context, excludeArchived bool) ([]Channel, error) {
- values := url.Values{
- "token": {api.token},
+func (api *Client) GetChannelsContext(ctx context.Context, excludeArchived bool, options ...GetChannelsOption) ([]Channel, error) {
+ config := channelsConfig{
+ values: url.Values{
+ "token": {api.token},
+ },
}
if excludeArchived {
- values.Add("exclude_archived", "1")
+ options = append(options, GetChannelsOptionExcludeArchived())
+ }
+
+ for _, opt := range options {
+ if err := opt(&config); err != nil {
+ return nil, err
+ }
}
- response, err := channelRequest(ctx, api.httpclient, "channels.list", values, api)
+ response, err := channelRequest(ctx, api.httpclient, "channels.list", config.values, api)
if err != nil {
return nil, err
}