Group Page : visibility, some info, members views.

This commit is contained in:
paoloar77
2022-08-10 17:07:02 +02:00
parent 680b353535
commit 07f42398da
7 changed files with 93 additions and 18 deletions

View File

@@ -340,23 +340,29 @@ router.post('/settable', authenticate, async (req, res) => {
let typeid = 0;
let groupnameDest = '';
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
typeid = (params.table === shared_consts.TABLES_MYGOODS) ? shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD : shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE
setnotif = true;
}
if (isnewrec) {
// New Record created
if (shared_consts.TABLES_EVENTS_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS;
typeid = shared_consts.TypeNotifs.ID_EVENTS_NEW_REC;
setnotif = true;
}
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
typeid = (params.table === shared_consts.TABLES_MYGOODS)
? shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD
: shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE
setnotif = true;
}
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
groupnameDest = myrec ? myrec.groupname : '';
setnotif = true;
if (shared_consts.TABLES_EVENTS_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS;
typeid = shared_consts.TypeNotifs.ID_EVENTS_NEW_REC;
setnotif = true;
}
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
groupnameDest = myrec ? myrec.groupname : '';
setnotif = true;
}
}
if (setnotif) {

View File

@@ -44,6 +44,14 @@ router.post('/load', authenticate, async (req, res) => {
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username);
let data = await MyGroup.findOne({idapp, groupname}, whatshow).lean();
let cities = [];
if (data) {
cities = await MyGroup.extractCitiesName(idapp, data._id);
if (cities && cities.length > 0) {
cities = cities[0].mycities;
}
}
data = await getGroupRecAdminsInfo(idapp, data);
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
@@ -56,9 +64,9 @@ router.post('/load', authenticate, async (req, res) => {
},
},
whatshowUsers,
);
).lean();
res.send({mygroup: data, users_in_group});
res.send({mygroup: data, users_in_group, cities});
} catch (e) {
console.error('Error in MyGroups', e);