chore: Handle attachments in Whatsapp Channel (#3299)

send and receive attachments in 360Dialog WhatsApp channels
This commit is contained in:
Sojan Jose
2021-11-11 11:33:48 +04:00
committed by GitHub
parent b3e313a200
commit a4c87f2052
33 changed files with 422 additions and 45 deletions

View File

@@ -19,6 +19,7 @@ RSpec.describe SendReplyJob, type: :job do
end
it 'calls Facebook::SendOnFacebookService when its facebook message' do
stub_request(:post, /graph.facebook.com/)
facebook_channel = create(:channel_facebook_page)
facebook_inbox = create(:inbox, channel: facebook_channel)
message = create(:message, conversation: create(:conversation, inbox: facebook_inbox))
@@ -66,6 +67,7 @@ RSpec.describe SendReplyJob, type: :job do
end
it 'calls ::Whatsapp:SendOnWhatsappService when its line message' do
stub_request(:post, 'https://waba.360dialog.io/v1/configs/webhook')
whatsapp_channel = create(:channel_whatsapp)
message = create(:message, conversation: create(:conversation, inbox: whatsapp_channel.inbox))
allow(::Whatsapp::SendOnWhatsappService).to receive(:new).with(message: message).and_return(process_service)

View File

@@ -4,6 +4,10 @@ require 'webhooks/twitter'
describe Webhooks::InstagramEventsJob do
subject(:instagram_webhook) { described_class }
before do
stub_request(:post, /graph.facebook.com/)
end
let!(:account) { create(:account) }
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) }
@@ -20,7 +24,7 @@ describe Webhooks::InstagramEventsJob do
name: 'Jane',
id: 'Sender-id-1',
account_id: instagram_inbox.account_id,
profile_pic: 'https://via.placeholder.com/250x250.png'
profile_pic: 'https://chatwoot-assets.local/sample.png'
}.with_indifferent_access
)
instagram_webhook.perform_now(dm_params[:entry])
@@ -39,7 +43,7 @@ describe Webhooks::InstagramEventsJob do
name: 'Jane',
id: 'Sender-id-1',
account_id: instagram_inbox.account_id,
profile_pic: 'https://via.placeholder.com/250x250.png'
profile_pic: 'https://chatwoot-assets.local/sample.png'
}.with_indifferent_access
)
instagram_webhook.perform_now(test_params[:entry])