++ aggiunta la prenotazione negli eventi. con la lista degli utenti.
This commit is contained in:
@@ -387,9 +387,9 @@ module.exports = {
|
||||
let sendmsg = false;
|
||||
|
||||
if (params.typenotif === shared_consts.TypeNotifs.TYPEDIR_FAVORITE) {
|
||||
if (!usernotifprofile || (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED))) {
|
||||
sendmsg = true;
|
||||
}
|
||||
if (!usernotifprofile || (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED))) {
|
||||
sendmsg = true;
|
||||
}
|
||||
} else {
|
||||
sendmsg = true;
|
||||
}
|
||||
@@ -592,6 +592,50 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
getNumAttendByIdObj: async function (idapp, numtab, id) {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
let query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
"profile.attend": {
|
||||
$elemMatch:
|
||||
{ id, tab: numtab }
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: null,
|
||||
count: {
|
||||
$sum:
|
||||
{
|
||||
$reduce: {
|
||||
input: "$profile.attend",
|
||||
initialValue: 0,
|
||||
in: {
|
||||
$add: ["$$value", "$$this.num"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
{ $project: { _id: 0 } }
|
||||
];
|
||||
|
||||
try {
|
||||
const [result] = await User.aggregate(query);
|
||||
|
||||
return result ? result.count : 0;
|
||||
} catch (err) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
getUserCreatorByNumTabAndId: async function (idapp, id, numtab) {
|
||||
try {
|
||||
const table = tools.getTableByNumTab(numtab);
|
||||
@@ -604,10 +648,15 @@ module.exports = {
|
||||
if (rec) {
|
||||
const recuser = await User.getUserById(idapp, rec.userId);
|
||||
|
||||
let numattend = await this.getNumAttendByIdObj(idapp, numtab, id);
|
||||
let numfav = await this.getNumFavoriteByIdObj(idapp, numtab, id);
|
||||
let exist = numfav > 1;
|
||||
let exist = false;
|
||||
if (table === shared_consts.TABLES_MYBACHECAS)
|
||||
exist = numattend > 1;
|
||||
else
|
||||
exist = numfav > 1;
|
||||
if (recuser)
|
||||
return { userId: rec.userId, username: recuser.username, descr: rec.descr, id: rec._id, table, exist, numfav };
|
||||
return { userId: rec.userId, username: recuser.username, descr: rec.descr, id: rec._id, table, exist, numfav, numattend };
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user