Use static Telegram login lifetime label
All checks were successful
Build and deploy Backend / build (push) Successful in 29s
All checks were successful
Build and deploy Backend / build (push) Successful in 29s
This commit is contained in:
@@ -112,25 +112,22 @@ export async function fetchTelegramPhoto(fileId: string) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatRemaining(expiresAt: Date) {
|
function formatLoginLifetime() {
|
||||||
const seconds = Math.max(0, Math.ceil((expiresAt.getTime() - Date.now()) / 1000));
|
const minutes = Math.ceil(config.botLoginMaxAgeSeconds / 60);
|
||||||
const minutes = Math.floor(seconds / 60).toString();
|
return `${minutes} мин`;
|
||||||
const rest = (seconds % 60).toString().padStart(2, '0');
|
|
||||||
return `${minutes}:${rest}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendLoginMessage(
|
async function sendLoginMessage(
|
||||||
chatId: number,
|
chatId: number,
|
||||||
text: string,
|
text: string,
|
||||||
token?: string,
|
token?: string,
|
||||||
expiresAt?: Date,
|
|
||||||
) {
|
) {
|
||||||
const replyMarkup = token
|
const replyMarkup = token
|
||||||
? {
|
? {
|
||||||
inline_keyboard: [
|
inline_keyboard: [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
text: `Открыть MapFlow · ${formatRemaining(expiresAt ?? expiresIn(0))}`,
|
text: `Открыть MapFlow · ${formatLoginLifetime()}`,
|
||||||
url: `${config.webAppUrl}?telegram_login=${encodeURIComponent(token)}`,
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user