- 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:
@@ -1777,6 +1777,36 @@ UserSchema.statics.setFriendsCmd = async function(req, idapp, usernameOrig, user
|
||||
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.UNBLOCK_USER) {
|
||||
|
||||
username_worked = usernameDest;
|
||||
|
||||
// Sblocco la persona
|
||||
ris = await User.updateOne({idapp, username: username_worked}, {
|
||||
$set: {
|
||||
reported: false,
|
||||
},
|
||||
});
|
||||
|
||||
if (ris) {
|
||||
// Send a notification to the DESTINATION!
|
||||
await SendNotif.createNewNotifToSingleUser(req, null, {username_worked, usernameDest, username_action}, false, shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||
shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED);
|
||||
|
||||
// Send a notification to the SENDER !
|
||||
// Hai segnalato %s da %s per comportamenti non idonei.
|
||||
await SendNotif.createNewNotifToSingleUser(req, null, {username_worked, usernameDest: username_action, username_action}, false,
|
||||
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||
shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED);
|
||||
|
||||
if (usernameOrig !== telegrambot.ADMIN_USER_SERVER) {
|
||||
// Send a notification to the Admin
|
||||
await SendNotif.createNewNotifToSingleUser(req, null, {username_worked, usernameDest: telegrambot.ADMIN_USER_SERVER, username_action, isAdmin: true}, false,
|
||||
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
|
||||
shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -1832,8 +1862,11 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
||||
|
||||
// Elimina la richiesta:
|
||||
update = {$pull: {req_users: {username: {$in: [usernameOrig]}}}};
|
||||
ris = await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
update);
|
||||
await MyGroup.updateOne({idapp, groupname: groupnameDest}, update);
|
||||
|
||||
// Elimina eventualmente se era bloccato:
|
||||
update = {$pull: {refused_users: {username: {$in: [usernameOrig]}}}};
|
||||
await MyGroup.updateOne({idapp, groupname: groupnameDest}, update);
|
||||
} else {
|
||||
ris = false;
|
||||
}
|
||||
@@ -1892,6 +1925,8 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
||||
|
||||
} else if (cmd === shared_consts.GROUPSCMD.REFUSE_REQ_GROUP) {
|
||||
|
||||
ris = await MyGroup.refuseReqGroup(idapp, usernameOrig, groupnameDest); // Aggiungi alla lista utenti Rifiutati
|
||||
|
||||
ris = await MyGroup.removeReqGroup(idapp, usernameOrig, groupnameDest); // Rimuovo la richiesta di entrare nel gruppo
|
||||
console.log('ris', ris);
|
||||
|
||||
@@ -3443,6 +3478,20 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
|
||||
? listSentMyRequestGroups
|
||||
: [];
|
||||
|
||||
const listRefusedGroups = await MyGroup.find({
|
||||
idapp,
|
||||
'refused_users': {
|
||||
$elemMatch: {username: {$eq: recUser.username}},
|
||||
},
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
}, MyGroup.getWhatToShow_Unknown()).lean();
|
||||
|
||||
recUser._doc.profile.refused_groups = listRefusedGroups
|
||||
? listRefusedGroups
|
||||
: [];
|
||||
|
||||
const listManageGroups = await MyGroup.find({
|
||||
idapp,
|
||||
'admins': {
|
||||
|
||||
Reference in New Issue
Block a user