- fix RIS in pendenti, se troppi msg, non compariva piu

- cataloghi, ricerca pickup
This commit is contained in:
Surya Paolo
2024-05-09 23:36:46 +02:00
parent 54443e784e
commit 3b1b2b9c83
13 changed files with 296 additions and 94 deletions

View File

@@ -1,11 +1,11 @@
DATABASE=test_PiuCheBuono DATABASE=test_FreePlanet
UDB=paofreeplanet UDB=paofreeplanet
PDB=mypassword@1A PDB=mypassword@1A
SEND_EMAIL=0 SEND_EMAIL=0
SEND_EMAIL_ORDERS=1 SEND_EMAIL_ORDERS=1
PORT=3000 PORT=3000
appTelegram_TEST=["1","17","18"] appTelegram_TEST=["1","13"]
appTelegram=["1","17","18"] appTelegram=["1","13"]
DOMAIN=mongodb://localhost:27017/ DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=1 AUTH_MONGODB=1
MONGODB_USER=admin MONGODB_USER=admin

View File

@@ -184,4 +184,8 @@ paoloar77: 38 RIS]
Gio 25/04 ORE 14:37: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 38 RIS [causale: ] Gio 25/04 ORE 14:37: [<b>Circuito RIS Bologna</b>]: Inviate Monete da paoloar77 a SuryaArena 38 RIS [causale: ]
Saldi: Saldi:
paoloar77: 0 RIS] paoloar77: 0 RIS]
SuryaArena: 37 RIS] SuryaArena: 37 RIS]
Gio 09/05 ORE 17:27: [<b>Circuito RIS Catania</b>]: Inviate Monete da paoloar77 a Giovannifruttadisicilia 1.5 RIS [causale: prova]
Saldi:
paoloar77: -1.50 RIS]
Giovannifruttadisicilia: 1.50 RIS]

View File

@@ -46,7 +46,7 @@ module.exports.executeQueryTable = function (idapp, params) {
module.exports.findAllIdApp = async function (idapp) { module.exports.findAllIdApp = async function (idapp) {
const myfind = { idapp }; const myfind = { idapp };
return await Author.find(myfind); return await Author.find(myfind).sort({name: 1, surname: 1});
}; };
module.exports.createIndexes((err) => { module.exports.createIndexes((err) => {

View File

@@ -227,6 +227,119 @@ module.exports.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params); return tools.executeQueryTable(this, idapp, params);
}; };
module.exports.executeQueryPickup = async function (idapp, params) {
let strfind = params.search;
strfind = strfind.replace(/[-@]/g, '');
if (strfind === '' && !params.filter) {
return [];
}
let filterfindexact = {};
if (strfind) {
filterfindexact = { comune: strfind };
}
let limit = 10;
let risexact = [];
let filterfind = {
idapp,
'productInfo.name': {
$regex: `\\b${strfind}`, // Usa \\b per trovare solo le parole che iniziano con strfind
$options: 'i' // Rendi la ricerca case-insensitive
}
};
/*
let aggr1 = [
{
$lookup: {
from: 'productinfos',
localField: 'idProductInfo',
foreignField: '_id',
as: 'productInfo'
}
},
{
$lookup: {
from: 'authors',
localField: 'idAuthors',
foreignField: '_id',
as: 'authors'
}
},
{
$match: { 'productInfo.name': strfind },
},
{ $limit: 1 },
{
$project: {
name: { $concat: ["$productInfo.name", " (", "$authors", ")"] },
},
},
];
if (params.filter) {
filterfind = { ...params.filter, ...filterfind };
limit = 200;
} else {
// risexact = await City.find(filterfindexact, {comune: 1, prov: 1, reg: 1}).lean();
risexact = await City.aggregate(aggr1);
}
*/
if (params.filter) {
filterfind = { ...params.filter, ...filterfind };
limit = 200;
}
let aggr2 = [
{
$lookup: {
from: 'productinfos',
localField: 'idProductInfo',
foreignField: '_id',
as: 'productInfo'
}
},
{
$unwind: {
path: '$productInfo',
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'authors',
localField: 'idAuthors',
foreignField: '_id',
as: 'authors'
}
},
{
$match: filterfind,
},
{ $limit: limit },
{
$project: {
name: '$productInfo.name',
},
},
];
// let ris = await City.find(filterfind, {comune: 1, prov: 1, reg: 1}).lean().limit(limit);
let ris = await this.aggregate(aggr2).limit(limit);
return [...risexact, ...ris];
};
module.exports.getProductByCode = function (idapp, code) { module.exports.getProductByCode = function (idapp, code) {
return Product.findAllIdApp(idapp, code); return Product.findAllIdApp(idapp, code);
} }

View File

@@ -161,18 +161,24 @@ sendNotifSchema.statics.getRecNotif = function (id) {
}; };
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord) { sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord, typedir) {
const SendNotif = this; const SendNotif = this;
if (!lastdataread) if (!lastdataread)
lastdataread = 0; lastdataread = 0;
let arrfilter = [
{ idapp },
{ dest: username },
{ datenotif: { $gt: new Date(lastdataread) } }
];
if (typedir) {
arrfilter.push({typedir});
}
return SendNotif.find({ return SendNotif.find({
$and: [ $and: arrfilter,
{ idapp },
{ 'dest': username },
{ 'datenotif': { $gt: new Date(lastdataread) } },
],
}).lean().limit(limitrecord).sort({ datenotif: -1 }).then(async (arrnotif) => { }).lean().limit(limitrecord).sort({ datenotif: -1 }).then(async (arrnotif) => {
// console.log('arrnotif', arrnotif.length); // console.log('arrnotif', arrnotif.length);
@@ -612,6 +618,7 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function (username, ida
$match: { $match: {
idapp, idapp,
dest: username, dest: username,
typedir: { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS },
}, },
}, },
{ $limit: limit }, { $limit: limit },
@@ -627,6 +634,38 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function (username, ida
}; };
sendNotifSchema.statics.findLastNotifCoinsByUserIdAndIdApp = function (username, idapp, limit, inattesa) {
const SendNotif = this;
let filter = {
idapp,
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
dest: username,
}
if (inattesa) {
filter.status = 0;
} else {
filter.status = { $ne: 0 };
}
return SendNotif.aggregate([
{
$match: filter,
},
{ $limit: limit },
{
$sort: { datenotif: -1 },
},
]).then(async (arrnotif) => {
return this.compileOtherFields(arrnotif);
}).catch((err) => {
console.error(err);
});
};
sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res, user) { sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res, user) {
const SendNotif = this; const SendNotif = this;
@@ -1097,18 +1136,18 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
} }
} }
/*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) { /*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) { if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) { if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
send = true; send = true;
}
} }
} } else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) { if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(myrecnotifpass.tablerec)) { if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) {
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) { send = true;
send = true; }
} }*/
}*/
} }
if (send) { if (send) {

View File

@@ -3281,7 +3281,8 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
} }
outres.recnotif = await SendNotif.getRecNotif(extrarec.notifId); outres.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER); outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.TypeNotifs.TYPEDIR_OTHERS);
outres.arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.TypeNotifs.TYPEDIR_CIRCUITS);
} else { } else {
outres.cansend = false; outres.cansend = false;

View File

@@ -461,7 +461,7 @@ router.post('/import', authenticate, async (req, res) => {
name: arrrecauthor[i].trim() name: arrrecauthor[i].trim()
} }
if (arrrecauthor.length > i + 1) { if (arrrecauthor.length > i + 1) {
surname = arrrecauthor[i + 1].trim() author.surname = arrrecauthor[i + 1].trim()
} }
arrAuthor.push(author); arrAuthor.push(author);
} catch (e) { } catch (e) {
@@ -513,18 +513,22 @@ router.post('/import', authenticate, async (req, res) => {
} }
} }
if (productInfo.publisher) { if (productInfo.publisher) {
publisher = productInfo.publisher.trim(); try {
// Cerca la Sotto Categoria publisher = productInfo.publisher.trim();
let recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean(); // Cerca la Sotto Categoria
if (!recpublisher) { let recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
// Non esiste questo Editore, quindi la creo ! if (!recpublisher) {
recpublisher = new Publisher({ idapp, name: publisher }); // Non esiste questo Editore, quindi la creo !
ris = await recpublisher.save(); recpublisher = new Publisher({ idapp, name: publisher });
recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean(); ris = await recpublisher.save();
} recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
}
if (recpublisher) { if (recpublisher) {
productInfo.idPublisher.push(recpublisher._id); productInfo.idPublisher = recpublisher._id;
}
} catch (e) {
console.error(e);
} }
} }

View File

@@ -84,13 +84,14 @@ router.post('/load', authenticate, async (req, res) => {
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, false, '', data.path); data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, false, '', data.path);
} }
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER); const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.TypeNotifs.TYPEDIR_OTHERS);
const arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.TypeNotifs.TYPEDIR_CIRCUITS);
/// E' QUIIII !!!! /// E' QUIIII !!!!
const useraccounts = await Account.getUserAccounts(idapp, req.user.username); const useraccounts = await Account.getUserAccounts(idapp, req.user.username);
await User.setLastCircuitOpened(idapp, req.user.username, path); await User.setLastCircuitOpened(idapp, req.user.username, path);
res.send({ circuit: data, users_in_circuit, arrrecnotif, useraccounts }); res.send({ circuit: data, users_in_circuit, arrrecnotif, arrrecnotifcoins, useraccounts });
} catch (e) { } catch (e) {
console.error('Error in Circuits', e); console.error('Error in Circuits', e);

View File

@@ -73,6 +73,7 @@ const CatAI = require('../models/catai');
const SubCatProd = require('../models/subcatprod'); const SubCatProd = require('../models/subcatprod');
const Gasordine = require('../models/gasordine'); const Gasordine = require('../models/gasordine');
const Product = require('../models/product'); const Product = require('../models/product');
const Author = require('../models/author');
const ProductInfo = require('../models/productInfo'); const ProductInfo = require('../models/productInfo');
const Scontistica = require('../models/scontistica'); const Scontistica = require('../models/scontistica');
const Department = require('../models/department'); const Department = require('../models/department');
@@ -1488,6 +1489,7 @@ function load(req, res, version) {
} catch (e) { } catch (e) {
} }
let products = Product.findAllIdApp(idapp, undefined, undefined, ismanager); let products = Product.findAllIdApp(idapp, undefined, undefined, ismanager);
let authors = Author.findAllIdApp(idapp);
let productInfos = ProductInfo.findAllIdApp(idapp); let productInfos = ProductInfo.findAllIdApp(idapp);
let scontisticas = Scontistica.findAllIdApp(idapp); let scontisticas = Scontistica.findAllIdApp(idapp);
let departments = Department.findAllIdApp(idapp); let departments = Department.findAllIdApp(idapp);
@@ -1584,6 +1586,7 @@ function load(req, res, version) {
subcatprods, subcatprods,
catprods_gas, catprods_gas,
catAI, catAI,
authors,
]).then((arrdata) => { ]).then((arrdata) => {
// console.table(arrdata); // console.table(arrdata);
let myuser = req.user; let myuser = req.user;
@@ -1676,6 +1679,7 @@ function load(req, res, version) {
catprods_gas: arrdata[47], catprods_gas: arrdata[47],
catAI: arrdata[48], catAI: arrdata[48],
code: req.code, code: req.code,
authors: arrdata[49],
}); });
const prova = 1; const prova = 1;
@@ -1696,7 +1700,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
return res.status(200).send(); return res.status(200).send();
} }
await CfgServer.find({ idapp }).then((arrcfgrec) => { await CfgServer.find({ idapp }).then(async (arrcfgrec) => {
if (!arrcfgrec) if (!arrcfgrec)
return res.status(404).send(); return res.status(404).send();
@@ -1705,6 +1709,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
let last_msgs = null; let last_msgs = null;
let last_notifs = null; let last_notifs = null;
let last_notifcoins = null;
let usersList = null; let usersList = null;
// const sall = '0'; // const sall = '0';
@@ -1718,6 +1723,8 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp); last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp);
last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40); last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40);
last_notifcoins_inattesa = SendNotif.findLastNotifCoinsByUserIdAndIdApp(req.user.username, idapp, 200, true);
last_notifcoins = SendNotif.findLastNotifCoinsByUserIdAndIdApp(req.user.username, idapp, 1, false);
if (req.user) { if (req.user) {
// If User is Admin, then send user Lists // If User is Admin, then send user Lists
@@ -1731,13 +1738,14 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
} }
} }
return Promise.all([usersList, last_msgs, last_notifs]).then((arrdata) => { return Promise.all([usersList, last_msgs, last_notifs, last_notifcoins, last_notifcoins_inattesa]).then((arrdata) => {
// console.table(arrdata); // console.table(arrdata);
return res.send({ return res.send({
CfgServer: arrcfgrec, CfgServer: arrcfgrec,
usersList: arrdata[0], usersList: arrdata[0],
last_msgs: arrdata[1], last_msgs: arrdata[1],
last_notifs: arrdata[2], last_notifs: arrdata[2],
last_notifcoins: [...arrdata[4], ...arrdata[3]],
}); });
}); });

View File

@@ -4,10 +4,10 @@ const router = express.Router();
const tools = require('../tools/general'); const tools = require('../tools/general');
const server_constants = require('../tools/server_constants'); const server_constants = require('../tools/server_constants');
const {authenticate} = require('../middleware/authenticate'); const { authenticate } = require('../middleware/authenticate');
const {SendNotif} = require('../models/sendnotif'); const { SendNotif } = require('../models/sendnotif');
const {User} = require('../models/user'); const { User } = require('../models/user');
const shared_consts = require('../tools/shared_nodejs'); const shared_consts = require('../tools/shared_nodejs');
@@ -23,9 +23,9 @@ router.post('/', authenticate, async (req, res) => {
const recout = await SendNotif.saveAndSendNotif(myrecnotif, req, res); const recout = await SendNotif.saveAndSendNotif(myrecnotif, req, res);
if (recout) { if (recout) {
return res.send({code: server_constants.RIS_CODE_OK, notif: '', record: recout}); return res.send({ code: server_constants.RIS_CODE_OK, notif: '', record: recout });
} else { } else {
return res.send({code: server_constants.RIS_CODE_ERR, notif: ''}); return res.send({ code: server_constants.RIS_CODE_ERR, notif: '' });
} }
}); });
@@ -39,12 +39,12 @@ router.get('/setall/:username/:qualinotif/:idapp', authenticate, async (req, res
try { try {
if (username === username_call) { if (username === username_call) {
let query = {idapp, dest: username, read: false}; let query = { idapp, dest: username, read: false };
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS) { if (qualinotif === shared_consts.QualiNotifs.CIRCUITS) {
query.typedir = {$eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS}; query.typedir = { $eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
} else if (qualinotif === shared_consts.QualiNotifs.OTHERS) { } else if (qualinotif === shared_consts.QualiNotifs.OTHERS) {
query.typedir = {$neq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS}; query.typedir = { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
} }
const arrNotifs = await SendNotif.find(query).lean(); const arrNotifs = await SendNotif.find(query).lean();
if (arrNotifs) { if (arrNotifs) {
@@ -67,7 +67,7 @@ router.get('/set/:_id/:idapp', authenticate, async (req, res) => {
const username_call = req.user.username; const username_call = req.user.username;
try { try {
let query = {_id, dest: username_call, read: false}; let query = { _id, dest: username_call, read: false };
const rec = await SendNotif.findOne(query); const rec = await SendNotif.findOne(query);
if (rec) { if (rec) {
@@ -83,17 +83,13 @@ router.get('/set/:_id/:idapp', authenticate, async (req, res) => {
}); });
router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
const idapp = req.params.idapp; async function delNotif(idapp, username, id, username_call) {
const username = req.params.username;
const myid = req.params.id;
const username_call = req.user.username;
try { try {
if (username === username_call) { if (username === username_call) {
await SendNotif.findOneAndRemove({idapp, _id: myid}); await SendNotif.findOneAndRemove({ idapp, _id: id });
return res.send(true); return res.send(true);
} }
} catch (e) { } catch (e) {
@@ -102,8 +98,19 @@ router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
return res.send(false); return res.send(false);
};
router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
try {
return delNotif(req.params.idapp, req.params.username, req.params.id, req.user.username);
} catch (e) {
return res.status(400).send(e);
}
}); });
router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res) => { router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res) => {
const idapp = req.params.idapp; const idapp = req.params.idapp;
@@ -113,12 +120,12 @@ router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res
try { try {
if (username === username_call) { if (username === username_call) {
let query = {idapp, dest: username}; let query = { idapp, dest: username };
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS) { if (qualinotif === shared_consts.QualiNotifs.CIRCUITS) {
query.typedir = {$eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS}; query.typedir = { $eq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
} else if (qualinotif === shared_consts.QualiNotifs.OTHERS) { } else if (qualinotif === shared_consts.QualiNotifs.OTHERS) {
query.typedir = {$neq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS}; query.typedir = { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
} }
const ris = await SendNotif.deleteMany(query); const ris = await SendNotif.deleteMany(query);
if (ris) if (ris)
@@ -133,31 +140,45 @@ router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res
}); });
router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => { router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
// tools.mylog('GET NotifS : ', req.params); return getNotif(req, res);
const username = req.params.username;
const lastdataread = req.params.lastdataread;
const idapp = req.params.idapp;
// var category = req.params.category;
if (req.user.idapp !== idapp) {
// I'm trying to get something not mine!
return res.status(404).send({code: server_constants.RIS_CODE_NOT_MY_USERNAME});
}
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIF_FOR_USER).then(async (arrnotif) => {
// const wait = new Promise((resolve, reject) => {
// setTimeout(() => {
//++Todo: Ottimizzare ! Non occorre inviare tutti questi dati !!! Solo per il Circuito ?!
const userprofile = await User.getExtraInfoByUsername(idapp, req.user.username);
return res.send({arrnotif, userprofile});
}).catch((e) => {
console.log(e.message);
res.status(400).send(e);
});
}); });
router.get('/:username/:lastdataread/:idapp/:qualinotif', authenticate, (req, res) => {
return getNotif(req, res);
});
function getNotif(req, res) {
try {
// tools.mylog('GET NotifS : ', req.params);
const username = req.params.username;
const lastdataread = req.params.lastdataread;
const idapp = req.params.idapp;
const qualinotif = req.params.qualinotif;
// var category = req.params.category;
if (req.user.idapp !== idapp) {
// I'm trying to get something not mine!
return res.status(404).send({ code: server_constants.RIS_CODE_NOT_MY_USERNAME });
}
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, qualinotif).then(async (arrnotif) => {
// const wait = new Promise((resolve, reject) => {
// setTimeout(() => {
//++Todo: Ottimizzare ! Non occorre inviare tutti questi dati !!! Solo per il Circuito ?!
const userprofile = await User.getExtraInfoByUsername(idapp, req.user.username);
return res.send({ arrnotif, userprofile });
}).catch((e) => {
console.log(e.message);
res.status(400).send(e);
});
} catch (e) {
console.log(e.message);
}
};
module.exports = router; module.exports = router;

View File

@@ -902,9 +902,8 @@ router.post('/updatesaldo', authenticate, async (req, res) => {
userprofile userprofile
} }
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER); ris.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.TypeNotifs.TYPEDIR_OTHERS);
ris.arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.TypeNotifs.TYPEDIR_CIRCUITS);
ris.arrrecnotif = arrrecnotif;
return res.send({ ris }); return res.send({ ris });

View File

@@ -940,7 +940,7 @@ const MyTelegramBot = {
keyb = cl.getInlineKeyboard(myuser.lang, [ keyb = cl.getInlineKeyboard(myuser.lang, [
{ {
text: '✅ Abilita ' + myuser.username, text: '✅ Ammetti ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest, callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest,
}, },
/*{ /*{

View File

@@ -2017,6 +2017,18 @@ module.exports = {
return query; return query;
}, },
sanitizzaHtml(html) {
try {
return sanitizeHtml(html);
} catch (e) {
return html
}
},
sanitizzaLookup: function (str) {
return str;
},
sanitizzaProjection: function (mioproj) { sanitizzaProjection: function (mioproj) {
// mioproj = {valore: '$password'}; // mioproj = {valore: '$password'};
@@ -2406,8 +2418,8 @@ module.exports = {
let query = []; let query = [];
if (params.filter && params.fieldsearch) { if (params.filter && params.fieldsearch) {
params.filter = sanitizeHtml(params.filter); params.filter = this.sanitizzaHtml(params.filter);
params.fieldsearch = sanitizeHtml(params.fieldsearch); params.fieldsearch = this.sanitizzaHtml(params.fieldsearch);
const querytemp = this.getFilterParam(params.filter, params.fieldsearch); const querytemp = this.getFilterParam(params.filter, params.fieldsearch);
if (querytemp) { if (querytemp) {
query = [...query, ...querytemp]; query = [...query, ...querytemp];
@@ -2424,7 +2436,7 @@ module.exports = {
// } // }
if (params.filterand) { if (params.filterand) {
params.filterand = sanitizeHtml(params.filterand); params.filterand = this.sanitizzaHtml(params.filterand);
if (params.filterand.includes( if (params.filterand.includes(
shared_consts.FILTER_EXTRALIST_NOT_REGISTERED)) shared_consts.FILTER_EXTRALIST_NOT_REGISTERED))
@@ -2545,7 +2557,7 @@ module.exports = {
} }
if (params.filtercustom) { if (params.filtercustom) {
params.filtercustom = sanitizeHtml(params.filtercustom); params.filtercustom = this.sanitizzaHtml(params.filtercustom);
let condition = {}; let condition = {};
for (const myfilter of params.filtercustom) { for (const myfilter of params.filtercustom) {
if (myfilter['userId']) { if (myfilter['userId']) {
@@ -2572,7 +2584,7 @@ module.exports = {
} }
if (params.filter_gte) { if (params.filter_gte) {
params.filter_gte = sanitizeHtml(params.filter_gte); params.filter_gte = this.sanitizzaHtml(params.filter_gte);
for (let ind = 0; ind < params.filter_gte.length; ind++) { for (let ind = 0; ind < params.filter_gte.length; ind++) {
for (const [key, value] of Object.entries(params.filter_gte[ind])) { for (const [key, value] of Object.entries(params.filter_gte[ind])) {
if (value > 0) { if (value > 0) {
@@ -2585,7 +2597,7 @@ module.exports = {
} }
if (params.filtersearch) { if (params.filtersearch) {
params.filtersearch = sanitizeHtml(params.filtersearch); params.filtersearch = this.sanitizzaHtml(params.filtersearch);
filtriadded.push(...params.filtersearch); filtriadded.push(...params.filtersearch);
} }
@@ -2597,13 +2609,13 @@ module.exports = {
if (params.filterextra) { if (params.filterextra) {
params.filterextra = sanitizeHtml(params.filterextra); params.filterextra = this.sanitizzaHtml(params.filterextra);
if (params.filterextra.length > 0) if (params.filterextra.length > 0)
query = [...query, ...params.filterextra] query = [...query, ...params.filterextra]
} }
if (filtriadded) { if (filtriadded) {
filtriadded = sanitizeHtml(filtriadded); filtriadded = this.sanitizzaHtml(filtriadded);
if (filtriadded.length > 0) if (filtriadded.length > 0)
query.push({ $match: { $and: filtriadded } }); query.push({ $match: { $and: filtriadded } });
} }