Group Page : visibility, some info, members views.
This commit is contained in:
@@ -181,6 +181,7 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CitySchema.statics.findAllIdApp = async function(idapp) {
|
CitySchema.statics.findAllIdApp = async function(idapp) {
|
||||||
const myfind = {};
|
const myfind = {};
|
||||||
|
|
||||||
|
|||||||
@@ -368,6 +368,54 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MyGroupSchema.statics.extractCitiesName = async function(idapp, id) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
let aggr1 = [
|
||||||
|
{
|
||||||
|
$match: {idapp, _id: id},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'cities',
|
||||||
|
localField: 'idCity',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'mycities',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'$replaceRoot': {
|
||||||
|
'newRoot': {
|
||||||
|
'$mergeObjects': [
|
||||||
|
{
|
||||||
|
'$arrayElemAt': [
|
||||||
|
'$mycities',
|
||||||
|
0,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'$$ROOT',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
"mycities.comune": 1,
|
||||||
|
"mycities.prov": 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
ris = await this.aggregate(aggr1);
|
||||||
|
|
||||||
|
return ris;
|
||||||
|
}catch (e) {
|
||||||
|
console.error('e', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
||||||
|
|
||||||
module.exports = {MyGroup};
|
module.exports = {MyGroup};
|
||||||
|
|||||||
@@ -1925,6 +1925,9 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD
|
|||||||
|
|
||||||
} else if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP) {
|
} else if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP) {
|
||||||
|
|
||||||
|
// Remove if is also an Admin
|
||||||
|
await MyGroup.removeAdminOfMyGroup(idapp, usernameOrig, groupnameDest);
|
||||||
|
|
||||||
ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me
|
||||||
console.log('ris', ris);
|
console.log('ris', ris);
|
||||||
|
|
||||||
@@ -2059,6 +2062,9 @@ UserSchema.statics.getWhatToShow_IfFriends = async function(idapp, username) {
|
|||||||
'profile.sex': 1,
|
'profile.sex': 1,
|
||||||
'profile.born_province': 1,
|
'profile.born_province': 1,
|
||||||
'profile.born_country': 1,
|
'profile.born_country': 1,
|
||||||
|
reported: 1,
|
||||||
|
date_report: 1,
|
||||||
|
username_who_report: 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
groups: 1,
|
groups: 1,
|
||||||
friends: 1,
|
friends: 1,
|
||||||
|
|||||||
@@ -340,23 +340,29 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
let typeid = 0;
|
let typeid = 0;
|
||||||
let groupnameDest = '';
|
let groupnameDest = '';
|
||||||
|
|
||||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
|
if (isnewrec) {
|
||||||
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
|
// New Record created
|
||||||
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_EVENTS_NOTIFICATION.includes(params.table)) {
|
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
|
||||||
typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS;
|
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
|
||||||
typeid = shared_consts.TypeNotifs.ID_EVENTS_NEW_REC;
|
typeid = (params.table === shared_consts.TABLES_MYGOODS)
|
||||||
setnotif = true;
|
? 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)) {
|
if (shared_consts.TABLES_EVENTS_NOTIFICATION.includes(params.table)) {
|
||||||
typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
|
typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS;
|
||||||
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
|
typeid = shared_consts.TypeNotifs.ID_EVENTS_NEW_REC;
|
||||||
groupnameDest = myrec ? myrec.groupname : '';
|
setnotif = true;
|
||||||
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) {
|
if (setnotif) {
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ router.post('/load', authenticate, async (req, res) => {
|
|||||||
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username);
|
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username);
|
||||||
let data = await MyGroup.findOne({idapp, groupname}, whatshow).lean();
|
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);
|
data = await getGroupRecAdminsInfo(idapp, data);
|
||||||
|
|
||||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||||
@@ -56,9 +64,9 @@ router.post('/load', authenticate, async (req, res) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
whatshowUsers,
|
whatshowUsers,
|
||||||
);
|
).lean();
|
||||||
|
|
||||||
res.send({mygroup: data, users_in_group});
|
res.send({mygroup: data, users_in_group, cities});
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error in MyGroups', e);
|
console.error('Error in MyGroups', e);
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ myLoad().then(ris => {
|
|||||||
if (app.get('env') === 'development') {
|
if (app.get('env') === 'development') {
|
||||||
|
|
||||||
app.use(function(err, req, res, next) {
|
app.use(function(err, req, res, next) {
|
||||||
console.log('Error: ', err.message);
|
console.log('Server Error: ', err.message);
|
||||||
// console.trace();
|
// console.trace();
|
||||||
res.status(err.status || 500).send({error: err.message});
|
res.status(err.status || 500).send({error: err.message});
|
||||||
// res.render('error', {
|
// res.render('error', {
|
||||||
|
|||||||
@@ -172,6 +172,12 @@ module.exports = {
|
|||||||
VISIB_ONLY_MANAGER: 2,
|
VISIB_ONLY_MANAGER: 2,
|
||||||
VISIB_ONLY_ADMIN: 4,
|
VISIB_ONLY_ADMIN: 4,
|
||||||
|
|
||||||
|
Visibility_Group: {
|
||||||
|
PRIVATE: 1,
|
||||||
|
HIDDEN: 2,
|
||||||
|
// PASSWORD: 4,
|
||||||
|
},
|
||||||
|
|
||||||
BOTTYPE_NONE: 0,
|
BOTTYPE_NONE: 0,
|
||||||
BOTTYPE_PAGE: 1,
|
BOTTYPE_PAGE: 1,
|
||||||
BOTTYPE_LINK: 2,
|
BOTTYPE_LINK: 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user