From 2abc57300c330298ab1b17438eae5a002a4de12a Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Mon, 6 Mar 2023 17:47:35 +0530 Subject: [PATCH] fix: Add a check for automation_created message in FIRST_REPLY_CREATED event (#6618) --- app/models/message.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/message.rb b/app/models/message.rb index 01b385f27..7596dedaf 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -196,9 +196,13 @@ class Message < ApplicationRecord .where("(additional_attributes->'campaign_id') is null").count == 1 end + def not_created_by_automation? + content_attributes['automation_rule_id'].blank? + end + def dispatch_create_events Rails.configuration.dispatcher.dispatch(MESSAGE_CREATED, Time.zone.now, message: self, performed_by: Current.executed_by) - if outgoing? && first_human_response? + if outgoing? && first_human_response? && not_created_by_automation? Rails.configuration.dispatcher.dispatch(FIRST_REPLY_CREATED, Time.zone.now, message: self, performed_by: Current.executed_by) end end