Feature: Slack - receive messages, create threads, send replies (#974)

Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
Sojan Jose
2020-06-22 13:19:26 +05:30
committed by GitHub
parent aa8a85b8bd
commit 1ef8d03e18
53 changed files with 815 additions and 188 deletions

View File

@@ -6,7 +6,7 @@ class Integrations::Slack::ChannelBuilder
end
def perform
create_channel
find_or_create_channel
update_reference_id
end
@@ -23,11 +23,12 @@ class Integrations::Slack::ChannelBuilder
Slack::Web::Client.new
end
def create_channel
@channel = slack_client.conversations_create(name: params[:channel])
def find_or_create_channel
exisiting_channel = slack_client.conversations_list.channels.find { |channel| channel['name'] == params[:channel] }
@channel = exisiting_channel || slack_client.conversations_create(name: params[:channel])['channel']
end
def update_reference_id
@hook.reference_id = channel['channel']['id']
@hook.update(reference_id: channel['id'])
end
end