From f963321d4470f9932538731b230d2386e9845a4f Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Fri, 9 Dec 2022 03:09:08 +0100 Subject: [PATCH] Aggio App --- src/server/router/users_router.js | 4 ++-- src/server/telegram/telegrambot.js | 3 ++- src/server/tools/globalTables.js | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index 81dfb2c..45b50e2 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -1249,9 +1249,9 @@ router.post('/mgt', authenticate, async (req, res) => { locale = req.body.locale; try { - const {nummsgsent, numrec, textsent} = await telegrambot.sendMsgFromSiteToBotTelegram(idapp, req.user, mydata); + const {nummsgsent, numrec, textsent, text} = await telegrambot.sendMsgFromSiteToBotTelegram(idapp, req.user, mydata); - return res.send({numrec, nummsgsent, textsent}); + return res.send({numrec, nummsgsent, textsent, text}); } catch (e) { res.status(400).send(); diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js index 65979b4..e419faa 100755 --- a/src/server/telegram/telegrambot.js +++ b/src/server/telegram/telegrambot.js @@ -1194,6 +1194,7 @@ const MyTelegramBot = { let ris = { numrec: 0, nummsgsent: 0, + text: '', }; let invia = false; @@ -1334,7 +1335,7 @@ async function local_sendMsgTelegram(idapp, username, text) { const teleg_id = await User.TelegIdByUsername(idapp, username); const cl = getclTelegByidapp(idapp); let ris = null; - if (cl && teleg_id) { + if (cl && teleg_id > 0) { ris = await cl.sendMsg(teleg_id, text); } diff --git a/src/server/tools/globalTables.js b/src/server/tools/globalTables.js index eabc67d..f437127 100755 --- a/src/server/tools/globalTables.js +++ b/src/server/tools/globalTables.js @@ -354,6 +354,7 @@ module.exports = { let numrec = 0; let nummsgsent = 0; + let text = ''; if (invia) { @@ -367,6 +368,7 @@ module.exports = { }, ).lean(); + for (const user of arrusers) { const mytitle = await tools.convertSpecialTags(user, params.title); @@ -390,8 +392,9 @@ module.exports = { if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) { const telegid = user.profile.teleg_id; + text = tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM); if (telegid > 0) { - risult = await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM)); + risult = await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, text); await tools.snooze(50); textsent = risult.text; @@ -418,6 +421,7 @@ module.exports = { numrec, nummsgsent, textsent, + text, }; } catch (e) { console.error('SendMsgToParam', e);