fixed slack channel builder so that the channel list can have more th… (#1725)

fixed slack channel builder so that the channel list can have more than 100 elements

Co-authored-by: xinruiyang <xinruiyang@deepmap.ai>
This commit is contained in:
Muyi 2021-02-10 22:52:06 +08:00 committed by GitHub
parent 1484849cc7
commit da94e65d20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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