- fix RIS in pendenti, se troppi msg, non compariva piu
- cataloghi, ricerca pickup
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user