- 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

@@ -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) {