diff --git a/src/server.js b/src/server.js index a91f94f..72aeb7f 100644 --- a/src/server.js +++ b/src/server.js @@ -90,6 +90,7 @@ app.post('/bot/messenger-login', async (req, res) => { const userId = String(req.body?.userId || '').trim(); const email = String(req.body?.email || '').trim().toLowerCase(); const channelId = String(req.body?.channelId || '').trim(); + const skipDispatch = req.body?.skipDispatch === true; if (!channelId || (!userId && !email)) { res.status(400).json({ error: 'channelId and (userId or email) are required.' }); return; @@ -140,17 +141,19 @@ app.post('/bot/messenger-login', async (req, res) => { ).replace(/\/$/, ''); const loginUrl = `${frontendUrl}/login?login_token=${encodeURIComponent(login.loginToken)}`; - const dispatch = await sendMessengerMessage({ - type: channel, - channelId, - message: 'Вход подтвержден. Нажмите кнопку, чтобы открыть личный кабинет.', - buttonUrl: loginUrl, - buttonText: 'Открыть кабинет', - }); + if (!skipDispatch) { + const dispatch = await sendMessengerMessage({ + type: channel, + channelId, + message: 'Вход подтвержден. Нажмите кнопку, чтобы открыть личный кабинет.', + buttonUrl: loginUrl, + buttonText: 'Открыть кабинет', + }); - if (!dispatch.success) { - res.status(502).json({ error: dispatch.detail }); - return; + if (!dispatch.success) { + res.status(502).json({ error: dispatch.detail }); + return; + } } res.json({