Skip to content

Commit cabf9d2

Browse files
authored
Enable name-to-id translation for private channels (#559)
1 parent ada6f96 commit cabf9d2

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
with:
3131
ruby-version: ${{ matrix.entry.ruby }}
3232
bundler-cache: true # 'bundle install' and cache gems
33+
continue-on-error: ${{ matrix.entry.ignore || false }}
3334
- name: Run Tests
3435
continue-on-error: ${{ matrix.entry.ignore || false }}
3536
env:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### 2.6.1 (Next)
22

33
* [#554](https://github.com/slack-ruby/slack-ruby-client/pull/557): Require Faraday >= 2.0.1 - [@anrichvs](https://github.com/AnrichVS).
4+
* [#559](https://github.com/slack-ruby/slack-ruby-client/pull/559): Enable name-to-id translation of non-public channels - [@eizengan](https://github.com/eizengan).
45
* Your contribution here.
56

67
### 2.6.0 (2025/05/24)

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)