Skip to content

Commit dd41b8f

Browse files
committed
Configurable page size when calcualting conversations_id
1 parent af8828f commit dd41b8f

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* [#549](https://github.com/slack-ruby/slack-ruby-client/pull/549): Add group ID formatting support for message mentions - [@n0h0](https://github.com/n0h0).
44
* [#553](https://github.com/slack-ruby/slack-ruby-client/pull/553): Use `secure_compare` during signature verification - [@hieuk09](https://github.com/hieuk09).
5+
* [#555](https://github.com/slack-ruby/slack-ruby-client/pull/555): Make page size while looking for a Conversation's ID configurable - [@eizengan](https://github.com/eizengan).
56
* Your contribution here.
67

78
### 2.5.2 (2025/02/19)

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ def conversations_id(options = {})
1616
name = options[:channel]
1717
raise ArgumentError, 'Required arguments :channel missing' if name.nil?
1818

19-
id_for :channel, name, '#', :conversations_list, :channels, 'channel_not_found'
19+
id_for(
20+
:channel,
21+
name,
22+
'#',
23+
:conversations_list,
24+
:channels,
25+
'channel_not_found',
26+
enum_method_options: { limit: conversations_id_page_size }
27+
)
2028
end
2129
end
2230
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module Mixins
66
module Ids
77
private
88

9-
def id_for(key, name, prefix, enum_method, list_method, not_found_error)
9+
def id_for(key, name, prefix, enum_method, list_method, not_found_error, enum_method_options: {}) # rubocop:disable Metrics/ParameterLists
1010
return { 'ok' => true, key.to_s => { 'id' => name } } unless name[0] == prefix
1111

12-
public_send enum_method do |list|
12+
public_send(enum_method, **enum_method_options) do |list|
1313
list.public_send(list_method).each do |li|
1414
return Slack::Messages::Message.new('ok' => true, key.to_s => { 'id' => li.id }) if li.name == name[1..-1]
1515
end

lib/slack/web/config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Config
1515
timeout
1616
open_timeout
1717
default_page_size
18+
conversations_id_page_size
1819
default_max_retries
1920
adapter
2021
].freeze
@@ -32,6 +33,7 @@ def reset
3233
self.timeout = nil
3334
self.open_timeout = nil
3435
self.default_page_size = 100
36+
self.conversations_id_page_size = default_page_size
3537
self.default_max_retries = 100
3638
self.adapter = ::Faraday.default_adapter
3739
end

0 commit comments

Comments
 (0)