chore: Automation bug fix (#4442)

This commit is contained in:
Tejaswini Chile
2022-04-12 20:23:34 +05:30
committed by GitHub
parent b6ad468eb4
commit 923b4637db
12 changed files with 47 additions and 164 deletions

View File

@@ -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?

View File

@@ -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