Fix: Campaign triggers first_response reporting event (#4607)
* Fix: Campaign triggers first_response reporting event * fix spec failure
This commit is contained in:
@@ -2,30 +2,32 @@
|
||||
#
|
||||
# Table name: messages
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# content :text
|
||||
# content_attributes :json
|
||||
# content_type :integer default("text"), not null
|
||||
# external_source_ids :jsonb
|
||||
# message_type :integer not null
|
||||
# private :boolean default(FALSE)
|
||||
# sender_type :string
|
||||
# status :integer default("sent")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :integer not null
|
||||
# conversation_id :integer not null
|
||||
# inbox_id :integer not null
|
||||
# sender_id :bigint
|
||||
# source_id :string
|
||||
# id :integer not null, primary key
|
||||
# additional_attributes :jsonb
|
||||
# content :text
|
||||
# content_attributes :json
|
||||
# content_type :integer default("text"), not null
|
||||
# external_source_ids :jsonb
|
||||
# message_type :integer not null
|
||||
# private :boolean default(FALSE)
|
||||
# sender_type :string
|
||||
# status :integer default("sent")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :integer not null
|
||||
# conversation_id :integer not null
|
||||
# inbox_id :integer not null
|
||||
# sender_id :bigint
|
||||
# source_id :string
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_messages_on_account_id (account_id)
|
||||
# index_messages_on_conversation_id (conversation_id)
|
||||
# index_messages_on_inbox_id (inbox_id)
|
||||
# index_messages_on_sender_type_and_sender_id (sender_type,sender_id)
|
||||
# index_messages_on_source_id (source_id)
|
||||
# index_messages_on_account_id (account_id)
|
||||
# index_messages_on_additional_attributes_campaign_id (((additional_attributes -> 'campaign_id'::text))) USING gin
|
||||
# index_messages_on_conversation_id (conversation_id)
|
||||
# index_messages_on_inbox_id (inbox_id)
|
||||
# index_messages_on_sender_type_and_sender_id (sender_type,sender_id)
|
||||
# index_messages_on_source_id (source_id)
|
||||
#
|
||||
|
||||
class Message < ApplicationRecord
|
||||
@@ -168,7 +170,7 @@ class Message < ApplicationRecord
|
||||
def dispatch_create_events
|
||||
Rails.configuration.dispatcher.dispatch(MESSAGE_CREATED, Time.zone.now, message: self, performed_by: Current.executed_by)
|
||||
|
||||
if outgoing? && conversation.messages.outgoing.count == 1
|
||||
if outgoing? && conversation.messages.outgoing.where("(additional_attributes->'campaign_id') is null").count == 1
|
||||
Rails.configuration.dispatcher.dispatch(FIRST_REPLY_CREATED, Time.zone.now, message: self, performed_by: Current.executed_by)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user