- Gruppi (3) - lista degli utenti del gruppo
This commit is contained in:
@@ -345,3 +345,6 @@ Dom 16/01 ORE 22:11: [Inviato a Paolo Arena (paoloar77)]:
|
||||
🔥 Si è appena Registrato "Paoloar775 Paoloar775 (paoloar775)
|
||||
Dom 16/01 ORE 22:14: [Inviato a Paolo Arena (paoloar77)]:
|
||||
🔥 Si è appena Registrato "Pao Are (paoloar775)
|
||||
Lun 07/02 ORE 22:48: [Inviato a undefined undefined (paoloar77)]:
|
||||
🔥 Acaba de registrarse " (paoloar775) (n. %s)"
|
||||
(Invitado de %s)
|
||||
@@ -200,7 +200,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username) {
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req) {
|
||||
|
||||
try {
|
||||
const {User} = require('../models/user');
|
||||
@@ -251,6 +251,7 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username) {
|
||||
listgroups,
|
||||
//listRequestUsersGroup,
|
||||
listSentRequestGroups,
|
||||
mygroups: req.user.profile.mygroups,
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
|
||||
@@ -1275,7 +1275,7 @@ UserSchema.statics.getArrUsernameFromFieldByUsername = async function(
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, myobj).then((ris) => ris ? ris._doc[field][subfield] : []);
|
||||
|
||||
if (arrrec.length > 0) {
|
||||
if (arrrec && arrrec.length > 0) {
|
||||
return arrrec.map(m => m.username);
|
||||
}
|
||||
return [];
|
||||
@@ -1902,8 +1902,12 @@ UserSchema.statics.getNameSurnameByUsername = async function(idapp, username) {
|
||||
return User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {name: 1, surname: 1}).then((rec) => {
|
||||
return (!!rec) ? `${rec.name} ${rec.surname}` : '';
|
||||
}, {username: 1, name: 1, surname: 1}).then((rec) => {
|
||||
let ris = rec.username;
|
||||
if (!!rec && rec.name) {
|
||||
ris = (`${rec.name} ${rec.surname}`)
|
||||
}
|
||||
return (!!rec) ? (`${rec.name} ${rec.surname}`) : '';
|
||||
}).catch((e) => {
|
||||
console.error('getNameSurnameByUsername', e);
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ router.post('/', async (req, res) => {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (tools.blockwords(body.email) || tools.blockwords(body.name) || tools.blockwords(body.surname)) {
|
||||
if (tools.blockwords(body.username) || tools.blockwords(body.email) || tools.blockwords(body.name) || tools.blockwords(body.surname)) {
|
||||
// tools.writeIPToBan(iscritti.ipaddr + ': [' + iscritti.username + '] ' + iscritti.name + ' ' + iscritti.surname);
|
||||
await tools.snooze(5000);
|
||||
return res.status(404).send();
|
||||
|
||||
@@ -191,7 +191,7 @@ router.post('/', async (req, res) => {
|
||||
|
||||
recuser = await User.findByCellAndNameSurname(user.idapp, user.profile.cell,
|
||||
user.name, user.surname);
|
||||
if (recuser) {
|
||||
if (recuser && user.name !== '' && user.surname !== '' && user.profile.cell !== '') {
|
||||
console.log('UTENTE GIA ESISTENTE:\n');
|
||||
console.log(user);
|
||||
// User already registered!
|
||||
@@ -499,7 +499,7 @@ router.post('/groups', authenticate, (req, res) => {
|
||||
locale = req.body.locale;
|
||||
|
||||
|
||||
return MyGroup.getGroupsByUsername(idapp, username).then((ris) => {
|
||||
return MyGroup.getGroupsByUsername(idapp, username, req).then((ris) => {
|
||||
res.send(ris);
|
||||
}).catch((e) => {
|
||||
tools.mylog('ERRORE IN groups: ' + e.message);
|
||||
|
||||
@@ -543,8 +543,8 @@ module.exports = {
|
||||
|
||||
let out = myvar.replace('{urlunsubscribe}', urlunsibscribe);
|
||||
out = out.replace('{email}', mylocalsconf.emailto);
|
||||
out = out.replace('{name}', mylocalsconf.name);
|
||||
out = out.replace('{surname}', mylocalsconf.surname);
|
||||
out = out.replace('{name}', mylocalsconf.name ? mylocalsconf.name : mylocalsconf.username);
|
||||
out = out.replace('{surname}', mylocalsconf.surname ? mylocalsconf.surname : '');
|
||||
|
||||
return out
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ const tools = require('../tools/general');
|
||||
const appTelegram = [tools.FREEPLANET];
|
||||
|
||||
const appTelegram_TEST = [tools.FREEPLANET, tools.PDNM];
|
||||
const appTelegram_DEVELOP = [tools.PDNM];
|
||||
const appTelegram_DEVELOP = [tools.FREEPLANET];
|
||||
|
||||
const appTelegramFinti = ['2', tools.CNM];
|
||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
||||
@@ -482,10 +482,7 @@ const txt_es = {
|
||||
emo.EXCLAMATION_MARK +
|
||||
'\nComprueba en el sitio %s y reescribe el nuevo código de 6 dígitos.',
|
||||
MSG_VERIFY_OK: emoji.get('grinning') +
|
||||
' Bienvenido %s! Ha verificado correctamente con el BOT. ' +
|
||||
'\nSoy su asistente virtual.\nContinúa la guía paso a paso de vuelta a la página web.\n\n' +
|
||||
'Este chat le ayudará a ver rápidamente su pizarra y recibir alertas importantes sobre cómo proceder.\n\nUtilice el menú de abajo para comprobar su situación.' +
|
||||
emo.GREEN_HEART,
|
||||
' Bienvenido %s! Ha verificado correctamente con el BOT. ' + emo.GREEN_HEART,
|
||||
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Error al guardar en el servidor. Inténtalo de nuevo más tarde.',
|
||||
MSG_EXIT_TELEGRAM: 'La cuenta ha sido desconectada de Telegram BOT.',
|
||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
|
||||
@@ -653,6 +650,9 @@ module.exports = {
|
||||
let userdest = mylocalsconf.user.aportador_solidario;
|
||||
let langdest = mylocalsconf.user.lang;
|
||||
let NameFrom = `${mylocalsconf.user.name} ${mylocalsconf.user.surname}`;
|
||||
if (!mylocalsconf.user.name) {
|
||||
NameFrom = `${mylocalsconf.user.username}`;
|
||||
}
|
||||
const index = mylocalsconf.user.index;
|
||||
|
||||
let aportador = '';
|
||||
@@ -670,8 +670,8 @@ module.exports = {
|
||||
userdest) + aportador;
|
||||
aportador = NameFrom;
|
||||
}
|
||||
text = printf(getstr(langdest, 'MSG_APORTADOR_USER_REGISTERED'),
|
||||
`${mylocalsconf.user.name} ${mylocalsconf.user.surname} (${mylocalsconf.user.username})`);
|
||||
let nome = tools.getNomeCognomeEUserNameByUser(mylocalsconf.user);
|
||||
text = printf(getstr(langdest, 'MSG_APORTADOR_USER_REGISTERED'), nome);
|
||||
}
|
||||
|
||||
let addtext = '';
|
||||
@@ -801,8 +801,8 @@ module.exports = {
|
||||
|
||||
if (!!user) {
|
||||
msg = msg.replace('{username}', user.username);
|
||||
msg = msg.replace('{name}', user.name);
|
||||
msg = msg.replace('{surname}', user.surname);
|
||||
msg = msg.replace('{name}', user.name ? user.name : user.username);
|
||||
msg = msg.replace('{surname}', user.surname ? user.surname : '');
|
||||
if (!!user.profile.link_payment)
|
||||
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
|
||||
if (!!user.profile.revolut)
|
||||
@@ -3390,17 +3390,15 @@ if (true) {
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO +
|
||||
shared_consts.CallFunz.REGISTRATION) {
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION) {
|
||||
await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, false);
|
||||
|
||||
const msgOrig = printf(
|
||||
getstr(userDest.lang, 'MSG_APORTADOR_DEST_NOT_CONFIRMED'),
|
||||
`${userDest.name + ' ' + userDest.surname}`);
|
||||
const msgDest = printf(
|
||||
getstr(user.lang, 'MSG_APORTADOR_NOT_CONFIRMED'),
|
||||
`${user.name + ' ' + user.surname}`);
|
||||
const nomeDest = tools.getNomeCognomeEUserNameByUser(userDest);
|
||||
const nomestr = tools.getNomeCognomeEUserNameByUser(user);
|
||||
|
||||
const msgOrig = printf(getstr(userDest.lang, 'MSG_APORTADOR_DEST_NOT_CONFIRMED', nomeDest));
|
||||
const msgDest = printf(getstr(user.lang, 'MSG_APORTADOR_NOT_CONFIRMED'),nomestr);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
|
||||
@@ -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,9 +1364,13 @@ module.exports = {
|
||||
if (myfilter['userId']) {
|
||||
myfilter['userId'] = ObjectID(myfilter['userId']);
|
||||
}
|
||||
if (myfilter['_idOBJ']) {
|
||||
filtriadded.push({_id: ObjectID(myfilter['_idOBJ'])});
|
||||
} else {
|
||||
filtriadded.push(myfilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (params.filtersearch) {
|
||||
filtriadded.push(...params.filtersearch);
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -4,6 +4,8 @@ module.exports = {
|
||||
CHECK_SEE_VIDEO_PRINCIPI: 2,
|
||||
},
|
||||
|
||||
QUERYTYPE_MYGROUP: 1,
|
||||
|
||||
ALL_SAW_AND_ACCEPTED: 3,
|
||||
// ---------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user