ver 0.5.51

This commit is contained in:
Surya Paolo
2023-01-03 16:51:32 +01:00
parent 7a41e6a1d4
commit 18b827f5f4
10 changed files with 1004 additions and 616 deletions

View File

@@ -16,7 +16,7 @@ const CryptoJS = require('crypto-js');
const Url = require('url-parse');
const { ObjectID } = require('mongodb');
const { ObjectID, ObjectId } = require('mongodb');
const shared_consts = require('./shared_nodejs');
@@ -836,8 +836,10 @@ module.exports = {
}).catch(async (err) => {
console.error('err Push', err.body);
// Cancella dal DB la notifica Push, visto che da errore! (sarà scaduto)
const ris = await Subscription.deleteOne({ _id: subscription._id });
if (err.body) {
// Cancella dal DB la notifica Push, visto che da errore! (sarà scaduto)
const ris = await Subscription.deleteOne({ _id: subscription._id });
}
reject({
status: false,
@@ -1020,6 +1022,7 @@ module.exports = {
const { SendNotif } = require('../models/sendnotif');
const { User } = require('../models/user');
const telegrambot = require('../telegram/telegrambot');
const { MyGroup } = require('../models/mygroup');
const req = this.getReqByPar(idapp, usernameOrig);
@@ -1065,7 +1068,7 @@ module.exports = {
// paramsObj.options = MessageOptions.Notify_OnlyToNotifinApp + MessageOptions.Notify_ByBotTelegram;
const myuserdata = await User.getUserShortDataByUsername(idapp, username_action);
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_CIRCUIT, myuserdata, usernameDest, circuitname,
myreccircuit._id);
myreccircuit._id, '', extrarec.groupname);
onlysave = false;
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN;
@@ -1074,6 +1077,8 @@ module.exports = {
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT) {
// Crea l'ID di Transazione
paramsObj.idTransaction = new ObjectId();
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
@@ -1088,8 +1093,25 @@ module.exports = {
}
if (sendnotif && typeid > 0) {
// CREATE NOTIFICATION IN TABLE SENDNOTIF
return await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
// Check if is group:
if (extrarec.groupdest) {
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, extrarec.groupdest);
let ris = null;
for (let i = 0; i < arrusers.length; i++) {
paramsObj.usernameDest = arrusers[i].username;
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
if (!ris) {
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", extrarec.groupdest)
}
}
} else {
// CREATE NOTIFICATION IN TABLE SENDNOTIF
return await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
}
}
}
} catch (e) {
@@ -1297,7 +1319,7 @@ module.exports = {
this.mylog('checkUserOk', userpassed, userauth);
if (String(userpassed) !== String(userauth)) {
// I'm trying to write something not mine!
this.mylog('userId = ', userpassed, 'req.user._id', userauth);
this.mylog('I\'m trying to write something not mine!: userId = ', userpassed, 'req.user._id', userauth);
if (!res) {
return {
exit: true,
@@ -1580,7 +1602,7 @@ module.exports = {
{
$and:
[
{ $eq: ['$'+params.lk_FF, '$$'+params.lk_FF] },
{ $eq: ['$' + params.lk_FF, '$$' + params.lk_FF] },
{ $eq: ['$idapp', '$$idapp'] },
],
},
@@ -1907,7 +1929,7 @@ module.exports = {
if (params.filterextra) {
if (params.filterextra.length > 0)
query = [...query, ...params.filterextra]
query = [...query, ...params.filterextra]
}
if (filtriadded) {