From da94e65d2034645b4635f1049f3bb38ec3717890 Mon Sep 17 00:00:00 2001 From: Muyi Date: Wed, 10 Feb 2021 22:52:06 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20slack=20channel=20builder=20so=20that?= =?UTF-8?q?=20the=20channel=20list=20can=20have=20more=20th=E2=80=A6=20(#1?= =?UTF-8?q?725)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed slack channel builder so that the channel list can have more than 100 elements Co-authored-by: xinruiyang --- lib/integrations/slack/channel_builder.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/integrations/slack/channel_builder.rb b/lib/integrations/slack/channel_builder.rb index 2092f3594..f59df449e 100644 --- a/lib/integrations/slack/channel_builder.rb +++ b/lib/integrations/slack/channel_builder.rb @@ -21,7 +21,13 @@ class Integrations::Slack::ChannelBuilder end def find_or_create_channel - existing_channel = slack_client.conversations_list.channels.find { |channel| channel['name'] == params[:channel] } + current_list = slack_client.conversations_list + channels = current_list.channels + while current_list.response_metadata.next_cursor.present? + current_list = slack_client.conversations_list(cursor: current_list.response_metadata.next_cursor) + channels.concat(current_list.channels) + end + existing_channel = channels.find { |channel| channel['name'] == params[:channel] } @channel = existing_channel || slack_client.conversations_create(name: params[:channel])['channel'] end