chore: Add warning logs when Chatwoot receives events for inactive channels (#11066)

This commit is contained in:
Sojan Jose
2025-03-12 08:16:47 -07:00
committed by GitHub
parent ba44f4fff8
commit d0631e99a5
2 changed files with 37 additions and 3 deletions

View File

@@ -17,8 +17,9 @@ RSpec.describe Webhooks::TelegramEventsJob do
expect(described_class.perform_now({})).to be_nil
end
it 'returns nil when invalid bot_token' do
expect(described_class.perform_now({ bot_token: 'invalid' })).to be_nil
it 'logs a warning when channel is not found' do
expect(Rails.logger).to receive(:warn).with('Telegram event discarded: Channel not found for bot_token: invalid')
described_class.perform_now({ bot_token: 'invalid' })
end
end
@@ -32,6 +33,19 @@ RSpec.describe Webhooks::TelegramEventsJob do
expect(process_service).to receive(:perform)
described_class.perform_now(params.with_indifferent_access)
end
it 'logs a warning and does not process events if account is suspended' do
account = telegram_channel.account
account.update!(status: :suspended)
process_service = double
allow(Telegram::IncomingMessageService).to receive(:new).and_return(process_service)
allow(process_service).to receive(:perform)
expect(Rails.logger).to receive(:warn).with("Telegram event discarded: Account #{account.id} is not active for channel #{telegram_channel.id}")
expect(Telegram::IncomingMessageService).not_to receive(:new)
described_class.perform_now(params.with_indifferent_access)
end
end
context 'when update message params' do