Mostrare il Bene, Servizio, solo ai Propri Gruppi.

Nella pagina profilo, i "Gruppi" personali non si vedevano !
This commit is contained in:
Paolo Arena
2022-06-16 20:34:42 +02:00
parent d8aa8e546e
commit c3b0a1f417
17 changed files with 170 additions and 52 deletions

View File

@@ -837,7 +837,7 @@ module.exports = {
const telegrambot = require('../telegram/telegrambot');
const user = await User.findOne({idapp, username}, {_id: 1, username:1, lang: 1}).lean();
const user = await User.findOne({idapp, username}, {_id: 1, username: 1, lang: 1}).lean();
if (!user)
return;
@@ -892,7 +892,7 @@ module.exports = {
const idtelegram = await User.TelegIdById(idapp, userId);
const msgteleg = objmsg.descr + (msgextrateleg ? '\n' + msgextrateleg : '')
const msgteleg = objmsg.descr + (msgextrateleg ? '\n' + msgextrateleg : '');
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, msgteleg);
}
},
@@ -950,7 +950,8 @@ module.exports = {
objmsg.tag = 'reqgroups';
sendnotif = false; // non lo rimandare 2 volte !
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, groupname, group._id);
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, groupname,
group._id);
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
objmsg.descr = printf(this.get__('RICHIESTA_BLOCCO_GRUPPO', lang),
@@ -1366,7 +1367,7 @@ module.exports = {
return query;
},
getQueryTable: function(idapp, params) {
getQueryTable: function(idapp, params, user) {
if (typeof params.startRow !== 'number') {
throw new Error('startRow must be number');
@@ -1431,7 +1432,7 @@ module.exports = {
filtriadded.push({verified_email: false});
if (params.filterand.includes(shared_consts.FILTER_USER_NO_VERIFIED_APORTADOR))
filtriadded.push({
verified_by_aportador: {$exists: false},
verified_by_aportador: {$exists: false},
});
if (params.filterand.includes(shared_consts.FILTER_USER_WITHOUT_USERNAME_TELEGRAM))
filtriadded.push({
@@ -1515,6 +1516,7 @@ module.exports = {
}
if (params.filtercustom) {
let condition = {};
for (const myfilter of params.filtercustom) {
if (myfilter['userId']) {
myfilter['userId'] = ObjectID(myfilter['userId']);
@@ -1524,13 +1526,15 @@ module.exports = {
} else if (myfilter['dateTimeStart']) {
const gte = myfilter['dateTimeStart'].$gte;
const lte = myfilter['dateTimeStart'].$lte;
let condition = {
condition = {
dateTimeStart: {
$gte: new Date(gte),
$lte: new Date(lte),
},
};
filtriadded.push(condition);
} else if (myfilter.hasOwnProperty('pub_to_share')) {
// non aggiungere niente
} else {
filtriadded.push(myfilter);
}
@@ -1541,7 +1545,7 @@ module.exports = {
for (let ind = 0; ind < params.filter_gte.length; ind++) {
for (const [key, value] of Object.entries(params.filter_gte[ind])) {
if (value > 0) {
let condition = {}
let condition = {};
condition[key] = {$gte: value};
filtriadded.push(condition);
}
@@ -1671,6 +1675,38 @@ module.exports = {
query.push({$match: {$and: params.filtersearch2}});
}
}
if (params.filtercustom) {
let condition = {};
for (const myfilter of params.filtercustom) {
if (myfilter['pub_to_share'] === shared_consts.PUBTOSHARE.ONLY_GROUPS_FOLLOW) {
let arraygroups = [];
if (user && user.profile.mygroups) {
arraygroups = user.profile.mygroups.map(rec => rec.groupname);
}
// prendere i gruppi dell'utente
// Cerca tra i gruppi di ogni record, se combaciano almeno 1
condition = {
'profile.mygroups':
{
$elemMatch: {
groupname: {$in: arraygroups},
},
},
};
query.push({$match: {$and: [condition]}});
}
}
}
if (params.filtersearch3or) {
if (params.filtersearch3or.length > 0) {
query.push({$match: {$or: params.filtersearch3or}});
@@ -1722,8 +1758,8 @@ module.exports = {
},
async executeQueryTable(mythistable, idapp, params) {
let query = this.getQueryTable(idapp, params);
async executeQueryTable(mythistable, idapp, params, user) {
let query = this.getQueryTable(idapp, params, user);
try {
// console.log('query', query);
@@ -2784,23 +2820,23 @@ module.exports = {
if (u_tg) {
msg += `<br>Profilo su Telegram [${name_tg} ${surname_tg}]:<br>https://t.me/${u_tg}`;
}
}catch (e) {
} catch (e) {
console.error('getUserInfoMsg', e);
}
return msg;
},
getlinkRequestNewPassword: function (idapp, email, tokenforgot) {
const strlinkreg = this.getHostByIdApp(idapp) + process.env.LINK_UPDATE_PASSWORD + `?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
getlinkRequestNewPassword: function(idapp, email, tokenforgot) {
const strlinkreg = this.getHostByIdApp(idapp) + process.env.LINK_UPDATE_PASSWORD +
`?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
return strlinkreg;
},
execScript: function(idapp, msg, script, testo) {
const { exec } = require("child_process");
const {exec} = require('child_process');
const telegrambot = require('../telegram/telegrambot');
const idchat = msg.chat.id;
console.log(testo + ' (' + script + ')');
@@ -2821,6 +2857,6 @@ module.exports = {
// console.log(` ... stdout: ${stdout}`);
telegrambot.local_sendMsgTelegramByIdTelegram(idapp, idchat, stdout);
});
}
},
};