Aggio App

This commit is contained in:
Surya Paolo
2022-12-09 03:09:08 +01:00
parent 6966bfe47b
commit f963321d44
3 changed files with 9 additions and 4 deletions

View File

@@ -1249,9 +1249,9 @@ router.post('/mgt', authenticate, async (req, res) => {
locale = req.body.locale; locale = req.body.locale;
try { 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) { } catch (e) {
res.status(400).send(); res.status(400).send();

View File

@@ -1194,6 +1194,7 @@ const MyTelegramBot = {
let ris = { let ris = {
numrec: 0, numrec: 0,
nummsgsent: 0, nummsgsent: 0,
text: '',
}; };
let invia = false; let invia = false;
@@ -1334,7 +1335,7 @@ async function local_sendMsgTelegram(idapp, username, text) {
const teleg_id = await User.TelegIdByUsername(idapp, username); const teleg_id = await User.TelegIdByUsername(idapp, username);
const cl = getclTelegByidapp(idapp); const cl = getclTelegByidapp(idapp);
let ris = null; let ris = null;
if (cl && teleg_id) { if (cl && teleg_id > 0) {
ris = await cl.sendMsg(teleg_id, text); ris = await cl.sendMsg(teleg_id, text);
} }

View File

@@ -354,6 +354,7 @@ module.exports = {
let numrec = 0; let numrec = 0;
let nummsgsent = 0; let nummsgsent = 0;
let text = '';
if (invia) { if (invia) {
@@ -367,6 +368,7 @@ module.exports = {
}, },
).lean(); ).lean();
for (const user of arrusers) { for (const user of arrusers) {
const mytitle = await tools.convertSpecialTags(user, params.title); const mytitle = await tools.convertSpecialTags(user, params.title);
@@ -390,8 +392,9 @@ module.exports = {
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) { if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) {
const telegid = user.profile.teleg_id; const telegid = user.profile.teleg_id;
text = tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM);
if (telegid > 0) { 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); await tools.snooze(50);
textsent = risult.text; textsent = risult.text;
@@ -418,6 +421,7 @@ module.exports = {
numrec, numrec,
nummsgsent, nummsgsent,
textsent, textsent,
text,
}; };
} catch (e) { } catch (e) {
console.error('SendMsgToParam', e); console.error('SendMsgToParam', e);