[Feature] Email collect message hooks (#331)
- Add email collect hook on creating conversation - Merge contact if it already exist
This commit is contained in:
@@ -6,5 +6,8 @@ FactoryBot.define do
|
||||
sequence(:website_url) { |n| "https://example-#{n}.com" }
|
||||
sequence(:widget_color, &:to_s)
|
||||
account
|
||||
after(:create) do |channel_widget|
|
||||
create(:inbox, channel: channel_widget, account: channel_widget.account)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,6 +16,7 @@ FactoryBot.define do
|
||||
channel: create(:channel_widget, account: conversation.account)
|
||||
)
|
||||
conversation.contact ||= create(:contact, account: conversation.account)
|
||||
conversation.contact_inbox ||= create(:contact_inbox, contact: conversation.contact, inbox: conversation.inbox)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
FactoryBot.define do
|
||||
factory :inbox do
|
||||
account
|
||||
name { 'Inbox' }
|
||||
channel { FactoryBot.build(:channel_widget, account: account) }
|
||||
name { 'Inbox' }
|
||||
|
||||
after(:create) do |inbox|
|
||||
inbox.channel.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,13 @@ FactoryBot.define do
|
||||
content { 'Message' }
|
||||
status { 'sent' }
|
||||
message_type { 'incoming' }
|
||||
account
|
||||
inbox
|
||||
conversation
|
||||
user
|
||||
content_type { 'text' }
|
||||
account { create(:account) }
|
||||
|
||||
after(:build) do |message|
|
||||
message.user ||= create(:user, account: message.account)
|
||||
message.conversation ||= create(:conversation, account: message.account)
|
||||
message.inbox ||= create(:inbox, account: message.account)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user