From 5541d9e00b7935f0ca8e3b7ebcaa8a61e7d25388 Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Mon, 19 Dec 2022 13:21:33 +0530 Subject: [PATCH] Fix: automation email improvement (#6061) --- .../dashboard/settings/automation/constants.js | 14 ++++++++++++++ app/models/automation_rule.rb | 3 ++- lib/automation_rules/conditions.json | 14 ++++++++++++++ spec/listeners/automation_rule_listener_spec.rb | 8 +++++++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js b/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js index 7916a4abc..62606ff13 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js +++ b/app/javascript/dashboard/routes/dashboard/settings/automation/constants.js @@ -99,6 +99,13 @@ export const AUTOMATIONS = { inputType: 'search_select', filterOperators: OPERATOR_TYPES_1, }, + { + key: 'mail_subject', + name: 'Email Subject', + attributeI18nKey: 'MAIL_SUBJECT', + inputType: 'plain_text', + filterOperators: OPERATOR_TYPES_2, + }, { key: 'country_code', name: 'Country', @@ -190,6 +197,13 @@ export const AUTOMATIONS = { inputType: 'search_select', filterOperators: OPERATOR_TYPES_1, }, + { + key: 'mail_subject', + name: 'Email Subject', + attributeI18nKey: 'MAIL_SUBJECT', + inputType: 'plain_text', + filterOperators: OPERATOR_TYPES_2, + }, { key: 'country_code', name: 'Country', diff --git a/app/models/automation_rule.rb b/app/models/automation_rule.rb index b72da9645..7e415231a 100644 --- a/app/models/automation_rule.rb +++ b/app/models/automation_rule.rb @@ -29,7 +29,8 @@ class AutomationRule < ApplicationRecord scope :active, -> { where(active: true) } - CONDITIONS_ATTRS = %w[content email country_code status message_type browser_language assignee_id team_id referer city company inbox_id].freeze + CONDITIONS_ATTRS = %w[content email country_code status message_type browser_language assignee_id team_id referer city company inbox_id + mail_subject].freeze ACTIONS_ATTRS = %w[send_message add_label send_email_to_team assign_team assign_agent send_webhook_event mute_conversation send_attachment change_status resolve_conversation snooze_conversation send_email_transcript].freeze diff --git a/lib/automation_rules/conditions.json b/lib/automation_rules/conditions.json index ad96b5289..566a35de2 100644 --- a/lib/automation_rules/conditions.json +++ b/lib/automation_rules/conditions.json @@ -63,6 +63,13 @@ "filter_operators": [ "equal_to", "not_equal_to", "contains", "does_not_contain" ], "attribute_type": "additional_attributes" }, + "mail_subject": { + "attribute_name": "Email Subject", + "input_type": "textbox", + "data_type": "text", + "filter_operators": [ "equal_to", "not_equal_to", "contains", "does_not_contain" ], + "attribute_type": "additional_attributes" + }, "country_code": { "attribute_name": "Country Name", "input_type": "textbox", @@ -142,6 +149,13 @@ "filter_operators": [ "equal_to", "not_equal_to", "contains", "does_not_contain" ], "attribute_type": "additional_attributes" }, + "mail_subject": { + "attribute_name": "Email Subject", + "input_type": "textbox", + "data_type": "text", + "filter_operators": [ "equal_to", "not_equal_to", "contains", "does_not_contain" ], + "attribute_type": "additional_attributes" + }, "country_code": { "attribute_name": "Country Name", "input_type": "textbox", diff --git a/spec/listeners/automation_rule_listener_spec.rb b/spec/listeners/automation_rule_listener_spec.rb index 51c352794..1da7225bd 100644 --- a/spec/listeners/automation_rule_listener_spec.rb +++ b/spec/listeners/automation_rule_listener_spec.rb @@ -258,7 +258,13 @@ describe AutomationRuleListener do end it 'triggers automation rule send email to the team' do - expect(TeamNotifications::AutomationNotificationMailer).to receive(:conversation_creation) + message_delivery = instance_double(ActionMailer::MessageDelivery) + + expect(TeamNotifications::AutomationNotificationMailer).to receive(:conversation_creation).with( + conversation, team, + 'Please pay attention to this conversation, its from high priority customer' + ).and_return(message_delivery) + allow(message_delivery).to receive(:deliver_now) listener.conversation_updated(event) end