- Registrazione: conferma Abilitazione da Telegram
- Richiesta Amicizia
This commit is contained in:
@@ -52,7 +52,7 @@ const BotSchema = new Schema({
|
||||
});
|
||||
|
||||
BotSchema.statics.getFieldsForSearch = function() {
|
||||
return [];
|
||||
return [{ field: 'label', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
BotSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
@@ -330,12 +330,13 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
const mytable = getTableByTableName(params.table);
|
||||
const mydata = req.body.data;
|
||||
|
||||
const fieldsvalue = {'ALL': 1};
|
||||
|
||||
mydata.idapp = req.user.idapp;
|
||||
|
||||
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) &&
|
||||
!User.isEditor(req.user.perm) && !User.isTutor(req.user.perm)) &&
|
||||
(req.user._id.toString() !== id) &&
|
||||
!tools.ModificheConsentite(mydata.table, fieldsvalue)) {
|
||||
!tools.ModificheConsentite(params.table, fieldsvalue)) {
|
||||
// If without permissions, exit
|
||||
return res.status(404).
|
||||
send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''});
|
||||
|
||||
@@ -51,6 +51,8 @@ const tools = require('./tools/general');
|
||||
|
||||
require('./models/cfgserver');
|
||||
|
||||
const shared_consts = require('./tools/shared_nodejs');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
|
||||
mongoose.set('debug', process.env.DEBUG);
|
||||
@@ -58,6 +60,7 @@ mongoose.set('debug', process.env.DEBUG);
|
||||
const cfgserver = mongoose.model('cfgserver');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const printf = require('util').format;
|
||||
|
||||
myLoad().then(ris => {
|
||||
|
||||
@@ -420,18 +423,33 @@ async function faitest() {
|
||||
console.log('ris', ris);
|
||||
}
|
||||
|
||||
const {User} = require('./models/user');
|
||||
|
||||
if (false) {
|
||||
// const {User} = require('./models/user');
|
||||
/*
|
||||
const user = await User.findOne({
|
||||
let myuser = await User.findOne({
|
||||
idapp: 12,
|
||||
username: 'paoloar77',
|
||||
});
|
||||
|
||||
await sendemail.sendEmail_Registration('it', 'paolo@freeplanet.app', user,
|
||||
const langdest = 'it';
|
||||
|
||||
telegrambot.askConfirmationUserRegistration(myuser.idapp, shared_consts.CallFunz.REGISTRATION, myuser, 'paoloar773', langdest);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (false) {
|
||||
|
||||
|
||||
const user = await User.findOne({
|
||||
idapp: 12,
|
||||
username: 'paolotest1',
|
||||
});
|
||||
|
||||
await sendemail.sendEmail_Registration('it', 'paolo@arcodiluce.it', user,
|
||||
'12', '');
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -334,6 +334,11 @@ const InlineZoomConferma = {
|
||||
NON_CONFERMA_ZOOM_PRESENZA: 'nonconf_pres',
|
||||
};
|
||||
|
||||
const InlineConferma = {
|
||||
RISPOSTA_SI: 'r_s',
|
||||
RISPOSTA_NO: 'r_n',
|
||||
};
|
||||
|
||||
const SendMsgCmd = [
|
||||
CONTA_SOLO,
|
||||
RICEVI_EMAIL,
|
||||
@@ -452,15 +457,13 @@ const txt = {
|
||||
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi',
|
||||
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
|
||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato "%s',
|
||||
MSG_APORTADOR_ASK_CONFIRM: emo.QUESTION_MARK +
|
||||
' Si vuole confermare di Conoscere "%s ?',
|
||||
MSG_APORTADOR_CONFIRMED: emo.SUN + ' %s è stato confermato correttamente!',
|
||||
MSG_APORTADOR_DEST_CONFIRMED: emo.SUN +
|
||||
' Sei stato Verificato correttamente da %s!',
|
||||
MSG_APORTADOR_ASK_CONFIRM: '🆕💥 🧍♂️ Abilita Nuova Registrazione: %s',
|
||||
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Abilitato correttamente!',
|
||||
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei stato Abilitato correttamente da %s!',
|
||||
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||
' Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s. Contattalo se lo conosci, oppure trova un altro invitante !',
|
||||
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
||||
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||
' %s Non è stato Verificato !',
|
||||
'🚫 %s Non è stato Abilitato !',
|
||||
MSG_ISCRITTO_CONACREIS: emo.FIRE + ' Si è appena Iscritto al Conacreis "%s"',
|
||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
||||
@@ -620,7 +623,7 @@ module.exports = {
|
||||
|
||||
getFormDaMostrare: function(idapp, myfunc, myuser) {
|
||||
|
||||
FormDaMostrare = null;
|
||||
let FormDaMostrare = null;
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
|
||||
@@ -629,13 +632,14 @@ module.exports = {
|
||||
{
|
||||
text: 'Conferma Presenza Zoom',
|
||||
// callback_data: { action: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA, username: myuser.username }
|
||||
callback_data: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA + '|' +
|
||||
callback_data: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA + tools.SEP +
|
||||
myuser.username,
|
||||
},
|
||||
{
|
||||
text: 'Annulla Presenza Zoom',
|
||||
// callback_data: { action: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA, username: myuser.username }
|
||||
callback_data: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA + '|' +
|
||||
callback_data: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA +
|
||||
tools.SEP +
|
||||
myuser.username,
|
||||
},
|
||||
]);
|
||||
@@ -684,9 +688,14 @@ module.exports = {
|
||||
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
|
||||
|
||||
if (phase === this.phase.REGISTRATION) {
|
||||
await this.askConfirmationUserRegistration(mylocalsconf.idapp, shared_consts.CallFunz.REGISTRATION,
|
||||
mylocalsconf.user, userdest, langdest);
|
||||
}
|
||||
|
||||
/*
|
||||
// Invia richiesta allo Sponsor
|
||||
const domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||
`${mylocalsconf.user.name + ' ' + mylocalsconf.user.surname}`);
|
||||
`${mylocalsconf.user.name + ' ' + mylocalsconf.user.surname + '(' + mylocalsconf.user.username + ')' + 'email: ' + mylocalsconf.user.email }`);
|
||||
const msgyes = printf(getstr(langdest, 'MSG_APORTADOR_CONFIRMED'),
|
||||
`${mylocalsconf.user.name + ' ' + mylocalsconf.user.surname}`);
|
||||
const msgNo = printf(getstr(langdest, 'MSG_APORTADOR_NOT_CONFIRMED'),
|
||||
@@ -707,8 +716,7 @@ module.exports = {
|
||||
msgDestNo, mylocalsconf.user.username);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
},
|
||||
|
||||
notifyIscrizioneToTelegram: async function(phase, mylocalsconf) {
|
||||
@@ -1083,7 +1091,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
sendMsgTelegram: async function(
|
||||
idapp, username, text, alsotomanagers, username_mitt) {
|
||||
idapp, username, text, alsotomanagers = false, username_mitt = '') {
|
||||
const {User} = require('../models/user');
|
||||
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, username);
|
||||
@@ -1111,6 +1119,9 @@ module.exports = {
|
||||
sendMsgTelegramByIdTelegram: async function(
|
||||
idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec,
|
||||
MyForm = null) {
|
||||
|
||||
console.log('sendMsgTelegramByIdTelegram', text);
|
||||
|
||||
if (!idtelegram)
|
||||
return;
|
||||
|
||||
@@ -1128,7 +1139,48 @@ module.exports = {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl) {
|
||||
return await cl.updateMenuBot();
|
||||
return cl.updateMenuBot();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
askConfirmationUserRegistration: async function(idapp, myfunc, myuser, userDest = '', langdest = '') {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
|
||||
try {
|
||||
|
||||
let keyb = null;
|
||||
let domanda = '';
|
||||
|
||||
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
|
||||
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||
`<br>${myuser.name + ' ' + myuser.surname + ' (' + myuser.username +
|
||||
') <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);
|
||||
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda,
|
||||
undefined, undefined, true, keyb);
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error askConfirmationUserRegistration', e);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -1208,6 +1260,19 @@ async function local_sendMsgTelegramToTheManagers(
|
||||
|
||||
}
|
||||
|
||||
async function local_sendMsgTelegram(idapp, username, text) {
|
||||
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, username);
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
let ris = null;
|
||||
if (cl && teleg_id) {
|
||||
ris = await cl.sendMsg(teleg_id, text);
|
||||
}
|
||||
|
||||
return ris;
|
||||
|
||||
}
|
||||
|
||||
function getstr(lang, key, param1) {
|
||||
|
||||
let mystr = '';
|
||||
@@ -1298,7 +1363,6 @@ class Telegram {
|
||||
if (rec.user)
|
||||
rec.status = Status.VERIFIED;
|
||||
} else {
|
||||
let prova = 1;
|
||||
// await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp)), MenuNoLogin);
|
||||
}
|
||||
|
||||
@@ -2349,8 +2413,7 @@ class Telegram {
|
||||
|
||||
async setCmdToUsername(rec, username, cmd_to_set, valuebool) {
|
||||
if (cmd_to_set === Cmd.VALIDATE_REGISTRATION) {
|
||||
return await User.setVerifiedByAportador(rec.user.idapp, username,
|
||||
valuebool);
|
||||
return User.setVerifiedByAportador(rec.user.idapp, username, valuebool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2466,12 +2529,13 @@ class Telegram {
|
||||
FormDaMostrare = this.getInlineKeyboard(lang, [
|
||||
{
|
||||
text: Menu[lang].SI,
|
||||
callback_data: InlineCmd.VOGLIO_IMBARCARMI + '|' +
|
||||
callback_data: InlineCmd.VOGLIO_IMBARCARMI + tools.SEP +
|
||||
utente.username,
|
||||
},
|
||||
{
|
||||
text: Menu[lang].NO,
|
||||
callback_data: InlineCmd.NON_VOGLIO_IMBARCARMI + '|' +
|
||||
callback_data: InlineCmd.NON_VOGLIO_IMBARCARMI +
|
||||
tools.SEP +
|
||||
utente.username,
|
||||
},
|
||||
]);
|
||||
@@ -3266,17 +3330,19 @@ if (true) {
|
||||
|
||||
let dataarr = [];
|
||||
let data = {
|
||||
action: 0,
|
||||
action: '',
|
||||
username: '',
|
||||
userDest: '',
|
||||
};
|
||||
|
||||
const datastr = callbackQuery.data;
|
||||
if (!!datastr) {
|
||||
dataarr = datastr.split('|');
|
||||
dataarr = datastr.split(tools.SEP);
|
||||
if (!!dataarr) {
|
||||
data = {
|
||||
action: dataarr[0],
|
||||
username: dataarr[1],
|
||||
username: dataarr[1] ? dataarr[1] : '',
|
||||
userDest: dataarr[2] ? dataarr[2] : '',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3291,6 +3357,10 @@ if (true) {
|
||||
const rec = myclTelegram.getRecInMem(msg);
|
||||
const user = await User.getUserShortDataByUsername(idapp,
|
||||
data.username);
|
||||
const userDest = data.userDest
|
||||
? await User.getUserShortDataByUsername(idapp, data.userDest)
|
||||
: null;
|
||||
|
||||
if (!!rec) {
|
||||
if (!!user) {
|
||||
if (data.action === InlineCmd.VOGLIO_IMBARCARMI) {
|
||||
@@ -3323,6 +3393,35 @@ if (true) {
|
||||
|
||||
await User.setZoomPresenza(user.idapp, user._id, false);
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI +
|
||||
shared_consts.CallFunz.REGISTRATION) {
|
||||
await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, true);
|
||||
|
||||
const msgOrig = printf(
|
||||
getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'),
|
||||
`${userDest.name + ' ' + userDest.surname}`);
|
||||
const msgDest = printf(
|
||||
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'),
|
||||
`${user.name + ' ' + user.surname}`);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO +
|
||||
shared_consts.CallFunz.REGISTRATION) {
|
||||
await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, false);
|
||||
|
||||
const msgOrig = printf(
|
||||
getstr(userDest.lang, 'MSG_APORTADOR_DEST_NOT_CONFIRMED'),
|
||||
`${userDest.name + ' ' + userDest.surname}`);
|
||||
const msgDest = printf(
|
||||
getstr(user.lang, 'MSG_APORTADOR_NOT_CONFIRMED'),
|
||||
`${user.name + ' ' + user.surname}`);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,6 +394,8 @@ module.exports = {
|
||||
|
||||
APORTADOR_NONE: '------',
|
||||
|
||||
SEP: '|',
|
||||
|
||||
TYPE_PROJECT: 1,
|
||||
TYPE_TODO: 2,
|
||||
|
||||
|
||||
@@ -132,7 +132,8 @@ module.exports = {
|
||||
DAMMI_PRIMO_UTENTE_LIBERO: 390,
|
||||
GET_VALBYTABLE: 400,
|
||||
SET_VALBYTABLE: 410,
|
||||
ZOOM_GIA_PARTECIPATO: 510
|
||||
ZOOM_GIA_PARTECIPATO: 510,
|
||||
REGISTRATION: 6
|
||||
},
|
||||
|
||||
OrderStatus: {
|
||||
|
||||
Reference in New Issue
Block a user