- Refused User

- Report User
- Unblock User
- refresh tables when an action (setFriends and setGroups) occurred.
- fix duplicate call of loadsite
This commit is contained in:
paoloar77
2022-08-08 16:35:32 +02:00
parent e433d3db8c
commit fc8e8d8034
7 changed files with 182 additions and 59 deletions

View File

@@ -937,7 +937,7 @@ module.exports = {
},
sendNotifGroupByUsername: async function(
cmd, typeid_pass, idapp, usernameOrig, usernameDest, username_action, groupname, myrecgroup, isAdmin, username_worked) {
cmd, idapp, usernameOrig, usernameDest, username_action, groupname, myrecgroup, isAdmin, username_worked) {
const {SendNotif} = require('../models/sendnotif');
const {User} = require('../models/user');
@@ -991,9 +991,6 @@ module.exports = {
typeid = shared_consts.TypeNotifs.ID_GROUP_DELETE_USER;
}
if (typeid_pass) {
typeid = typeid_pass;
}
}
if (sendnotif && typeid > 0) {
@@ -1023,7 +1020,7 @@ module.exports = {
if (usernameOrig === singleadmin.username)
giainviato = true;
await this.sendNotifGroupByUsername(cmd, 0, idapp, usernameOrig, singleadmin.username, username_action, groupname, group, true);
await this.sendNotifGroupByUsername(cmd, idapp, usernameOrig, singleadmin.username, username_action, groupname, group, true);
}
} catch (e) {
console.error('sendNotificationByGroupname', e);
@@ -1032,9 +1029,11 @@ module.exports = {
if (!giainviato && (cmd !== shared_consts.GROUPSCMD.REQGROUP)) {
// SEND TO THE USER THE NOTIFICATION
await this.sendNotifGroupByUsername(cmd, value, idapp, usernameOrig, usernameOrig, username_action, groupname, false);
await this.sendNotifGroupByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, groupname, false);
}
} catch (e) {
console.error('e', e);
}
@@ -1652,17 +1651,6 @@ module.exports = {
numrowend = 1;
if (params.querytype === shared_consts.QUERYTYPE_MYGROUP) {
// query.push({'$addFields': {'myid': {'$toObjectId': params.myid}}});
/*query.push({
$match: {
$and: [
{idapp},
{'_id': '$myid'},
],
},
});
*/
query.push({
$match: {
$expr: {
@@ -1700,6 +1688,44 @@ module.exports = {
},
);
} else if (params.querytype === shared_consts.QUERYTYPE_REFUSED_USER_GRP) {
query.push({
$match: {
$expr: {
$eq: ['$_id', params.myid],
},
},
});
query.push({$project: {refused_users: 1}});
const qa1 = this.getLookup(
{
lk_tab: 'users',
lk_LF: 'refused_users.username',
lk_FF: 'username',
lk_as: 'user',
}, 0, {
'user.idapp': 1,
'user.username': 1,
'user.profile.img': 1,
'user.profile.qualifica': 1,
});
if (qa1) query = [...query, ...qa1];
query.push({$unwind: '$user'});
query.push({
$match: {
$and: [
{'user.idapp': idapp},
],
},
});
query.push({
$replaceRoot: {
newRoot: '$user',
},
},
);
}
if (newvers) {