Automation enhancement (#4087)
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
class AutomationRule < ApplicationRecord
|
||||
belongs_to :account
|
||||
|
||||
validates :account, presence: true
|
||||
validate :json_conditions_format
|
||||
validate :json_actions_format
|
||||
validates :account_id, presence: true
|
||||
|
||||
scope :active, -> { where(active: true) }
|
||||
|
||||
|
||||
@@ -210,6 +210,8 @@ class Conversation < ApplicationRecord
|
||||
end
|
||||
|
||||
def dispatcher_dispatch(event_name)
|
||||
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?)
|
||||
end
|
||||
|
||||
|
||||
@@ -166,6 +166,8 @@ 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)
|
||||
|
||||
if outgoing? && conversation.messages.outgoing.count == 1
|
||||
@@ -174,6 +176,8 @@ class Message < ApplicationRecord
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user