Move bot login timer into message text
All checks were successful
Build and deploy Backend / build (push) Successful in 41s
All checks were successful
Build and deploy Backend / build (push) Successful in 41s
This commit is contained in:
@@ -129,7 +129,7 @@ function loginReplyMarkup(token: string, expiresAt: Date) {
|
||||
inline_keyboard: [
|
||||
[
|
||||
{
|
||||
text: `Открыть MapFlow · ${formatRemaining(expiresAt)}`,
|
||||
text: 'Открыть MapFlow',
|
||||
url: `${config.webAppUrl}?telegram_login=${encodeURIComponent(token)}`,
|
||||
},
|
||||
],
|
||||
@@ -137,6 +137,15 @@ function loginReplyMarkup(token: string, expiresAt: Date) {
|
||||
};
|
||||
}
|
||||
|
||||
function loginMessageText(expiresAt: Date) {
|
||||
return [
|
||||
'Вход в MapFlow',
|
||||
'',
|
||||
'Перейдите по ссылке ниже.',
|
||||
`Ссылка активна: ${formatRemaining(expiresAt)}`,
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
async function sendLoginMessage(
|
||||
chatId: number,
|
||||
text: string,
|
||||
@@ -206,7 +215,7 @@ function scheduleLoginMessageTimer(
|
||||
return;
|
||||
}
|
||||
|
||||
await editLoginMessage(chatId, messageId, 'MapFlow', token, expiresAt);
|
||||
await editLoginMessage(chatId, messageId, loginMessageText(expiresAt), token, expiresAt);
|
||||
const handle = setTimeout(() => {
|
||||
void tick();
|
||||
}, 1000);
|
||||
@@ -267,7 +276,7 @@ export async function completeTelegramBotLogin(token: string) {
|
||||
await editLoginMessage(
|
||||
request.telegramChatId,
|
||||
request.telegramMessageId,
|
||||
'Вход выполнен.',
|
||||
'Вход выполнен.\nМожно вернуться в MapFlow.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -295,7 +304,7 @@ export async function handleTelegramBotWebhook(
|
||||
|
||||
const [command, payload] = text.split(' ');
|
||||
if (command !== '/start' || !payload?.startsWith(loginPrefix)) {
|
||||
await sendLoginMessage(chatId, 'Открой вход с сайта MapFlow.');
|
||||
await sendLoginMessage(chatId, 'Начните вход с сайта MapFlow.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -305,7 +314,7 @@ export async function handleTelegramBotWebhook(
|
||||
});
|
||||
|
||||
if (!request || request.status !== 'PENDING' || request.expiresAt <= new Date()) {
|
||||
await sendLoginMessage(chatId, 'Ссылка входа устарела.');
|
||||
await sendLoginMessage(chatId, 'Ссылка входа устарела.\nВернитесь на сайт и начните вход заново.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -322,7 +331,12 @@ export async function handleTelegramBotWebhook(
|
||||
},
|
||||
});
|
||||
|
||||
const sentMessage = await sendLoginMessage(chatId, 'MapFlow', token, request.expiresAt);
|
||||
const sentMessage = await sendLoginMessage(
|
||||
chatId,
|
||||
loginMessageText(request.expiresAt),
|
||||
token,
|
||||
request.expiresAt,
|
||||
);
|
||||
|
||||
await prisma.telegramLoginRequest.update({
|
||||
where: { id: request.id },
|
||||
|
||||
Reference in New Issue
Block a user