Group Page corrected

This commit is contained in:
paoloar77
2022-08-09 17:32:06 +02:00
parent fc8e8d8034
commit 680b353535
8 changed files with 96 additions and 15 deletions

View File

@@ -21,6 +21,10 @@
"GROUP_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel gruppo %s",
"GROUP_CREATED": "✅ %s ha creato un nuovo Gruppo chiamato %s",
"GROUP_REQUEST": "Richiesta di entrare nel Gruppo %s da parte di %s",
"GROUPS_ADDED_ADMIN_GROUP": "E' stato aggiunto %s come Amministratore del gruppo %s da parte di %s",
"GROUPS_ADDED_ADMIN_GROUP_YOU": "Sei stato aggiunto come Amministratore del gruppo %s da parte di %s",
"GROUPS_REMOVED_ADMIN_GROUP": "E' stato rimosso l'incarico di Amministratore a %s del gruppo %s da parte di %s",
"GROUPS_REMOVED_ADMIN_GROUP_YOU": "Ti è stato rimosso l'incarico di Amministratore del gruppo %s da parte di %s",
"RICHIESTA_BLOCCO_GRUPPO": "Richiesta di bloccare il Gruppo %s da parte di %s",
"GRUPPO_ELIMINATO": "Il gruppo %s è stato eliminato da parte di %s",
"FRIEND_REPORTED_TO_ME": "Sei stato segnalato da %s per comportamenti non idonei. Contatta %s per chiarimenti",

View File

@@ -172,6 +172,8 @@ MyBachecaSchema.statics.executeQueryTable = function(idapp, params, user) {
"profile.mygroups": 1,
'profile.qualifica': 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
};

View File

@@ -190,6 +190,29 @@ MyGroupSchema.statics.refuseReqGroup = async function(idapp, username, groupname
};
// Aggiungi agli Admin del Gruppo
MyGroupSchema.statics.addToAdminOfMyGroup = async function(idapp, username, groupnameDest) {
return MyGroup.updateOne({idapp, groupname: groupnameDest},
{
$push:
{
admins: {
username,
date: new Date(),
},
},
});
};
// Rimuovi dagli Admin del Gruppo
MyGroupSchema.statics.removeAdminOfMyGroup = async function(idapp, username, groupnameDest) {
return MyGroup.updateOne({idapp, groupname: groupnameDest},
{$pull: {admins: {username: {$in: [username]}}}});
};
MyGroupSchema.statics.getWhatToShow = function(idapp, username) {
// FOR ME, PERMIT ALL
return {
@@ -209,6 +232,8 @@ MyGroupSchema.statics.getWhatToShow = function(idapp, username) {
blocked: 1,
req_users: 1,
refused_users: 1,
createdBy: 1,
date_created: 1,
};
};

View File

@@ -172,15 +172,19 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
tag = 'reportuser';
if (recnotif.paramsObj.usernameDest === recnotif.paramsObj.username_action) {
newdescr = i18n.__('FRIEND_REPORTED_YOU', recnotif.paramsObj.username_worked);
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_worked;
} else if (recnotif.paramsObj.isAdmin) {
newdescr = i18n.__('FRIEND_REPORTED', recnotif.paramsObj.usernameDest, userorig);
recnotif.openUrl = '/my/' + recnotif.paramsObj.usernameDest;
} else {
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_action;
newdescr = i18n.__('FRIEND_REPORTED_TO_ME', recnotif.paramsObj.username_action, recnotif.paramsObj.username_action);
}
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED) {
tag = 'unblockeduser';
if (recnotif.paramsObj.usernameDest === recnotif.paramsObj.username_action) {
newdescr = i18n.__('FRIEND_UNBLOCKED_YOU', recnotif.paramsObj.username_worked);
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_worked;
} else if (recnotif.paramsObj.isAdmin) {
newdescr = i18n.__('FRIEND_UNBLOCKED', recnotif.paramsObj.usernameDest, userorig);
} else {
@@ -195,18 +199,23 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
if (recnotif.paramsObj.isAdmin) {
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
} else
recnotif.openUrl = '/my/' + userorig;
} else {
newdescr = i18n.__('GROUPS_ACCEPTED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
}
tag = 'addgroup';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED) {
if (recnotif.paramsObj.username_action === recnotif.paramsObj.usernameDest && userorig === recnotif.paramsObj.usernameDest)
if (recnotif.paramsObj.username_action === recnotif.paramsObj.usernameDest && userorig === recnotif.paramsObj.usernameDest) {
newdescr = i18n.__('GROUPS_EXIT_USER_TO_ME', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
else if (userorig === recnotif.paramsObj.usernameDest)
} else if (userorig === recnotif.paramsObj.usernameDest) {
newdescr = i18n.__('GROUPS_REMOVED_TO_ME', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
else if (userorig === recnotif.paramsObj.username_action)
} else if (userorig === recnotif.paramsObj.username_action) {
newdescr = i18n.__('GROUPS_EXIT_USER', userorig, recnotif.paramsObj.groupnameDest);
else
recnotif.openUrl = '/my/' + userorig;
} else {
newdescr = i18n.__('GROUPS_REMOVED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
}
tag = 'remgroup';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REFUSED) {
newdescr = i18n.__('GROUPS_REFUSED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
@@ -223,11 +232,22 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_DELETE_USER) {
newdescr = i18n.__('GRUPPO_ELIMINATO', userorig, recnotif.paramsObj.username_action);
tag = 'deletegroup';
}
if (recnotif.paramsObj.isAdmin) {
// If is a Admin, then click to see the user's profile
recnotif.openUrl = '/my/' + userorig;
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ADDED_ADMIN_OFMYGROUP) {
if (userorig === recnotif.paramsObj.usernameDest) {
newdescr = i18n.__('GROUPS_ADDED_ADMIN_GROUP_YOU', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
} else {
newdescr = i18n.__('GROUPS_ADDED_ADMIN_GROUP', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
recnotif.openUrl = '/my/' + userorig;
}
tag = 'addadmingrp';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED_ADMIN_OFMYGROUP) {
if (userorig === recnotif.paramsObj.usernameDest) {
newdescr = i18n.__('GROUPS_REMOVED_ADMIN_GROUP_YOU', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
} else {
newdescr = i18n.__('GROUPS_REMOVED_ADMIN_GROUP', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
recnotif.openUrl = '/my/' + userorig;
}
tag = 'removeadmingrp';
}
}

View File

@@ -703,6 +703,8 @@ UserSchema.statics.getUserShortDataByUsername = async function(idapp, username)
surname: 1,
deleted: 1,
reported: 1,
date_report: 1,
username_who_report: 1,
sospeso: 1,
verified_email: 1,
verified_by_aportador: 1,
@@ -1366,6 +1368,8 @@ UserSchema.statics.getUserProfileByUsername = async function(
deleted: 1,
sospeso: 1,
reported: 1,
date_report: 1,
username_who_report: 1,
verified_email: 1,
verified_by_aportador: 1,
date_reg: 1,
@@ -1384,6 +1388,8 @@ UserSchema.statics.getUserProfileByUsername = async function(
deleted: 1,
sospeso: 1,
reported: 1,
date_report: 1,
username_who_report: 1,
verified_email: 1,
verified_by_aportador: 1,
'profile.nationality': 1,
@@ -1418,6 +1424,8 @@ UserSchema.statics.getUserProfileByUsername = async function(
deleted: 1,
sospeso: 1,
reported: 1,
date_report: 1,
username_who_report: 1,
verified_email: 1,
verified_by_aportador: 1,
notask_verif: 1,
@@ -1923,11 +1931,9 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
// Invia una notifica alla persona
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
} else if (cmd === shared_consts.GROUPSCMD.REFUSE_REQ_GROUP) {
} else if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP) {
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
ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
console.log('ris', ris);
// Invia una notifica alla persona
@@ -1964,6 +1970,18 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
//++Todo: Send Notification to Admin and Group's manager
tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
} else if (cmd === shared_consts.GROUPSCMD.ADDADMIN_OFMYGROUP) {
ris = await MyGroup.addToAdminOfMyGroup(idapp, usernameOrig, groupnameDest); // Rimuovo la richiesta di entrare nel gruppo
// Invia una notifica alla persona
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
} else if (cmd === shared_consts.GROUPSCMD.REMOVEADMIN_OFMYGROUP) {
ris = await MyGroup.removeAdminOfMyGroup(idapp, usernameOrig, groupnameDest); // Rimuovo la richiesta di entrare nel gruppo
// Invia una notifica alla persona
await tools.sendNotificationByGroupname(idapp, usernameOrig, groupnameDest, cmd, false, true, username_action);
}
} catch (e) {
console.error('Error: ', e);
@@ -1981,6 +1999,8 @@ function getWhatToShow(idapp, username) {
deleted: 1,
sospeso: 1,
reported: 1,
date_report: 1,
username_who_report: 1,
verified_email: 1,
verified_by_aportador: 1,
notask_verif: 1,

View File

@@ -509,6 +509,8 @@ router.post('/getexp', authenticate, (req, res) => {
username: 1,
email: 1,
'reported': 1,
date_report: 1,
username_who_report: 1,
'profile.teleg_id': 1,
'verified_by_aportador': 1,
'profile.username_telegram': 1,
@@ -1339,7 +1341,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
// msgs = SendMsg.findAllByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
let last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp);
let last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 20);
let last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40);
let usersList = null;

View File

@@ -989,6 +989,10 @@ module.exports = {
typeid = shared_consts.TypeNotifs.ID_GROUP_BLOCK_USER;
} else if (cmd === shared_consts.GROUPSCMD.DELETE_GROUP) {
typeid = shared_consts.TypeNotifs.ID_GROUP_DELETE_USER;
} else if (cmd === shared_consts.GROUPSCMD.ADDADMIN_OFMYGROUP) {
typeid = shared_consts.TypeNotifs.ID_GROUP_ADDED_ADMIN_OFMYGROUP;
} else if (cmd === shared_consts.GROUPSCMD.REMOVEADMIN_OFMYGROUP) {
typeid = shared_consts.TypeNotifs.ID_GROUP_REMOVED_ADMIN_OFMYGROUP;
}
}

View File

@@ -62,6 +62,8 @@ module.exports = {
BLOCK_GROUP: 1155,
FIND_GROUP: 1166,
DELETE_GROUP: 1170,
ADDADMIN_OFMYGROUP: 1180,
REMOVEADMIN_OFMYGROUP: 1185,
},
REPORT_FILT_RESP: 1,
@@ -333,6 +335,8 @@ module.exports = {
ID_GROUP_BLOCK_USER: 16,
ID_GROUP_DELETE_USER: 32,
ID_GROUP_REMOVED: 64,
ID_GROUP_ADDED_ADMIN_OFMYGROUP: 128,
ID_GROUP_REMOVED_ADMIN_OFMYGROUP: 256,
TYPEDIR_CIRCUITS: 5,