Aggiunte opzioni per il Gestore: richiede che l'invitante confermi la Reg, Notifica sul BOT , Notifica all'Admin la Reg.

This commit is contained in:
paoloar77
2022-02-27 16:56:02 +01:00
parent 2749506de7
commit 8d98726f1f
9 changed files with 175 additions and 85 deletions

View File

@@ -15,6 +15,8 @@ const {CalZoom} = require('../models/calzoom');
const {MyBot} = require('../models/bot');
const shared_consts = require('../tools/shared_nodejs');
const server_constants = require('../tools/server_constants');
// const {ListaIngresso} = require('../models/listaingresso');
const {MsgTemplate} = require('../models/msg_template');
@@ -728,24 +730,32 @@ module.exports = {
let text = '';
if (phase === this.phase.REGISTRATION) {
if (userdest) {
NameFrom = await User.getNameSurnameByUsername(mylocalsconf.idapp, userdest, true) + aportador;
aportador = NameFrom;
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp, shared_consts.ConfSite.Notif_Reg_Bot)) {
if (userdest) {
NameFrom = await User.getNameSurnameByUsername(mylocalsconf.idapp,
userdest, true) + aportador;
aportador = NameFrom;
}
const numutenti = await User.getNumUsers(mylocalsconf.idapp);
let nome = tools.getNomeCognomeEUserNameByUser(mylocalsconf.user);
text = printf(getstr(langdest, 'MSG_APORTADOR_USER_REGISTERED'), nome,
numutenti, aportador);
}
const numutenti = await User.getNumUsers(mylocalsconf.idapp);
let nome = tools.getNomeCognomeEUserNameByUser(mylocalsconf.user);
text = printf(getstr(langdest, 'MSG_APORTADOR_USER_REGISTERED'), nome, numutenti, aportador);
}
let addtext = '';
let rismsg = null;
if (!!mylocalsconf.user.aportador_solidario) {
addtext = '[Inviato a ' + NameFrom + ']:' + '\n';
rismsg = await this.sendMsgTelegram(mylocalsconf.idapp, userdest, text);
}
if (text) {
if (!!mylocalsconf.user.aportador_solidario) {
addtext = '[Inviato a ' + NameFrom + ']:' + '\n';
rismsg = await this.sendMsgTelegram(mylocalsconf.idapp, userdest, text);
}
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text, false, null, userdest);
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp,
addtext + text, false, null, userdest);
}
if (phase === this.phase.REGISTRATION) {
await this.askConfirmationUserRegistration(mylocalsconf.idapp, shared_consts.CallFunz.REGISTRATION,
@@ -1189,6 +1199,12 @@ module.exports = {
},
reloadSites: async function() {
tools.loadApps();
},
setVerifiedReg: async function (idapp, lang, usernameorig, usernameDest) {
try {
await User.setVerifiedByAportador(idapp, usernameDest, true);
@@ -1212,35 +1228,40 @@ module.exports = {
let domanda = '';
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
const name = myuser.username + (myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '')
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' + myuser.username;
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` + myuser.email);
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
keyb = cl.getInlineKeyboard(myuser.lang, [
{
text: '✅ Abilita ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_SI +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
{
text: '🚫 Rifiuta ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_NO +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
]);
if (notask_verif) {
// Non chiedi la verifica Registrazione
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest, myuser.username);
} else {
const name = myuser.username + (myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '')
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' + myuser.username;
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` +
myuser.email);
keyb = cl.getInlineKeyboard(myuser.lang, [
{
text: '✅ Abilita ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_SI +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
{
text: '🚫 Rifiuta ' + myuser.username,
callback_data: InlineConferma.RISPOSTA_NO +
shared_consts.CallFunz.REGISTRATION + tools.SEP +
myuser.username + tools.SEP + userDest,
},
]);
}
}
// INvia Msg
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda,
undefined, undefined, true, keyb);bot
if (notask_verif) {
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest, myuser.username);
// Invia Msg
if (domanda) {
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda, undefined, undefined, true, keyb);
}
} catch (e) {