chore: Add warning logs when Chatwoot receives events for inactive channels (#11066)
This commit is contained in:
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user