Compare commits

...

9 Commits

Author SHA1 Message Date
Muhsin Keloth
3496c9c16a Merge branch 'fix/slack-attachment-issues' of https://github.com/chatwoot/chatwoot into fix/slack-attachment-issues 2023-08-25 19:01:45 +05:30
Muhsin Keloth
1b17926b90 Revert facebook code 2023-08-25 19:01:40 +05:30
Muhsin Keloth
b21e9849ba chore: fix slack attachment issue 2023-08-25 19:01:40 +05:30
Muhsin Keloth
64db949581 Fix slack attachment issues 2023-08-25 19:01:40 +05:30
Muhsin Keloth
8c1c1a5ab2 chore: move lib to services 2023-08-25 19:01:40 +05:30
Muhsin Keloth
2971d78f8c Revert facebook code 2023-08-25 11:39:46 +05:30
Muhsin Keloth
7f8d8a112d chore: fix slack attachment issue 2023-08-25 10:59:41 +05:30
Muhsin Keloth
68205d8fd3 Fix slack attachment issues 2023-08-16 15:47:41 +05:30
Muhsin Keloth
d42206e03b chore: move lib to services 2023-08-16 15:47:35 +05:30
20 changed files with 14 additions and 8 deletions

View File

@@ -36,7 +36,11 @@ 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?
params[:event][:subtype].blank? || params[:event][:subtype] == 'file_share'
end
def supported_event?
@@ -93,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,
@@ -102,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
@@ -131,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

View File

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