diff --git a/src/auth/telegram-bot-login.ts b/src/auth/telegram-bot-login.ts index 66bf6f4..b6c086e 100644 --- a/src/auth/telegram-bot-login.ts +++ b/src/auth/telegram-bot-login.ts @@ -112,25 +112,22 @@ export async function fetchTelegramPhoto(fileId: string) { }; } -function formatRemaining(expiresAt: Date) { - const seconds = Math.max(0, Math.ceil((expiresAt.getTime() - Date.now()) / 1000)); - const minutes = Math.floor(seconds / 60).toString(); - const rest = (seconds % 60).toString().padStart(2, '0'); - return `${minutes}:${rest}`; +function formatLoginLifetime() { + const minutes = Math.ceil(config.botLoginMaxAgeSeconds / 60); + return `${minutes} мин`; } async function sendLoginMessage( chatId: number, text: string, token?: string, - expiresAt?: Date, ) { const replyMarkup = token ? { inline_keyboard: [ [ { - text: `Открыть MapFlow · ${formatRemaining(expiresAt ?? expiresIn(0))}`, + text: `Открыть MapFlow · ${formatLoginLifetime()}`, url: `${config.webAppUrl}?telegram_login=${encodeURIComponent(token)}`, }, ], @@ -245,5 +242,5 @@ export async function handleTelegramBotWebhook( }, }); - await sendLoginMessage(chatId, 'MapFlow', token, request.expiresAt); + await sendLoginMessage(chatId, 'MapFlow', token); }