fix: webhook:close button not working due to channel check timeout

Channel checker middleware called bot.get_chat_member() which could
timeout (60s), causing callback.answer() to fail with "query too old".

Skip channel check for lightweight UI callbacks (webhook:close,
ban_notify:delete, noop). Also answer callback before delete attempt
and add fallback to remove keyboard if delete fails.
This commit is contained in:
Fringg
2026-02-10 07:54:24 +03:00
parent 5156d635f0
commit 019fbc12b6
2 changed files with 18 additions and 2 deletions

View File

@@ -30,10 +30,17 @@ async def handle_webhook_notification_close(
):
"""Удаляет webhook-уведомление при нажатии кнопки Закрыть."""
try:
await callback.message.delete()
await callback.answer()
except Exception:
pass
await callback.answer()
try:
await callback.message.delete()
except Exception as e:
logger.warning('Не удалось удалить webhook-уведомление: %s', e)
try:
await callback.message.edit_reply_markup(reply_markup=None)
except Exception:
pass
async def handle_unknown_callback(callback: types.CallbackQuery, db_user: User):

View File

@@ -109,6 +109,15 @@ class ChannelCheckerMiddleware(BaseMiddleware):
logger.debug('❌ telegram_id не найден, пропускаем')
return await handler(event, data)
# Skip channel check for lightweight UI callbacks (close/delete notifications)
if isinstance(event, CallbackQuery) and event.data in (
'webhook:close',
'ban_notify:delete',
'noop',
'current_page',
):
return await handler(event, data)
# Админам разрешаем пропускать проверку подписки
if settings.is_admin(telegram_id):
logger.debug(