chore: Logger for non-existent WhatsApp channels (#11064)

- Add a warning logger for cases where we are getting webhook events for
inactive numbers.
- Add config to discard events for inactive numbers so that the meta
will stop sending events

---------

Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
Sojan Jose
2025-03-12 15:50:38 -07:00
committed by GitHub
parent d0631e99a5
commit 29158e32fe
6 changed files with 73 additions and 2 deletions

View File

@@ -81,6 +81,22 @@ RSpec.describe Webhooks::WhatsappEventsJob do
expect(Whatsapp::IncomingMessageService).not_to receive(:new)
job.perform_now(params)
end
it 'logs a warning when channel is inactive' do
channel.prompt_reauthorization!
allow(Rails.logger).to receive(:warn)
expect(Rails.logger).to receive(:warn).with("Inactive WhatsApp channel: #{channel.phone_number}")
job.perform_now(params)
end
it 'logs a warning with unknown phone number when channel does not exist' do
unknown_phone = '+1234567890'
allow(Rails.logger).to receive(:warn)
expect(Rails.logger).to receive(:warn).with("Inactive WhatsApp channel: unknown - #{unknown_phone}")
job.perform_now(phone_number: unknown_phone)
end
end
context 'when default provider' do