diff --git a/.env.development b/.env.development
index b7b5087..b85e237 100644
--- a/.env.development
+++ b/.env.development
@@ -1,11 +1,11 @@
-DATABASE=test_PiuCheBuono
+DATABASE=test_FreePlanet
UDB=paofreeplanet
PDB=mypassword@1A
SEND_EMAIL=0
SEND_EMAIL_ORDERS=1
PORT=3000
-appTelegram_TEST=["1","17","18"]
-appTelegram=["1","17","18"]
+appTelegram_TEST=["1","13"]
+appTelegram=["1","13"]
DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=1
MONGODB_USER=admin
diff --git a/logtrans.txt b/logtrans.txt
index ef6147b..e03ba3e 100644
--- a/logtrans.txt
+++ b/logtrans.txt
@@ -184,4 +184,8 @@ paoloar77: 38 RIS]
Gio 25/04 ORE 14:37: [Circuito RIS Bologna]: Inviate Monete da paoloar77 a SuryaArena 38 RIS [causale: ]
Saldi:
paoloar77: 0 RIS]
-SuryaArena: 37 RIS]
\ No newline at end of file
+SuryaArena: 37 RIS]
+Gio 09/05 ORE 17:27: [Circuito RIS Catania]: Inviate Monete da paoloar77 a Giovannifruttadisicilia 1.5 RIS [causale: prova]
+Saldi:
+paoloar77: -1.50 RIS]
+Giovannifruttadisicilia: 1.50 RIS]
\ No newline at end of file
diff --git a/src/server/models/author.js b/src/server/models/author.js
index de7711d..17a4440 100755
--- a/src/server/models/author.js
+++ b/src/server/models/author.js
@@ -46,7 +46,7 @@ module.exports.executeQueryTable = function (idapp, params) {
module.exports.findAllIdApp = async function (idapp) {
const myfind = { idapp };
- return await Author.find(myfind);
+ return await Author.find(myfind).sort({name: 1, surname: 1});
};
module.exports.createIndexes((err) => {
diff --git a/src/server/models/product.js b/src/server/models/product.js
index 44f5841..f3ec0c5 100755
--- a/src/server/models/product.js
+++ b/src/server/models/product.js
@@ -227,6 +227,119 @@ module.exports.executeQueryTable = function (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) {
return Product.findAllIdApp(idapp, code);
}
diff --git a/src/server/models/sendnotif.js b/src/server/models/sendnotif.js
index 8afa622..a955c8f 100755
--- a/src/server/models/sendnotif.js
+++ b/src/server/models/sendnotif.js
@@ -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;
if (!lastdataread)
lastdataread = 0;
+ let arrfilter = [
+ { idapp },
+ { dest: username },
+ { datenotif: { $gt: new Date(lastdataread) } }
+ ];
+
+ if (typedir) {
+ arrfilter.push({typedir});
+ }
+
return SendNotif.find({
- $and: [
- { idapp },
- { 'dest': username },
- { 'datenotif': { $gt: new Date(lastdataread) } },
- ],
+ $and: arrfilter,
}).lean().limit(limitrecord).sort({ datenotif: -1 }).then(async (arrnotif) => {
// console.log('arrnotif', arrnotif.length);
@@ -612,6 +618,7 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function (username, ida
$match: {
idapp,
dest: username,
+ typedir: { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS },
},
},
{ $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) {
const SendNotif = this;
@@ -1097,18 +1136,18 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
}
}
- /*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
- if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
- if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
- send = true;
+ /*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
+ if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
+ if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
+ send = true;
+ }
}
- }
- } else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
- if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
- if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) {
- send = true;
- }
- }*/
+ } else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
+ if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
+ if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) {
+ send = true;
+ }
+ }*/
}
if (send) {
diff --git a/src/server/models/user.js b/src/server/models/user.js
index 3d82944..464585e 100755
--- a/src/server/models/user.js
+++ b/src/server/models/user.js
@@ -3281,7 +3281,8 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
}
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 {
outres.cansend = false;
diff --git a/src/server/router/admin_router.js b/src/server/router/admin_router.js
index 8bf7c3e..dd9efc5 100755
--- a/src/server/router/admin_router.js
+++ b/src/server/router/admin_router.js
@@ -461,7 +461,7 @@ router.post('/import', authenticate, async (req, res) => {
name: arrrecauthor[i].trim()
}
if (arrrecauthor.length > i + 1) {
- surname = arrrecauthor[i + 1].trim()
+ author.surname = arrrecauthor[i + 1].trim()
}
arrAuthor.push(author);
} catch (e) {
@@ -513,18 +513,22 @@ router.post('/import', authenticate, async (req, res) => {
}
}
if (productInfo.publisher) {
- publisher = productInfo.publisher.trim();
- // Cerca la Sotto Categoria
- let recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
- if (!recpublisher) {
- // Non esiste questo Editore, quindi la creo !
- recpublisher = new Publisher({ idapp, name: publisher });
- ris = await recpublisher.save();
- recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
- }
+ try {
+ publisher = productInfo.publisher.trim();
+ // Cerca la Sotto Categoria
+ let recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
+ if (!recpublisher) {
+ // Non esiste questo Editore, quindi la creo !
+ recpublisher = new Publisher({ idapp, name: publisher });
+ ris = await recpublisher.save();
+ recpublisher = await Publisher.findOne({ idapp, name: publisher }).lean();
+ }
- if (recpublisher) {
- productInfo.idPublisher.push(recpublisher._id);
+ if (recpublisher) {
+ productInfo.idPublisher = recpublisher._id;
+ }
+ } catch (e) {
+ console.error(e);
}
}
diff --git a/src/server/router/circuits_router.js b/src/server/router/circuits_router.js
index 109c4bd..6ead97c 100755
--- a/src/server/router/circuits_router.js
+++ b/src/server/router/circuits_router.js
@@ -84,13 +84,14 @@ router.post('/load', authenticate, async (req, res) => {
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 !!!!
const useraccounts = await Account.getUserAccounts(idapp, req.user.username);
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) {
console.error('Error in Circuits', e);
diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js
index a33578a..bb878bc 100755
--- a/src/server/router/index_router.js
+++ b/src/server/router/index_router.js
@@ -73,6 +73,7 @@ const CatAI = require('../models/catai');
const SubCatProd = require('../models/subcatprod');
const Gasordine = require('../models/gasordine');
const Product = require('../models/product');
+const Author = require('../models/author');
const ProductInfo = require('../models/productInfo');
const Scontistica = require('../models/scontistica');
const Department = require('../models/department');
@@ -1488,6 +1489,7 @@ function load(req, res, version) {
} catch (e) {
}
let products = Product.findAllIdApp(idapp, undefined, undefined, ismanager);
+ let authors = Author.findAllIdApp(idapp);
let productInfos = ProductInfo.findAllIdApp(idapp);
let scontisticas = Scontistica.findAllIdApp(idapp);
let departments = Department.findAllIdApp(idapp);
@@ -1584,6 +1586,7 @@ function load(req, res, version) {
subcatprods,
catprods_gas,
catAI,
+ authors,
]).then((arrdata) => {
// console.table(arrdata);
let myuser = req.user;
@@ -1676,6 +1679,7 @@ function load(req, res, version) {
catprods_gas: arrdata[47],
catAI: arrdata[48],
code: req.code,
+ authors: arrdata[49],
});
const prova = 1;
@@ -1696,7 +1700,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res
return res.status(200).send();
}
- await CfgServer.find({ idapp }).then((arrcfgrec) => {
+ await CfgServer.find({ idapp }).then(async (arrcfgrec) => {
if (!arrcfgrec)
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_notifs = null;
+ let last_notifcoins = null;
let usersList = null;
// 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_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 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);
return res.send({
CfgServer: arrcfgrec,
usersList: arrdata[0],
last_msgs: arrdata[1],
last_notifs: arrdata[2],
+ last_notifcoins: [...arrdata[4], ...arrdata[3]],
});
});
diff --git a/src/server/router/sendnotif_router.js b/src/server/router/sendnotif_router.js
index 42fd05d..4b3d0b1 100755
--- a/src/server/router/sendnotif_router.js
+++ b/src/server/router/sendnotif_router.js
@@ -4,10 +4,10 @@ const router = express.Router();
const tools = require('../tools/general');
const server_constants = require('../tools/server_constants');
-const {authenticate} = require('../middleware/authenticate');
+const { authenticate } = require('../middleware/authenticate');
-const {SendNotif} = require('../models/sendnotif');
-const {User} = require('../models/user');
+const { SendNotif } = require('../models/sendnotif');
+const { User } = require('../models/user');
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);
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 {
- 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 {
if (username === username_call) {
- let query = {idapp, dest: username, read: false};
+ let query = { idapp, dest: username, read: false };
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) {
- query.typedir = {$neq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS};
+ query.typedir = { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
}
const arrNotifs = await SendNotif.find(query).lean();
if (arrNotifs) {
@@ -67,7 +67,7 @@ router.get('/set/:_id/:idapp', authenticate, async (req, res) => {
const username_call = req.user.username;
try {
- let query = {_id, dest: username_call, read: false};
+ let query = { _id, dest: username_call, read: false };
const rec = await SendNotif.findOne(query);
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;
- const username = req.params.username;
- const myid = req.params.id;
- const username_call = req.user.username;
+async function delNotif(idapp, username, id, username_call) {
try {
if (username === username_call) {
- await SendNotif.findOneAndRemove({idapp, _id: myid});
+ await SendNotif.findOneAndRemove({ idapp, _id: id });
return res.send(true);
}
} catch (e) {
@@ -102,8 +98,19 @@ router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
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) => {
const idapp = req.params.idapp;
@@ -113,12 +120,12 @@ router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res
try {
if (username === username_call) {
- let query = {idapp, dest: username};
+ let query = { idapp, dest: username };
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) {
- query.typedir = {$neq: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS};
+ query.typedir = { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS };
}
const ris = await SendNotif.deleteMany(query);
if (ris)
@@ -133,31 +140,45 @@ router.get('/delall/:username/:qualinotif/:idapp', authenticate, async (req, res
});
router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
- // tools.mylog('GET NotifS : ', req.params);
- 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);
- });
-
+ return getNotif(req, res);
});
+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;
diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js
index 138f2a7..519e507 100755
--- a/src/server/router/users_router.js
+++ b/src/server/router/users_router.js
@@ -902,9 +902,8 @@ router.post('/updatesaldo', authenticate, async (req, res) => {
userprofile
}
- const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
-
- ris.arrrecnotif = arrrecnotif;
+ 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);
return res.send({ ris });
diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js
index 54355d2..e8b3eeb 100755
--- a/src/server/telegram/telegrambot.js
+++ b/src/server/telegram/telegrambot.js
@@ -940,7 +940,7 @@ const MyTelegramBot = {
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,
},
/*{
diff --git a/src/server/tools/general.js b/src/server/tools/general.js
index aec1b47..40da223 100755
--- a/src/server/tools/general.js
+++ b/src/server/tools/general.js
@@ -2017,6 +2017,18 @@ module.exports = {
return query;
},
+ sanitizzaHtml(html) {
+ try {
+ return sanitizeHtml(html);
+ } catch (e) {
+ return html
+ }
+ },
+
+ sanitizzaLookup: function (str) {
+ return str;
+ },
+
sanitizzaProjection: function (mioproj) {
// mioproj = {valore: '$password'};
@@ -2406,8 +2418,8 @@ module.exports = {
let query = [];
if (params.filter && params.fieldsearch) {
- params.filter = sanitizeHtml(params.filter);
- params.fieldsearch = sanitizeHtml(params.fieldsearch);
+ params.filter = this.sanitizzaHtml(params.filter);
+ params.fieldsearch = this.sanitizzaHtml(params.fieldsearch);
const querytemp = this.getFilterParam(params.filter, params.fieldsearch);
if (querytemp) {
query = [...query, ...querytemp];
@@ -2424,7 +2436,7 @@ module.exports = {
// }
if (params.filterand) {
- params.filterand = sanitizeHtml(params.filterand);
+ params.filterand = this.sanitizzaHtml(params.filterand);
if (params.filterand.includes(
shared_consts.FILTER_EXTRALIST_NOT_REGISTERED))
@@ -2545,7 +2557,7 @@ module.exports = {
}
if (params.filtercustom) {
- params.filtercustom = sanitizeHtml(params.filtercustom);
+ params.filtercustom = this.sanitizzaHtml(params.filtercustom);
let condition = {};
for (const myfilter of params.filtercustom) {
if (myfilter['userId']) {
@@ -2572,7 +2584,7 @@ module.exports = {
}
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 (const [key, value] of Object.entries(params.filter_gte[ind])) {
if (value > 0) {
@@ -2585,7 +2597,7 @@ module.exports = {
}
if (params.filtersearch) {
- params.filtersearch = sanitizeHtml(params.filtersearch);
+ params.filtersearch = this.sanitizzaHtml(params.filtersearch);
filtriadded.push(...params.filtersearch);
}
@@ -2597,13 +2609,13 @@ module.exports = {
if (params.filterextra) {
- params.filterextra = sanitizeHtml(params.filterextra);
+ params.filterextra = this.sanitizzaHtml(params.filterextra);
if (params.filterextra.length > 0)
query = [...query, ...params.filterextra]
}
if (filtriadded) {
- filtriadded = sanitizeHtml(filtriadded);
+ filtriadded = this.sanitizzaHtml(filtriadded);
if (filtriadded.length > 0)
query.push({ $match: { $and: filtriadded } });
}