From f48230cbeb3f2958bb121790840be27fc73c2583 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 14 Jan 2026 18:00:32 +0300 Subject: [PATCH] fix: bot sent caption without content from cache --- apps/bot/src/bot/features/download.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/bot/src/bot/features/download.ts b/apps/bot/src/bot/features/download.ts index d942737..85e14fd 100644 --- a/apps/bot/src/bot/features/download.ts +++ b/apps/bot/src/bot/features/download.ts @@ -37,22 +37,24 @@ feature.on('message:text', logHandle('download-message'), async (context) => { return context.reply(context.t('err-invalid-url')); } - // Проверка кеша - const cachedFileId = await redis.get(url); let contentMessageId: number | undefined; - if (cachedFileId) { - const cachedMessage = await context.replyWithVideo(cachedFileId); + // Проверка кеша + const cachedVideoId = await redis.get(url); + if (cachedVideoId) { + const cachedMessage = await context.replyWithVideo(cachedVideoId); contentMessageId = cachedMessage.message_id; } - const cachedCaption = await redis.get(`caption:${url}`); - if (cachedCaption) { - const { entities, text } = formatCaption(cachedCaption); - return context.reply(text, { - entities, - reply_parameters: contentMessageId ? { message_id: contentMessageId } : undefined, - }); + if (contentMessageId) { + const cachedCaption = await redis.get(`caption:${url}`); + if (cachedCaption) { + const { entities, text } = formatCaption(cachedCaption); + return context.reply(text, { + entities, + reply_parameters: contentMessageId ? { message_id: contentMessageId } : undefined, + }); + } } // Загрузка данных с сервисов