feat: Enable Slack Integration in all channels (#1175)

This commit is contained in:
Sojan Jose
2020-08-29 01:39:41 +05:30
committed by GitHub
parent 45cd949c40
commit 85ae6d92b9
6 changed files with 48 additions and 21 deletions

View File

@@ -80,7 +80,7 @@ class Integrations::Slack::IncomingMessageBuilder
account_id: conversation.account_id,
inbox_id: conversation.inbox_id,
content: params[:event][:text],
source_id: "slack_#{params[:event][:ts]}",
external_source_id_slack: params[:event][:ts],
private: private_note?,
sender: sender
)

View File

@@ -4,9 +4,9 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
def perform
# overriding the base class logic since the validations are different in this case.
# FIXME: for now we will only send messages from widget to slack
return unless channel.is_a?(Channel::WebWidget)
return unless valid_channel_for_slack?
# we don't want message loop in slack
return if message.source_id.try(:starts_with?, 'slack_')
return if message.external_source_id_slack.present?
# we don't want to start slack thread from agent conversation as of now
return if message.outgoing? && conversation.identifier.blank?
@@ -15,6 +15,13 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService
private
def valid_channel_for_slack?
# slack wouldn't be an idean interface to reply to tweets, hence disabling that case
return false if channel.is_a?(Channel::TwitterProfile) && conversation.additional_attributes['type'] == 'tweet'
true
end
def perform_reply
send_message
update_reference_id