Skip to content

Commit d603a3e

Browse files
committed
Enable name-to-id translation for private channels
1 parent ada6f96 commit d603a3e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/slack/web/api/mixins/conversations.id.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ module Conversations
1414
# Channel to get ID for, prefixed with #.
1515
# @option options [integer] :id_limit
1616
# The page size used for conversations_list calls required to find the channel's ID
17+
# @option options [string] :id_types
18+
# The types of conversations to use when searching for the ID. A comma-separated list
19+
# containing one or more of public_channel, private_channel, mpim, im
1720
def conversations_id(options = {})
1821
name = options[:channel]
1922
limit = options.fetch(:id_limit, Slack::Web.config.conversations_id_page_size)
23+
types = options.fetch(:id_types, nil)
2024

2125
raise ArgumentError, 'Required arguments :channel missing' if name.nil?
2226

@@ -26,7 +30,7 @@ def conversations_id(options = {})
2630
prefix: '#',
2731
enum_method: :conversations_list,
2832
list_method: :channels,
29-
options: { limit: limit }.compact
33+
options: { limit: limit, types: types }.compact
3034
)
3135
end
3236
end

spec/slack/web/api/mixins/conversations_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@
3737
)
3838
end
3939

40-
it 'forwards a provided limit to the underlying conversations_list calls' do
40+
it 'forwards the provided limit to the underlying conversations_list calls' do
4141
expect(conversations).to receive(:conversations_list).with(limit: 1234)
4242
conversations.conversations_id(channel: '#general', id_limit: 1234)
4343
end
4444

45+
it 'forwards a provided types to the underlying conversations_list calls' do
46+
expect(conversations).to receive(:conversations_list).with(types: 'public_channel,private_channel')
47+
conversations.conversations_id(channel: '#general', id_types: 'public_channel,private_channel')
48+
end
49+
4550
it 'fails with an exception' do
4651
expect { conversations.conversations_id(channel: '#invalid') }.to(
4752
raise_error(Slack::Web::Api::Errors::SlackError, 'channel_not_found')

0 commit comments

Comments
 (0)