// 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 };