chore: fix slack attachment issue
This commit is contained in:
@@ -36,7 +36,7 @@ class Integrations::Slack::IncomingMessageBuilder
|
||||
def should_process_event?
|
||||
return true if params[:type] != 'event_callback'
|
||||
|
||||
params[:event][:user].present? && params[:event][:subtype].blank?
|
||||
params[:event][:user].present? && valid_event_subtype?
|
||||
end
|
||||
|
||||
def valid_event_subtype?
|
||||
@@ -97,7 +97,14 @@ class Integrations::Slack::IncomingMessageBuilder
|
||||
def create_message
|
||||
return unless conversation
|
||||
|
||||
@message = conversation.messages.create!(
|
||||
build_message
|
||||
process_attachments(params[:event][:files]) if params[:event][:files].present?
|
||||
@message.save!
|
||||
{ status: 'success' }
|
||||
end
|
||||
|
||||
def build_message
|
||||
@message = conversation.messages.build(
|
||||
message_type: :outgoing,
|
||||
account_id: conversation.account_id,
|
||||
inbox_id: conversation.inbox_id,
|
||||
@@ -106,10 +113,6 @@ class Integrations::Slack::IncomingMessageBuilder
|
||||
private: private_note?,
|
||||
sender: sender
|
||||
)
|
||||
|
||||
process_attachments(params[:event][:files]) if params[:event][:files].present?
|
||||
|
||||
{ status: 'success' }
|
||||
end
|
||||
|
||||
def slack_client
|
||||
@@ -135,7 +138,6 @@ class Integrations::Slack::IncomingMessageBuilder
|
||||
|
||||
attachment_obj = @message.attachments.new(attachment_params)
|
||||
attachment_obj.file.content_type = attachment[:mimetype]
|
||||
attachment_obj.save!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ slack:
|
||||
id: slack
|
||||
logo: slack.png
|
||||
i18n_key: slack
|
||||
action: https://slack.com/oauth/v2/authorize?scope=commands,chat:write,channels:read,channels:manage,channels:join,groups:read,groups:write,im:write,mpim:write,users:read,users:read.email,chat:write.customize,channels:history,groups:history,mpim:history,im:history
|
||||
action: https://slack.com/oauth/v2/authorize?scope=commands,chat:write,channels:read,channels:manage,channels:join,groups:read,groups:write,im:write,mpim:write,users:read,users:read.email,chat:write.customize,channels:history,groups:history,mpim:history,im:history,files:read
|
||||
hook_type: account
|
||||
allow_multiple_hooks: false
|
||||
webhooks:
|
||||
|
||||
Reference in New Issue
Block a user