- fix notifiche

This commit is contained in:
Surya Paolo
2024-05-10 01:08:49 +02:00
parent 1d5002ea0f
commit 87808caadf
3 changed files with 11 additions and 6 deletions

View File

@@ -161,7 +161,7 @@ sendNotifSchema.statics.getRecNotif = function (id) {
};
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord, qualinotif) {
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord, qualinotif, arroptionfilter) {
const SendNotif = this;
if (!lastdataread)
@@ -179,7 +179,10 @@ sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, l
} else {
arrfilter.push({ typedir: { $ne: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS } });
}
}
if (arroptionfilter) {
arrfilter = [...arrfilter, ...arroptionfilter];
}
return SendNotif.find({

View File

@@ -159,13 +159,14 @@ async function getNotif(req, res) {
}
const arrnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.OTHERS);
const arrnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.CIRCUITS);
const arrnotifcoins_inattesa = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIFCOINS_IN_ATTESA_FOR_USER, shared_consts.QualiNotifs.CIRCUITS, [{ status: 0 }]);
const arrnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIFCOINS_FOR_USER, shared_consts.QualiNotifs.CIRCUITS, [{ status: {$ne: 0 }}]);
//++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, arrnotifcoins, userprofile });
return res.send({ arrnotif, arrnotifcoins: [...arrnotifcoins, ...arrnotifcoins_inattesa], userprofile });
} catch (e) {
console.log(e.message);

View File

@@ -3,8 +3,9 @@ module.exports = {
CHECK_READ_GUIDELINES: 1,
CHECK_SEE_VIDEO_PRINCIPI: 2,
},
LIMIT_NOTIF_FOR_USER: 100,
LIMIT_NOTIFCOINS_FOR_USER: 200,
LIMIT_NOTIF_FOR_USER: 50,
LIMIT_NOTIFCOINS_FOR_USER: 50,
LIMIT_NOTIFCOINS_IN_ATTESA_FOR_USER: 200,
QUERYTYPE_MYGROUP: 1,
QUERYTYPE_REFUSED_USER_GRP: 2,