- aggiornata la grafica della Home di RISO
- Profilo Completition - Email Verificata - Invita un Amico (invio di email)
This commit is contained in:
50
src/telegram/handlers/registrationHandler.js
Normal file
50
src/telegram/handlers/registrationHandler.js
Normal file
@@ -0,0 +1,50 @@
|
||||
// telegram/handlers/registrationHandler.js
|
||||
const shared_consts = require('../../tools/shared_nodejs');
|
||||
const { User } = require('../../models/user');
|
||||
const telegrambot = require('../telegram.bot.init'); // per sendMsgTelegramToTheAdminAllSites
|
||||
const printf = require('util').format;
|
||||
|
||||
const InlineConferma = {
|
||||
RISPOSTA_SI: 'SI_',
|
||||
RISPOSTA_NO: 'NO_',
|
||||
};
|
||||
|
||||
async function handleRegistration({ bot, cl, idapp, msg, data, user, userDest, username_action }) {
|
||||
let notifyText = '';
|
||||
|
||||
// NO alla registrazione
|
||||
if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION) {
|
||||
await cl.sendMsg(msg.chat.id, '❌ Registrazione annullata.');
|
||||
notifyText = 'Annullata';
|
||||
return notifyText;
|
||||
}
|
||||
|
||||
// SI alla registrazione standard
|
||||
if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.REGISTRATION) {
|
||||
// set verified (come da tuo codice)
|
||||
await User.setVerifiedReg(idapp, data.username, data.userDest);
|
||||
await cl.sendMsg(msg.chat.id, '✅ Registrazione confermata.');
|
||||
await telegrambot.sendMsgTelegramToTheAdminAllSites(`🆕 Nuova registrazione confermata: ${data.userDest}`);
|
||||
notifyText = 'Registrazione OK';
|
||||
return notifyText;
|
||||
}
|
||||
|
||||
// SI/NO alla REGISTRATION_FRIEND
|
||||
if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.REGISTRATION_FRIEND) {
|
||||
await User.setVerifiedReg(idapp, data.username, data.userDest);
|
||||
await cl.sendMsg(msg.chat.id, '🤝 Conferma amicizia completata!');
|
||||
notifyText = 'Amicizia OK';
|
||||
return notifyText;
|
||||
}
|
||||
|
||||
if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION_FRIEND) {
|
||||
await cl.sendMsg(msg.chat.id, '🚫 Invito amicizia rifiutato.');
|
||||
notifyText = 'Rifiutata';
|
||||
return notifyText;
|
||||
}
|
||||
|
||||
// deleghe future (es. REGISTRATION_TOZOOM gestita in zoomHandler)
|
||||
return 'OK';
|
||||
}
|
||||
|
||||
module.exports = { handleRegistration, InlineConferma };
|
||||
Reference in New Issue
Block a user