- Gruppi (3) - lista degli utenti del gruppo

This commit is contained in:
paoloar77
2022-02-08 23:14:08 +01:00
parent 16664f7be7
commit 8ed9bd941f
9 changed files with 129 additions and 36 deletions

View File

@@ -820,14 +820,15 @@ module.exports = {
let actions = [];
if (cmd) {
if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang) , username);
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), username);
openUrl = '/my/' + username;
tag = 'reqfriends';
}
}
if (userId) {
this.sendNotificationToUser(userId, title, descr, openUrl, '', tag, actions);
this.sendNotificationToUser(userId, title, descr, openUrl, '', tag,
actions);
}
if (telegram) {
@@ -845,7 +846,8 @@ module.exports = {
var {User} = require('../models/user');
var {MyGroup} = require('../models/mygroup');
const group = await MyGroup.findOne({idapp, groupname}, {_id: 1, admins: 1});
const group = await MyGroup.findOne({idapp, groupname},
{_id: 1, admins: 1});
if (!group)
return;
@@ -891,13 +893,15 @@ module.exports = {
if (telegram) {
const telegrambot = require('../telegram/telegrambot');
const idtelegram = await User.TelegIdByUsername(idapp, arradmins.username);
const idtelegram = await User.TelegIdByUsername(idapp,
arradmins.username);
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr);
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram,
descr);
}
}
}
}catch (e){
} catch (e) {
console.error('sendNotificationByGroupname', e);
}
}
@@ -1360,7 +1364,11 @@ module.exports = {
if (myfilter['userId']) {
myfilter['userId'] = ObjectID(myfilter['userId']);
}
filtriadded.push(myfilter);
if (myfilter['_idOBJ']) {
filtriadded.push({_id: ObjectID(myfilter['_idOBJ'])});
} else {
filtriadded.push(myfilter);
}
}
}
@@ -1399,13 +1407,81 @@ module.exports = {
if (numrowend < 0)
numrowend = 1;
if (params.querytype === shared_consts.QUERYTYPE_MYGROUP) {
// query.push({'$addFields': {'myid': {'$toObjectId': params.myid}}});
/*query.push({
$match: {
$and: [
{idapp},
{'_id': '$myid'},
],
},
});
*/
query.push({
$match: {
$expr: {
$eq: [
'$_id',
{
'$toObjectId': params.myid,
},
],
},
},
});
query.push({$project: {req_users: 1}});
const qa1 = this.getLookup(
{
lk_tab: 'users',
lk_LF: 'req_users.username',
lk_FF: 'username',
lk_as: 'user',
}, 0, {
'user.idapp': 1,
'user.username': 1,
'user.profile.img': 1,
'user.profile.qualifica': 1,
});
if (qa1) query = [...query, ...qa1];
query.push({$unwind: '$user'});
query.push({
$match: {
$and: [
{'user.idapp': idapp},
],
},
});
query.push({
$replaceRoot: {
newRoot: '$user',
},
},
);
}
if (newvers) {
// NUOVA VERSIONE
let proj = params.lookup2 ? params.lookup2.lk_proj : null;
if (params.proj0) {
query.push({$project: params.proj0});
}
if (params.unwind0) {
query.push({$unwind: params.unwind0});
}
const q1 = this.getLookup(params.lookup1, 1, proj);
if (q1) query = [...query, ...q1];
if (params.unwind1) {
query.push({$unwind: params.unwind1});
}
const q2 = this.getLookup(params.lookup2, 2, proj);
if (q2) query = [...query, ...q2];
@@ -2116,7 +2192,7 @@ module.exports = {
},
isFileExists(filename) {
return fs.existsSync(filename)
return fs.existsSync(filename);
},
getiPAddressUser(req) {
@@ -2243,7 +2319,7 @@ module.exports = {
},
blockwords(mystr) {
const arrwords = ['http', 'Http', 'Asasfasfas', '://', 'mrbit'];
const arrwords = ['http', 'Http', 'Asasfasfas', '://', 'mrbit', 'admin', 'info', 'superuser'];
for (const myword of arrwords) {
if (mystr.includes(myword)) {
return true;
@@ -2360,4 +2436,13 @@ module.exports = {
return count;
},
getNomeCognomeEUserNameByUser(user) {
let nome = `${user.name} ${user.surname} (${user.username})`
if (!user.name) {
nome = user.username;
}
return nome;
},
};