feat: New automation actions (#4033)

This commit is contained in:
Fayaz Ahmed
2022-03-29 13:27:16 +05:30
committed by GitHub
parent cffc984ef6
commit c674393c02
9 changed files with 192 additions and 35 deletions

View File

@@ -21,21 +21,27 @@ class AutomationRules::ActionService
private
def send_email_transcript(email)
ConversationReplyMailer.with(account: conversation.account).conversation_transcript(@conversation, email)&.deliver_later
def send_email_transcript(emails)
emails.each do |email|
ConversationReplyMailer.with(account: @conversation.account).conversation_transcript(@conversation, email)&.deliver_later
end
end
def mute_conversation(_params)
@conversation.mute!
end
def snooze_conversation(_params)
@conversation.ensure_snooze_until_reset
end
def change_status(status)
@conversation.update!(status: status[0])
end
def send_webhook_events(webhook_url)
def send_webhook_event(webhook_url)
payload = @conversation.webhook_data.merge(event: "automation_event: #{@rule.event_name}")
WebhookJob.perform_later(webhook_url, payload)
WebhookJob.perform_later(webhook_url[0], payload)
end
def send_message(message)

View File

@@ -28,7 +28,7 @@ class FilterService
@filter_values["value_#{current_index}"] = filter_values(query_hash)
equals_to_filter_string(query_hash[:filter_operator], current_index)
when 'contains', 'does_not_contain'
@filter_values["value_#{current_index}"] = "%#{filter_values(query_hash)}%"
@filter_values["value_#{current_index}"] = "%#{string_filter_values(query_hash)}%"
like_filter_string(query_hash[:filter_operator], current_index)
when 'is_present'
@filter_values["value_#{current_index}"] = 'IS NOT NULL'
@@ -57,6 +57,12 @@ class FilterService
end
end
def string_filter_values(query_hash)
return query_hash['values'][0] if query_hash['values'].is_a?(Array)
query_hash['values']
end
def lt_gt_filter_values(query_hash)
attribute_key = query_hash[:attribute_key]
attribute_type = custom_attribute(attribute_key).try(:attribute_display_type)