fix: Add Attachment endpoint to save file against automation rule (#4480)

Co-authored-by: fayazara <fayazara@gmail.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Tejaswini Chile
2022-04-24 12:02:40 +05:30
committed by GitHub
parent 2acb48bbe0
commit 1b3011b27b
18 changed files with 291 additions and 57 deletions

View File

@@ -21,9 +21,14 @@ class AutomationRules::ActionService
private
def send_attachments(_file_params)
blobs = @rule.files.map { |file, _| file.blob }
params = { content: nil, private: false, attachments: blobs }
def send_attachment(blob_ids)
return unless @rule.files.attached?
blob = ActiveStorage::Blob.find(blob_ids)
return if blob.blank?
params = { content: nil, private: false, attachments: blob }
mb = Messages::MessageBuilder.new(nil, @conversation, params)
mb.perform
end
@@ -51,7 +56,7 @@ class AutomationRules::ActionService
end
def send_webhook_event(webhook_url)
payload = @conversation.webhook_data.merge(event: "automation_event: #{@rule.event_name}")
payload = @conversation.webhook_data.merge(event: "automation_event.#{@rule.event_name}")
WebhookJob.perform_later(webhook_url[0], payload)
end