Use static Telegram login lifetime label
All checks were successful
Build and deploy Backend / build (push) Successful in 29s

This commit is contained in:
Ruslan Bakiev
2026-05-13 20:10:00 +07:00
parent 7deedcb276
commit 4aea10b195

View File

@@ -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);
}