"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.)"
This commit is contained in:
paoloar77
2022-03-04 22:30:50 +01:00
parent dba9a4ea70
commit 4bc406fba6
5 changed files with 247 additions and 153 deletions

View File

@@ -495,7 +495,7 @@ const txt = {
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Si è appena Registrato "%s" (n. %s)\nInvitato da %s',
MSG_APORTADOR_ASK_CONFIRM: '🆕💥 🧍‍♂️ Abilita Nuova Registrazione: %s',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Abilitato correttamente!',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Abilitato correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei stato Abilitato correttamente da %s!\n' +
'Vai sulla App oppure clicca qui per entrare\n👉🏻 %s',
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
@@ -917,6 +917,72 @@ module.exports = {
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
},
askConfirmationUserRegistration: async function(
idapp, myfunc, myuser, usernametelegram = '', name_telegram = '',
surname_telegram = '') {
const cl = getclTelegByidapp(idapp);
try {
const userDest = myuser.aportador_solidario;
const langdest = myuser.lang;
let keyb = null;
let domanda = '';
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
if (notask_verif) {
// Non chiedi la verifica Registrazione
setVerifiedReg(myuser.idapp, myuser.lang, myuser.username, userDest);
} 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><br>Profilo su APP: ${linkuserprof}<br>Email: ` +
myuser.email);
if (usernametelegram) {
domanda += '<br>Profilo su Telegram [' + name_telegram + ' ' +
surname_telegram + ']:<br>' + 'https://t.me/' +
usernametelegram;
}
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
if (domanda) {
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
await local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda,
undefined, undefined, true, keyb);
}
} catch (e) {
console.error('Error askConfirmationUserRegistration', e);
}
},
sendMsgTelegramToTheManagers: async function(
idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
@@ -1365,78 +1431,13 @@ async function setVerifiedReg(idapp, lang, usernameorig, usernameDest) {
shared_consts.FRIENDSCMD.SETFRIEND);
const msgDest = printf(getstr(lang, 'MSG_APORTADOR_CONFIRMED'),
`${usernameDest}`);
await local_sendMsgTelegram(idapp, usernameorig, msgDest);
`${usernameorig}`, usernameDest);
await local_sendMsgTelegram(idapp, usernameDest, msgDest);
} catch (e) {
console.log('e', e);
}
}
async function askConfirmationUserRegistration(
idapp, myfunc, myuser, usernametelegram = '', name_telegram = '',
surname_telegram = '') {
const cl = getclTelegByidapp(idapp);
try {
const userDest = myuser.aportador_solidario;
const langdest = myuser.lang;
let keyb = null;
let domanda = '';
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
if (notask_verif) {
// Non chiedi la verifica Registrazione
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><br>Profilo su APP: ${linkuserprof}<br>Email: ` +
myuser.email);
if (usernametelegram) {
domanda += '<br>Profilo su Telegram [' + name_telegram + ' ' +
surname_telegram + ']:<br>' + 'https://t.me/' + usernametelegram;
}
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
if (domanda) {
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
await local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda,
undefined, undefined, true, keyb);
}
} catch (e) {
console.error('Error askConfirmationUserRegistration', e);
}
}
function getusernameByUser(idapp, msg) {
let username = '';
let rec = this.getRecInMem(msg);
@@ -1727,7 +1728,7 @@ class Telegram {
printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
if (!rec.user.verified_by_aportador) {
askConfirmationUserRegistration(this.idapp,
this.askConfirmationUserRegistration(this.idapp,
shared_consts.CallFunz.REGISTRATION, rec.user,
msg.from.username || '', msg.from.first_name || '',
msg.from.last_name || '');
@@ -2713,7 +2714,7 @@ class Telegram {
tools.getHostByIdApp(this.idapp)));
if (msg.from.username) {
askConfirmationUserRegistration(this.idapp,
this.askConfirmationUserRegistration(this.idapp,
shared_consts.CallFunz.REGISTRATION, recuser,
msg.from.username || '', msg.from.first_name || '',
msg.from.last_name || '');
@@ -3538,13 +3539,12 @@ class Telegram {
async sendMsgLog(id, text, menu, form, msg_id, chat_id, ripr_menuPrec) {
const rec = this.getRecInMemById(id);
const username = rec ? rec.username : ''
const username = rec ? rec.username_bo : '';
console.log('Msg inviato a ', username, text);
this.sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec)
console.log('Msg inviato a ', username, '(', id, ')', text);
this.sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec);
}
getmenuKey(mymenu, lang) {
let mymenuout = null;
try {
@@ -3845,16 +3845,18 @@ if (true) {
await User.setZoomPresenza(user.idapp, user._id, false);
} else if (data.action === InlineConferma.RISPOSTA_SI +
shared_consts.CallFunz.REGISTRATION) {
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.REGISTRATION) {
const changed = await myclTelegram.setCmdToUsername(rec,
data.username,
Cmd.VALIDATE_REGISTRATION, true);
await User.setFriendsCmd(user.idapp, data.username,
userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
if (changed) {
await User.setFriendsCmd(user.idapp, data.username,
userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
await User.setaportador_solidario(user.idapp, data.username,
userDest.username);
const msgOrig = printf(
getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'),
`${userDest.username}`, tools.getHostByIdApp(user.idapp));
@@ -3870,26 +3872,29 @@ if (true) {
} else if (data.action === InlineConferma.RISPOSTA_NO +
shared_consts.CallFunz.REGISTRATION) {
const changed = await myclTelegram.setCmdToUsername(rec,
data.username,
Cmd.VALIDATE_REGISTRATION, false);
if (userDest.username === user.aportador_solidario) {
const changed = await myclTelegram.setCmdToUsername(rec,
data.username,
Cmd.VALIDATE_REGISTRATION, false);
if (changed) {
const nomeDest = tools.getNomeCognomeEUserNameByUser(
userDest);
const nomestr = tools.getNomeCognomeEUserNameByUser(user);
if (changed) {
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);
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);
await local_sendMsgTelegram(user.idapp, data.username,
msgOrig);
await local_sendMsgTelegram(user.idapp, data.userDest,
msgDest);
}
}
}
}