chore: Macros enhancement (#5609)
- Fixed send_attachment and send_email_transcript - Fixed duplicate activity messages - Fixed Order of execution Fixes: #5584
This commit is contained in:
@@ -39,6 +39,12 @@ class ActionService
|
||||
@conversation.update!(team_id: team_ids[0])
|
||||
end
|
||||
|
||||
def send_email_transcript(emails)
|
||||
emails.each do |email|
|
||||
ConversationReplyMailer.with(account: @conversation.account).conversation_transcript(@conversation, email)&.deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def agent_belongs_to_account?(agent_ids)
|
||||
|
||||
@@ -26,21 +26,15 @@ class AutomationRules::ActionService < ActionService
|
||||
|
||||
return unless @rule.files.attached?
|
||||
|
||||
blob = ActiveStorage::Blob.find(blob_ids)
|
||||
blobs = ActiveStorage::Blob.where(id: blob_ids)
|
||||
|
||||
return if blob.blank?
|
||||
return if blobs.blank?
|
||||
|
||||
params = { content: nil, private: false, attachments: blob }
|
||||
params = { content: nil, private: false, attachments: blobs }
|
||||
mb = Messages::MessageBuilder.new(nil, @conversation, params)
|
||||
mb.perform
|
||||
end
|
||||
|
||||
def send_email_transcript(emails)
|
||||
emails.each do |email|
|
||||
ConversationReplyMailer.with(account: @conversation.account).conversation_transcript(@conversation, email)&.deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
def send_webhook_event(webhook_url)
|
||||
payload = @conversation.webhook_data.merge(event: "automation_event.#{@rule.event_name}")
|
||||
WebhookJob.perform_later(webhook_url[0], payload)
|
||||
|
||||
@@ -21,18 +21,29 @@ class Macros::ExecutionService < ActionService
|
||||
|
||||
private
|
||||
|
||||
def send_webhook_event(webhook_url)
|
||||
payload = @conversation.webhook_data.merge(event: "macro_event.#{@macro.name}")
|
||||
WebhookJob.perform_later(webhook_url[0], payload)
|
||||
end
|
||||
|
||||
def send_message(message)
|
||||
return if conversation_a_tweet?
|
||||
|
||||
params = { content: message[0], private: false, content_attributes: { macro_id: @macro.id } }
|
||||
mb = Messages::MessageBuilder.new(nil, @conversation, params)
|
||||
params = { content: message[0], private: false }
|
||||
|
||||
# Added reload here to ensure conversation us persistent with the latest updates
|
||||
mb = Messages::MessageBuilder.new(nil, @conversation.reload, params)
|
||||
mb.perform
|
||||
end
|
||||
|
||||
def send_email_to_team(_params); end
|
||||
def send_attachment(blob_ids)
|
||||
return if conversation_a_tweet?
|
||||
|
||||
return unless @macro.files.attached?
|
||||
|
||||
blobs = ActiveStorage::Blob.where(id: blob_ids)
|
||||
|
||||
return if blobs.blank?
|
||||
|
||||
params = { content: nil, private: false, attachments: blobs }
|
||||
|
||||
# Added reload here to ensure conversation us persistent with the latest updates
|
||||
mb = Messages::MessageBuilder.new(nil, @conversation.reload, params)
|
||||
mb.perform
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user