vedere le Richieste di Fiducia solo se si è verificati Telegram

Corretto il mio account che doveva confermare in automatico... non lo faceva...
"Riregistrarsi se l'invitante non ha ancora confermato l'invito.
Annullo la richiesta precedente. (inviando un msg di annullamento. (Si è già registrato con un alto invito.)"
CMyEditor: non posso andare in edit sul HTML (nella table)
Aggiornare il msg di benvenuto ! (prendere da msgtemplate)
Dal Profilo: è possibile inviarsi il messaggio da condividere agli Amici
Visualizzare la data d'inserimento dell'annuncio e l'ultima modifica fatta
Link alla pagina di un Evento o Bene o Servizio !
Se aggiornamento: mettere messaggio che dice di chiudere e riaprire per aggiornare.
Quando un utente chiede di entrare nel Gruppo, mettere l'abilitazione anche su Telegram. (e correggere il msg)
This commit is contained in:
paoloar77
2022-03-06 00:48:33 +01:00
parent 4bc406fba6
commit 466fdd597d
14 changed files with 686 additions and 784 deletions

View File

@@ -123,6 +123,8 @@ const textlang = {
'MSG_SEND_FROM': 'Msg Inviato da',
'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!',
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s',
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
},
@@ -190,6 +192,11 @@ const textlang = {
'NAVE': 'NAVE',
'MSG_SEND_FROM': 'Mensaje enviado por',
'ZOOM_CONFERMATO': '¡Se ha confirmado que ha visto la Video Conferencia de Bienvenida!',
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s',
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
},
enUs: {
'partecipanti': 'participants',
@@ -249,6 +256,11 @@ const textlang = {
'NAVE': 'SHIP',
'MSG_SEND_FROM': 'Msg sent by',
'ZOOM_CONFERMATO': 'You have been confirmed to have seen the Welcome Video Conference!',
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s',
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
},
fr: {
'L\'Email è già stata Verificata': 'Le courrier électronique a déjà été vérifié',
@@ -313,6 +325,11 @@ const textlang = {
'NAVE': 'NAVIRE',
'MSG_SEND_FROM': 'Message envoyé par',
'ZOOM_CONFERMATO': 'Vous avez été confirmé comme ayant vu la vidéoconférence de bienvenue !',
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s',
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
},
pt: {
'L\'Email è già stata Verificata': '',
@@ -375,6 +392,11 @@ const textlang = {
'NAVE': 'NAVE',
'MSG_SEND_FROM': 'Mensagem enviada por',
'ZOOM_CONFERMATO': 'Foi-lhe confirmado que assistiu à Conferência de Vídeo de Boas-vindas!',
'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s',
'ACCETTATO_SUL_GRUPPO': 'Sei stato accettato da %s a far parte del Gruppo %s',
'ACCETTATO_NOTIFICA_ADMINS': 'l\'utente %s è stato accettato a far parte del Gruppo %s',
'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s',
'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s',
},
};
@@ -702,8 +724,7 @@ module.exports = {
});
},
sendNotificationToUser: function(
userId, title, content, openUrl, openUrl2, tag, actions) {
sendNotificationToUser: function(userId, title, content, openUrl, openUrl2, tag, actions) {
let payload = {
actions,
@@ -850,11 +871,30 @@ module.exports = {
},
sendNotificationByGroupname: async function(idapp, groupname, cmd, telegram) {
sendNotifAndMsgTelegram: async function(idapp, userId, objmsg, telegram, msgextrateleg) {
if (userId) {
this.sendNotificationToUser(userId, objmsg.title, objmsg.descr, objmsg.openUrl, '', objmsg.tag, objmsg.actions);
}
if (telegram) {
var {User} = require('../models/user');
const telegrambot = require('../telegram/telegrambot');
const idtelegram = await User.TelegIdById(idapp, userId);
const msgteleg = objmsg.descr + (msgextrateleg ? '\n' + msgextrateleg : '')
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, msgteleg);
}
},
sendNotificationByGroupname: async function(idapp, usernameOrig, groupname, cmd, telegram) {
var {User} = require('../models/user');
var {MyGroup} = require('../models/mygroup');
const telegrambot = require('../telegram/telegrambot');
const group = await MyGroup.findOne({idapp, groupname},
{_id: 1, admins: 1});
if (!group)
@@ -864,50 +904,58 @@ module.exports = {
const arrusernameAdmins = group.admins;
for (const arradmins of arrusernameAdmins) {
const myuser = await User.findOne({idapp, username: usernameOrig}).lean();
let struserinfomsg = this.getUserInfoMsg(idapp, myuser);
let objmsg = {
title: this.getNomeAppByIdApp(idapp),
descr: '',
openUrl: '/',
tag: '',
actions: [],
};
for (const singleadmin of arrusernameAdmins) {
try {
if (arradmins.username) {
const user = await User.findOne({idapp, username: arradmins.username},
if (singleadmin.username) {
const user = await User.findOne({idapp, username: singleadmin.username},
{_id: 1, lang: 1});
if (user) {
let userId = user._id;
let lang = user.lang;
let title = this.getNomeAppByIdApp(idapp);
let descr = '';
let openUrl = '/';
let tag = '';
let actions = [];
let sendnotif = true;
if (cmd) {
if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
descr = printf(this.get__('RICHIESTA_GRUPPO', lang), groupname,
arradmins.username);
openUrl = '/grp/' + groupname;
tag = 'reqgroups';
if (cmd === shared_consts.GROUPSCMD.SETGROUP) {
objmsg.descr = printf(this.get__('ACCETTATO_NOTIFICA_ADMINS', lang), singleadmin.username, groupname);
objmsg.openUrl = '/grp/' + groupname;
objmsg.tag = 'addgroups';
} else if (cmd === shared_consts.GROUPSCMD.REQGROUP) {
objmsg.descr = printf(this.get__('RICHIESTA_GRUPPO', lang), groupname,
singleadmin.username);
objmsg.openUrl = '/grp/' + groupname;
objmsg.tag = 'reqgroups';
sendnotif = false; // non lo rimandare 2 volte !
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, {groupid: group._id, groupname });
} else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) {
descr = printf(this.get__('RICHIESTA_BLOCCO_GRUPPO', lang),
groupname, arradmins.username);
openUrl = '/grp/' + groupname;
tag = 'blockgroups';
objmsg.descr = printf(this.get__('RICHIESTA_BLOCCO_GRUPPO', lang),
groupname, singleadmin.username);
objmsg.openUrl = '/grp/' + groupname;
objmsg.tag = 'blockgroups';
}
}
if (userId) {
this.sendNotificationToUser(userId, title, descr, openUrl, '',
tag,
actions);
if (sendnotif && objmsg.descr) {
await this.sendNotifAndMsgTelegram(idapp, userId, objmsg, telegram, struserinfomsg);
}
if (telegram) {
const telegrambot = require('../telegram/telegrambot');
const idtelegram = await User.TelegIdByUsername(idapp,
arradmins.username);
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram,
descr);
}
}
}
} catch (e) {
@@ -915,6 +963,16 @@ module.exports = {
}
}
if (cmd === shared_consts.GROUPSCMD.SETGROUP) {
const reclang = await User.getRecLangAndIdByUsername(idapp, usernameOrig);
objmsg.descr = printf(this.get__('ACCETTATO_SUL_GRUPPO', reclang.lang), usernameOrig, groupname);
objmsg.openUrl = '/grp/' + groupname;
objmsg.tag = 'addgroups';
// Send to User:
await this.sendNotifAndMsgTelegram(idapp, reclang._id, objmsg, telegram);
}
},
// **********************
@@ -1063,11 +1121,11 @@ module.exports = {
return '';
},
getLinkUserProfile: function (idapp, username) {
getLinkUserProfile: function(idapp, username) {
return tools.getHostByIdApp(idapp) + '/my/' + username;
},
getLinkEditUserProfile: function (idapp) {
getLinkEditUserProfile: function(idapp) {
return tools.getHostByIdApp(idapp) + '/editprofile';
},
@@ -2627,13 +2685,76 @@ module.exports = {
try {
return download.image({
url,
dest: filepath
dest: filepath,
});
}catch (e) {
} catch (e) {
console.error('Err download image', e);
return false;
}
},
convertSpecialTags(user, msg) {
try {
if (!!user) {
msg = msg.replace('{username}', user.username);
msg = msg.replace('{name}', user.name ? user.name : user.username);
msg = msg.replace('{surname}', user.surname ? user.surname : '');
msg = msg.replace('{aportador_solidario}',
user.aportador_solidario ? user.aportador_solidario : '');
if (!!user.profile.link_payment)
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
if (!!user.profile.revolut)
msg = msg.replace('{revolut}', user.profile.revolut);
if (!!user.profile.payeer_id)
msg = msg.replace('{payeer_id}', user.profile.payeer_id);
if (!!user.profile.advcash_id)
msg = msg.replace('{advcash_id}', user.profile.advcash_id);
if (!!user.profile.email_paypal)
msg = msg.replace('{email_paypal}', user.profile.email_paypal);
if (!!user.profile.note_payment)
msg = msg.replace('{note_payment}', user.profile.note_payment);
}
// const cl = getclTelegByidapp(user.idapp);
msg = msg.replace('{link_chathelp}', this.HELP_CHAT);
} catch (e) {
console.log(e);
}
return msg;
},
getUserInfoMsg: function(idapp, myuser, usernametelegram = '', name_telegram = '',
surname_telegram = '') {
let msg = '';
try {
const name = myuser.username +
(myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '');
const linkuserprof = this.getHostByIdApp(idapp) + '/my/' +
myuser.username;
msg = `<br>Username: <b>${name}</b><br>Profilo su APP: ${linkuserprof}<br>Email: ${myuser.email}`;
let u_tg = myuser.profile && myuser.profile.hasOwnProperty('username_telegram') ? myuser.profile.username_telegram : usernametelegram;
let name_tg = myuser.profile && myuser.profile.hasOwnProperty('firstname_telegram')
? myuser.profile.firstname_telegram
: name_telegram;
let surname_tg = myuser.profile && myuser.profile.hasOwnProperty('lastname_telegram')
? myuser.profile.lastname_telegram
: surname_telegram;
if (u_tg) {
msg += '<br>Profilo su Telegram [' + name_tg + ' ' + surname_tg + ']:<br>' + 'https://t.me/' + u_tg;
}
}catch (e) {
console.error('getUserInfoMsg', e);
}
return msg;
},
};