Il creatore del Gruppo deve già appartenere al Gruppo stesso

Non permettere di aggiungere un Gruppo con lo stesso nome o codice
quando cancelli un Gruppo, cancella anche tutti i riferimenti sugli utenti di quel gruppo.
Errore caricamento Immagini !
This commit is contained in:
paoloar77
2022-02-28 17:20:47 +01:00
parent 1d7397bafe
commit adf4918224
9 changed files with 188 additions and 117 deletions

View File

@@ -877,10 +877,18 @@ UserSchema.statics.setVerifiedByAportador = async function(
'username': username,
};
const myrec = await User.findOneAndUpdate(myquery,
{$set: {'verified_by_aportador': valuebool}}, {new: false});
const userver = await User.findOne(myquery, {verified_by_aportador: 1}).lean();
if (userver.verified_by_aportador !== valuebool) {
const myrec = await User.findOneAndUpdate(myquery,
{$set: {'verified_by_aportador': valuebool}}, {new: false});
return !!myrec;
} else {
return false;
}
return !!myrec;
};
UserSchema.statics.setnotask_verif = async function(
@@ -1404,6 +1412,12 @@ UserSchema.statics.removeFromMyGroups = async function(
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
};
// Rimuovo il Gruppo per Tutti gli Utenti
UserSchema.statics.removeAllUsersFromMyGroups = async function(idapp, groupnameDest) {
return User.updateMany({idapp},
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
};
// Rimuovo la Richiesta di Amicizia
UserSchema.statics.removeReqFriend = async function(
idapp, username, usernameDest) {
@@ -2311,8 +2325,9 @@ UserSchema.statics.getFieldsForSearch = function() {
{field: 'profile.revolut', type: tools.FieldType.string},
{field: 'profile.link_payment', type: tools.FieldType.string},
{field: 'profile.teleg_id', type: tools.FieldType.number},
{field: 'profile.username_telegram', type: tools.FieldType.string},
{field: 'aportador_solidario', type: tools.FieldType.string}];
{field: 'profile.username_telegram', type: tools.FieldType.string}
];
//{field: 'aportador_solidario', type: tools.FieldType.string}
};
UserSchema.statics.getFieldsForSearchUserFriend = function() {