fix: Duplicate instagram conversations for echo messages (#7078)
This commit is contained in:
@@ -21,6 +21,7 @@ describe Webhooks::InstagramEventsJob do
|
||||
let!(:instagram_channel) { create(:channel_instagram_fb_page, account: account, instagram_id: 'chatwoot-app-user-id-1') }
|
||||
let!(:instagram_inbox) { create(:inbox, channel: instagram_channel, account: account, greeting_enabled: false) }
|
||||
let!(:dm_params) { build(:instagram_message_create_event).with_indifferent_access }
|
||||
let!(:standby_params) { build(:instagram_message_standby_event).with_indifferent_access }
|
||||
let!(:test_params) { build(:instagram_test_text_event).with_indifferent_access }
|
||||
let!(:unsend_event) { build(:instagram_message_unsend_event).with_indifferent_access }
|
||||
let!(:attachment_params) { build(:instagram_message_attachment_event).with_indifferent_access }
|
||||
@@ -45,6 +46,24 @@ describe Webhooks::InstagramEventsJob do
|
||||
expect(instagram_inbox.messages.count).to be 1
|
||||
end
|
||||
|
||||
it 'creates standby message in the instagram inbox' do
|
||||
allow(Koala::Facebook::API).to receive(:new).and_return(fb_object)
|
||||
allow(fb_object).to receive(:get_object).and_return(
|
||||
return_object.with_indifferent_access
|
||||
)
|
||||
instagram_webhook.perform_now(standby_params[:entry])
|
||||
|
||||
instagram_inbox.reload
|
||||
|
||||
expect(instagram_inbox.contacts.count).to be 1
|
||||
expect(instagram_inbox.contacts.last.additional_attributes['social_profiles']['instagram']).to eq 'some_user_name'
|
||||
expect(instagram_inbox.conversations.count).to be 1
|
||||
expect(instagram_inbox.messages.count).to be 1
|
||||
|
||||
message = instagram_inbox.messages.last
|
||||
expect(message.content).to eq('This is the first standby message from the customer, after 24 hours.')
|
||||
end
|
||||
|
||||
it 'creates test text message in the instagram inbox' do
|
||||
allow(Koala::Facebook::API).to receive(:new).and_return(fb_object)
|
||||
allow(fb_object).to receive(:get_object).and_return(
|
||||
|
||||
Reference in New Issue
Block a user