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

@@ -5,13 +5,33 @@ class Webhooks::TelegramEventsJob < ApplicationJob
return unless params[:bot_token]
channel = Channel::Telegram.find_by(bot_token: params[:bot_token])
return unless channel
if channel_is_inactive?(channel)
log_inactive_channel(channel, params)
return
end
process_event_params(channel, params)
end
private
def channel_is_inactive?(channel)
return true if channel.blank?
return true unless channel.account.active?
false
end
def log_inactive_channel(channel, params)
message = if channel&.id
"Account #{channel.account.id} is not active for channel #{channel.id}"
else
"Channel not found for bot_token: #{params[:bot_token]}"
end
Rails.logger.warn("Telegram event discarded: #{message}")
end
def process_event_params(channel, params)
return unless params[:telegram]