chore: Automation bug fix (#4442)
This commit is contained in:
@@ -194,7 +194,7 @@ export default {
|
||||
required: requiredIf(prop => {
|
||||
return !(
|
||||
prop.action_name === 'mute_conversation' ||
|
||||
prop.action_name === 'snooze_convresation' ||
|
||||
prop.action_name === 'snooze_conversation' ||
|
||||
prop.action_name === 'resolve_convresation'
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -198,7 +198,7 @@ export default {
|
||||
required: requiredIf(prop => {
|
||||
return !(
|
||||
prop.action_name === 'mute_conversation' ||
|
||||
prop.action_name === 'snooze_convresation' ||
|
||||
prop.action_name === 'snooze_conversation' ||
|
||||
prop.action_name === 'resolve_convresation'
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -92,7 +92,7 @@ export const AUTOMATIONS = {
|
||||
attributeI18nKey: 'MUTE_CONVERSATION',
|
||||
},
|
||||
{
|
||||
key: 'snooze_convresation',
|
||||
key: 'snooze_conversation',
|
||||
name: 'Snooze conversation',
|
||||
attributeI18nKey: 'MUTE_CONVERSATION',
|
||||
},
|
||||
@@ -166,7 +166,7 @@ export const AUTOMATIONS = {
|
||||
attributeI18nKey: 'MUTE_CONVERSATION',
|
||||
},
|
||||
{
|
||||
key: 'snooze_convresation',
|
||||
key: 'snooze_conversation',
|
||||
name: 'Snooze conversation',
|
||||
attributeI18nKey: 'MUTE_CONVERSATION',
|
||||
},
|
||||
@@ -254,7 +254,7 @@ export const AUTOMATIONS = {
|
||||
attributeI18nKey: 'MUTE_CONVERSATION',
|
||||
},
|
||||
{
|
||||
key: 'snooze_convresation',
|
||||
key: 'snooze_conversation',
|
||||
name: 'Snooze conversation',
|
||||
attributeI18nKey: 'MUTE_CONVERSATION',
|
||||
},
|
||||
@@ -314,7 +314,7 @@ export const AUTOMATION_ACTION_TYPES = [
|
||||
inputType: null,
|
||||
},
|
||||
{
|
||||
key: 'snooze_convresation',
|
||||
key: 'snooze_conversation',
|
||||
label: 'Snooze conversation',
|
||||
inputType: null,
|
||||
},
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
class AutomationRuleListener < BaseListener
|
||||
def conversation_updated(event_obj)
|
||||
return if performed_by_automation?(event_obj)
|
||||
|
||||
conversation = event_obj.data[:conversation]
|
||||
account = conversation.account
|
||||
|
||||
@@ -11,19 +13,9 @@ class AutomationRuleListener < BaseListener
|
||||
end
|
||||
end
|
||||
|
||||
def conversation_status_changed(event_obj)
|
||||
conversation = event_obj.data[:conversation]
|
||||
account = conversation.account
|
||||
|
||||
return unless rule_present?('conversation_status_changed', account)
|
||||
|
||||
@rules.each do |rule|
|
||||
conditions_match = ::AutomationRules::ConditionsFilterService.new(rule, conversation).perform
|
||||
AutomationRules::ActionService.new(rule, account, conversation).perform if conditions_match.present?
|
||||
end
|
||||
end
|
||||
|
||||
def conversation_created(event_obj)
|
||||
return if performed_by_automation?(event_obj)
|
||||
|
||||
conversation = event_obj.data[:conversation]
|
||||
account = conversation.account
|
||||
|
||||
@@ -36,6 +28,8 @@ class AutomationRuleListener < BaseListener
|
||||
end
|
||||
|
||||
def message_created(event_obj)
|
||||
return if performed_by_automation?(event_obj)
|
||||
|
||||
message = event_obj.data[:message]
|
||||
account = message.try(:account)
|
||||
|
||||
@@ -57,4 +51,8 @@ class AutomationRuleListener < BaseListener
|
||||
)
|
||||
@rules.any?
|
||||
end
|
||||
|
||||
def performed_by_automation?(event_obj)
|
||||
event_obj.data[:performed_by].present? && event_obj.data[:performed_by].instance_of?(AutomationRule)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,18 +35,14 @@ class TeamNotifications::AutomationNotificationMailer < ApplicationMailer
|
||||
private
|
||||
|
||||
def send_an_email_to_team
|
||||
@agents.each do |agent|
|
||||
subject = "#{agent.user.available_name}, This email has been sent via automation rule actions."
|
||||
@action_url = app_account_conversation_url(account_id: @conversation.account_id, id: @conversation.display_id)
|
||||
@agent = agent
|
||||
|
||||
send_mail_with_liquid(to: @agent.user.email, subject: subject)
|
||||
end
|
||||
subject = 'This email has been sent via automation rule actions.'
|
||||
@action_url = app_account_conversation_url(account_id: @conversation.account_id, id: @conversation.display_id)
|
||||
@agent_emails = @agents.collect(&:user).pluck(:email)
|
||||
send_mail_with_liquid(to: @agent_emails, subject: subject) and return
|
||||
end
|
||||
|
||||
def liquid_droppables
|
||||
super.merge!({
|
||||
user: @agent.user,
|
||||
conversation: @conversation,
|
||||
inbox: @conversation.inbox
|
||||
})
|
||||
|
||||
@@ -214,10 +214,9 @@ class Conversation < ApplicationRecord
|
||||
end
|
||||
|
||||
def dispatcher_dispatch(event_name, changed_attributes = nil)
|
||||
return if Current.executed_by.present? && Current.executed_by.instance_of?(AutomationRule)
|
||||
|
||||
Rails.configuration.dispatcher.dispatch(event_name, Time.zone.now, conversation: self, notifiable_assignee_change: notifiable_assignee_change?,
|
||||
changed_attributes: changed_attributes)
|
||||
changed_attributes: changed_attributes,
|
||||
performed_by: Current.executed_by)
|
||||
end
|
||||
|
||||
def conversation_status_changed_to_open?
|
||||
|
||||
@@ -166,19 +166,15 @@ class Message < ApplicationRecord
|
||||
end
|
||||
|
||||
def dispatch_create_events
|
||||
return if Current.executed_by.present? && Current.executed_by.instance_of?(AutomationRule)
|
||||
|
||||
Rails.configuration.dispatcher.dispatch(MESSAGE_CREATED, Time.zone.now, message: self)
|
||||
Rails.configuration.dispatcher.dispatch(MESSAGE_CREATED, Time.zone.now, message: self, performed_by: Current.executed_by)
|
||||
|
||||
if outgoing? && conversation.messages.outgoing.count == 1
|
||||
Rails.configuration.dispatcher.dispatch(FIRST_REPLY_CREATED, Time.zone.now, message: self)
|
||||
Rails.configuration.dispatcher.dispatch(FIRST_REPLY_CREATED, Time.zone.now, message: self, performed_by: Current.executed_by)
|
||||
end
|
||||
end
|
||||
|
||||
def dispatch_update_event
|
||||
return if Current.executed_by.present? && Current.executed_by.instance_of?(AutomationRule)
|
||||
|
||||
Rails.configuration.dispatcher.dispatch(MESSAGE_UPDATED, Time.zone.now, message: self)
|
||||
Rails.configuration.dispatcher.dispatch(MESSAGE_UPDATED, Time.zone.now, message: self, performed_by: Current.executed_by)
|
||||
end
|
||||
|
||||
def send_reply
|
||||
|
||||
@@ -41,7 +41,7 @@ class AutomationRules::ActionService
|
||||
end
|
||||
|
||||
def snooze_conversation(_params)
|
||||
@conversation.ensure_snooze_until_reset
|
||||
@conversation.snoozed!
|
||||
end
|
||||
|
||||
def change_status(status)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<p>Hi {{user.available_name}}</p>
|
||||
|
||||
<p>This is the mail from Automation System</p>
|
||||
|
||||
<p>{{ custom_message }}</p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user