- Chart Maps Nationality
- Username lowercase - Statistics - Telegram
This commit is contained in:
@@ -99,9 +99,9 @@ if (process.env.NODE_ENV === 'production') {
|
||||
portapp: '0',
|
||||
dir: '/var/www/ayni.gifteconomy.app',
|
||||
email_from: 'ayni.gifteconomy@gmail.com',
|
||||
email_pwd: '4a16f0c93b28cd53cb2b6d9b6698ad20c5514f1c91de8161b2789274d15617bb20Ecne0RP3aNDl8NhJj5Uw==',
|
||||
email_pwd: 'b72b121f6fb69f7c58a269f5b5110e179430cd6fa940a168c2c10b255aa75fd1ebql9yXWoH1LwANdHD7Yvw==',
|
||||
telegram_key:'1037577457:AAGQbdIuYoB838v61ewJ0Hearx9UPpTBhMI',
|
||||
telegram_bot_name: 'aynibot',
|
||||
telegram_bot_name: 'notevoleaynibot',
|
||||
},
|
||||
{
|
||||
idapp: '8',
|
||||
|
||||
@@ -123,6 +123,12 @@ ExtraListSchema.statics.getRegDellaLista = async function (idapp) {
|
||||
return await ExtraList.count(myfind);
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.getLastUser = function (idapp) {
|
||||
const ExtraList = this;
|
||||
|
||||
return ExtraList.findOne({ idapp }).sort({ ind_order: -1 })
|
||||
};
|
||||
|
||||
|
||||
ExtraListSchema.statics.findByCellAndNameSurname = function (idapp, cell_complete, name, surname) {
|
||||
const ExtraList = this;
|
||||
@@ -163,7 +169,7 @@ ExtraListSchema.statics.getUsersList = function (idapp) {
|
||||
|
||||
|
||||
ExtraListSchema.statics.getFieldsForSearch = function () {
|
||||
return ['name', 'surname', 'cell_complete', 'aportador_solidario_name_surname', 'aportador_solidario_originale_name_surname']
|
||||
return ['username', 'name', 'surname', 'cell_complete', 'aportador_solidario_name_surname', 'aportador_solidario_originale_name_surname']
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
@@ -286,7 +286,7 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) {
|
||||
return User.findOne({ idapp, username: username }).then((user) => {
|
||||
if (!user) {
|
||||
// Check if with email:
|
||||
return User.findOne({ idapp, email: username })
|
||||
return User.findOne({ idapp, email: username.toLowerCase() })
|
||||
} else {
|
||||
return user
|
||||
}
|
||||
@@ -416,6 +416,12 @@ UserSchema.statics.findByEmail = function (idapp, email) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getLastUser = function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({ idapp }).sort({ ind_order: -1 })
|
||||
};
|
||||
|
||||
UserSchema.pre('save', function (next) {
|
||||
const user = this;
|
||||
|
||||
@@ -548,7 +554,28 @@ UserSchema.statics.getUsersTelegALL = async function (idapp) {
|
||||
UserSchema.statics.isManagerByIdTeleg = async function (idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, 'profile.manage_telegram': true, 'profile.teleg_id': idtelegram }, { 'profile.teleg_id': 1 })
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
'profile.manage_telegram': true,
|
||||
'profile.teleg_id': idtelegram
|
||||
}, { 'profile.teleg_id': 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec && rec.profile.teleg_id === idtelegram);
|
||||
}).catch((e) => {
|
||||
console.error('getusersManagers', e);
|
||||
return false
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
'username': 'paoloar77',
|
||||
'profile.manage_telegram': true,
|
||||
'profile.teleg_id': idtelegram
|
||||
}, { 'profile.teleg_id': 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec && rec.profile.teleg_id === idtelegram);
|
||||
}).catch((e) => {
|
||||
@@ -607,7 +634,7 @@ UserSchema.statics.getUsersListByParams = function (params) {
|
||||
*/
|
||||
|
||||
UserSchema.statics.getFieldsForSearch = function () {
|
||||
return ['name', 'surname', 'email', 'profile.cell', 'profile.email_paypal', 'profile.username_telegram', 'aportador_solidario']
|
||||
return ['username', 'name', 'surname', 'email', 'profile.cell', 'profile.email_paypal', 'profile.username_telegram', 'aportador_solidario']
|
||||
};
|
||||
|
||||
UserSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
@@ -682,12 +709,59 @@ UserSchema.statics.getUsersRegistered = async function (idapp) {
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getEmailNotVerified = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, verified_email: false };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramAttivo = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.teleg_id': { $gt: 0 } };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramPending = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.teleg_checkcode': { $gt: 0 } };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersZoom = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.saw_zoom_presentation': true };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersDreams = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
'profile.my_dream': { $exists: true },
|
||||
"$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] }
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getLastUsers = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
|
||||
|
||||
return await User.find({ idapp }).sort({ date_temp_reg: -1 }).limit(lastn);
|
||||
return await User.find({ idapp }).sort({ date_temp_reg: -1 }).limit(lastn).then((arr) => {
|
||||
//return JSON.stringify(arr)
|
||||
return arr
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -698,6 +772,8 @@ UserSchema.statics.checkUser = async function (idapp, username) {
|
||||
verified_email: 1,
|
||||
'profile.teleg_id': 1,
|
||||
'profile.teleg_checkcode': 1,
|
||||
}).then((rec) => {
|
||||
return JSON.stringify(rec)
|
||||
});
|
||||
|
||||
};
|
||||
@@ -712,8 +788,61 @@ UserSchema.statics.calculateStat = async function (idapp, username) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersNationalityQuery = function (idapp) {
|
||||
const query = [
|
||||
{
|
||||
$match: { idapp }
|
||||
},
|
||||
{
|
||||
$group: { _id: "$profile.nationality", count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { count: -1 }
|
||||
}
|
||||
];
|
||||
return query
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.findAllDistinctNationality = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getUsersNationalityQuery(idapp))
|
||||
.then(ris => {
|
||||
// console.table(ris);
|
||||
return JSON.stringify(ris);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
|
||||
const query = [
|
||||
{
|
||||
$match: { idapp }
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_temp_reg" } }, count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
},
|
||||
{
|
||||
$limit: nrec
|
||||
}
|
||||
];
|
||||
return query
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.calcRegDaily = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getUsersRegDaily(idapp, 30))
|
||||
.then(ris => {
|
||||
// console.table(ris);
|
||||
return JSON.stringify(ris);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
if (tools.INITDB_FIRSTIME) {
|
||||
console.log(' createIndex User Index...');
|
||||
|
||||
@@ -20,13 +20,6 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
getiPAddressUser: function (req) {
|
||||
try {
|
||||
return req.ip; // Express
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
|
||||
const aportador_solidario = req.user.aportador_solidario;
|
||||
|
||||
const dashboard = User.getDashboard(idapp, aportador_solidario, req.user.username);
|
||||
const dashboard = await User.getDashboard(idapp, aportador_solidario, req.user.username);
|
||||
if (dashboard)
|
||||
res.send({ dashboard });
|
||||
else
|
||||
|
||||
@@ -26,26 +26,35 @@ router.post('/load', async (req, res) => {
|
||||
num_tot_lista: await ExtraList.getTotInLista(idapp),
|
||||
num_reg_lista: await ExtraList.getRegDellaLista(idapp),
|
||||
num_reg: await User.getUsersRegistered(idapp),
|
||||
email_non_verif: await User.getEmailNotVerified(idapp),
|
||||
num_teleg_attivo: await User.getUsersTelegramAttivo(idapp),
|
||||
num_teleg_pending: await User.getUsersTelegramPending(idapp),
|
||||
num_part_zoom: await User.getUsersZoom(idapp),
|
||||
num_users_dream: await User.getUsersDreams(idapp),
|
||||
arr_nations: await User.findAllDistinctNationality(idapp),
|
||||
reg_daily: await User.calcRegDaily(idapp),
|
||||
lastsreg: await User.getLastUsers(idapp),
|
||||
checkuser: await User.checkUser(idapp, username),
|
||||
};
|
||||
|
||||
|
||||
|
||||
// console.table(datastat.lastsreg);
|
||||
|
||||
/*
|
||||
let datastat = {
|
||||
num_tot_lista: 80,
|
||||
num_reg: 40,
|
||||
lastsreg: [
|
||||
{ username: 'prova3', name: 'Datti', surname: 'Una Mossa', nationality: 'gb', date_reg: new Date()},
|
||||
{ username: 'prova2', name: 'Pinco', surname: 'Pallino', nationality: 'de', date_reg: new Date()},
|
||||
{ username: 'paoloar77', name: 'Paolo', surname: 'Arena', nationality: 'it', date_reg: new Date()},
|
||||
{ username: 'mariorossi', name: 'Mario', surname: 'Rossi', nationality: 'es', date_reg: new Date()},
|
||||
{ username: 'prova4', name: 'Quanto', surname: 'Siamo Fighi', nationality: 'uk', date_reg: new Date()},
|
||||
{ username: 'prova5', name: 'Secondo', surname: 'PPP', nationality: 'sl', date_reg: new Date()},
|
||||
]
|
||||
};
|
||||
*/
|
||||
/*
|
||||
let datastat = {
|
||||
num_tot_lista: 80,
|
||||
num_reg: 40,
|
||||
lastsreg: [
|
||||
{ username: 'prova3', name: 'Datti', surname: 'Una Mossa', nationality: 'gb', date_reg: new Date()},
|
||||
{ username: 'prova2', name: 'Pinco', surname: 'Pallino', nationality: 'de', date_reg: new Date()},
|
||||
{ username: 'paoloar77', name: 'Paolo', surname: 'Arena', nationality: 'it', date_reg: new Date()},
|
||||
{ username: 'mariorossi', name: 'Mario', surname: 'Rossi', nationality: 'es', date_reg: new Date()},
|
||||
{ username: 'prova4', name: 'Quanto', surname: 'Siamo Fighi', nationality: 'uk', date_reg: new Date()},
|
||||
{ username: 'prova5', name: 'Secondo', surname: 'PPP', nationality: 'sl', date_reg: new Date()},
|
||||
]
|
||||
};
|
||||
*/
|
||||
|
||||
res.send({ datastat });
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ router.post('/', async (req, res) => {
|
||||
|
||||
user.linkreg = reg.getlinkregByEmail(body.idapp, body.email, body.username);
|
||||
user.verified_email = false;
|
||||
user.ipaddr = reg.getiPAddressUser(req);
|
||||
user.ipaddr = tools.getiPAddressUser(req);
|
||||
user.lasttimeonline = new Date();
|
||||
user.date_reg = new Date();
|
||||
user.date_temp_reg = new Date();
|
||||
@@ -62,6 +62,11 @@ router.post('/', async (req, res) => {
|
||||
user.verified_email = true;
|
||||
}
|
||||
|
||||
if (user.profile.intcode_cell) {
|
||||
if (user.profile.cell.substring(0, user.profile.intcode_cell.length) === user.profile.intcode_cell) {
|
||||
user.profile.cell = user.profile.cell.substring(user.profile.intcode_cell.length)
|
||||
}
|
||||
}
|
||||
let exit;
|
||||
|
||||
// Check if already esist email or username
|
||||
@@ -98,6 +103,21 @@ router.post('/', async (req, res) => {
|
||||
nomeaportador_corretto = recextra.aportador_solidario_originale_name_surname;
|
||||
}
|
||||
|
||||
const lastuser = await User.getLastUser(user.idapp);
|
||||
const lastextra = await ExtraList.getLastUser(user.idapp);
|
||||
let lastindorder = 0;
|
||||
|
||||
if (lastuser) {
|
||||
lastindorder = lastuser.ind_order;
|
||||
}
|
||||
if (lastextra) {
|
||||
if (lastextra.ind_order > lastindorder)
|
||||
lastindorder = lastextra.ind_order;
|
||||
}
|
||||
|
||||
if (lastindorder > 0)
|
||||
user.ind_order = lastindorder + 1;
|
||||
|
||||
|
||||
namesurname_aportador_reg = await User.getNameSurnameByUsername(user.idapp, user.aportador_solidario);
|
||||
|
||||
@@ -119,6 +139,9 @@ router.post('/', async (req, res) => {
|
||||
if (already_registered) {
|
||||
// Check in the extraList if is present!
|
||||
if (!recextra) {
|
||||
console.log('Utente non trovato; ', user);
|
||||
const msg = 'Utente non trovato: ' + user.name + ' ' + user.surname + ' ' + user.profile.nationality + ' ' + user.profile.intcode_cell + user.profile.cell + ' email: ' + user.email + ' username: ' + user.username;
|
||||
telegrambot.sendMsgTelegramToTheManagers(user.idapp, msg);
|
||||
res.status(400).send({ code: server_constants.RIS_CODE_USER_EXTRALIST_NOTFOUND, msg: '' });
|
||||
return 1;
|
||||
} else {
|
||||
@@ -247,7 +270,9 @@ router.post('/login', (req, res) => {
|
||||
.then((user) => {
|
||||
// tools.mylog("CREDENZIALI ! ");
|
||||
if (!user) {
|
||||
tools.mylogshow("NOT FOUND !");
|
||||
tools.mylogshow("Errore LOGIN ! Username o password Errati: ", body.username, body.password);
|
||||
const msg = "Tentativo di Login ERRATO [" + body.username + ' , ' + body.password + ']\n' + '[IP: ' + tools.getiPAddressUser(req) + ']';
|
||||
telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
|
||||
res.status(404).send({ code: server_constants.RIS_CODE_LOGIN_ERR });
|
||||
}
|
||||
return user
|
||||
|
||||
@@ -78,6 +78,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
// console.log('2 . paramemail.transport', paramemail.transport);
|
||||
// console.log('user', tools.getEmailByIdApp(mylocalsconf.idapp));
|
||||
// console.log('pass', tools.getPwdByIdApp(mylocalsconf.idapp));
|
||||
|
||||
// console.log('paramemail', paramemail);
|
||||
|
||||
@@ -116,13 +118,13 @@ module.exports = {
|
||||
mailOptions['reply-to'] = replyTo;
|
||||
|
||||
if (process.env.SEND_EMAIL === 1) {
|
||||
console.log("SEND EMAIL...");
|
||||
// console.log("SEND EMAIL...");
|
||||
// send mail with defined transport object
|
||||
smtpTransport.sendMail(mailOptions, function (error, response) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
console.log("Email Inviata ERRORE RISPOSTA: " + error);
|
||||
} else {
|
||||
console.log("Email Inviata RISPOSTA: " + response);
|
||||
// console.log("Email Inviata RISPOSTA: " + response);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -303,7 +305,7 @@ module.exports = {
|
||||
},
|
||||
Add_to_MailingList_AndSendEmailNotify: async function (lang, user, idapp, sendnews) {
|
||||
|
||||
console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
@@ -442,9 +444,9 @@ module.exports = {
|
||||
templemail_id: await Settings.getValDbSettings(idapp, 'TEMPLEMAIL_ID'),
|
||||
};
|
||||
|
||||
console.log(mydata.templemail_id);
|
||||
// console.log(mydata.templemail_id);
|
||||
mydata.templ = await TemplEmail.findOne({_id: mydata.templemail_id });
|
||||
console.log(mydata.templ);
|
||||
// console.log(mydata.templ);
|
||||
|
||||
return mydata
|
||||
},
|
||||
@@ -547,7 +549,7 @@ module.exports = {
|
||||
await tools.snooze(5000);
|
||||
|
||||
// Send Email to the User
|
||||
console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')');
|
||||
// console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')');
|
||||
const esito = this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply, smtpTransport);
|
||||
|
||||
//Put the result in the database, to check if is sent or not.
|
||||
|
||||
@@ -101,18 +101,18 @@ const StatusMSGALL = {
|
||||
|
||||
const txt = {
|
||||
MSG_SCEGLI_MENU: emoji.get('dizzy') + ' Scegli una voce di menu:' + emoji.get('dizzy'),
|
||||
MSG_ASK_USERNAME_BO: 'Inserire lo username con cui ti sei registrato sul sito:',
|
||||
MSG_ASK_USERNAME_BO: 'Inserire lo username con cui ti sei registrato sul sito %s:',
|
||||
MSG_ERRORE_USERNAME: 'Attenzione! Devi inserire solo lo username (20 caratteri massimo)',
|
||||
MSG_ERRORE_USERNAME_NOT_FOUND: 'Attenzione! Username non trovato in archivio. Verifica che sia corretto.',
|
||||
MSG_ERRORE_USERNAME_ANNULLA: 'Inserimento Annullato. Riprovare',
|
||||
MSG_OPERAZ_ANNULLATA: 'Operazione Annullata',
|
||||
MSG_ERRORE_VERIFY_CODE_MAXLEN: 'Attenzione! Devi inserire solo il codice a 6 cifre',
|
||||
MSG_VERIFY_CODE: 'Vai sul sito e scrivi qui il Codice di Autenticazione che vedrai visualizzato',
|
||||
MSG_VERIFY_CODE: 'Ritorna sul sito cliccando qui %s, poi torna qui e scrivi il Codice di Autenticazione che vedrai visualizzato',
|
||||
MSG_ERR_VERIFY_CODE: 'Codice di Verifica Errato! Controllare sul Sito e reinserire il nuovo codice di 6 cifre.',
|
||||
MSG_VERIFY_OK: emoji.get('grinning') + ' Benvenuto %s. Ora sei correttamente verificato!',
|
||||
MSG_VERIFY_OK: emoji.get('grinning') + ' Benvenuto %s. Sono il tuo BOT. Chiedi utilizzando il menu che trovi in basso.\nOra sei correttamente verificato!\nContinua la guida passo passo che trovi sul sito. Qui puoi ritornare per vedere La tua Lavagna in maniera rapida, senza passare dal sito.',
|
||||
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\n(Invitato da %s)',
|
||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato "%s (n. %s)"\n(Invitato da %s)',
|
||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||
};
|
||||
|
||||
@@ -131,6 +131,7 @@ module.exports = {
|
||||
notifyToTelegram: async function (phase, mylocalsconf) {
|
||||
let userdest = mylocalsconf.user.aportador_solidario;
|
||||
let NameFrom = `${mylocalsconf.user.name} ${mylocalsconf.user.surname}`;
|
||||
const ind_order = mylocalsconf.user.ind_order;
|
||||
|
||||
let aportador = '';
|
||||
if (userdest) {
|
||||
@@ -146,7 +147,7 @@ module.exports = {
|
||||
NameFrom = await User.getNameSurnameByUsername(mylocalsconf.idapp, userdest) + aportador;
|
||||
aportador = NameFrom;
|
||||
}
|
||||
text = printf(txt.MSG_APORTADOR_USER_REGISTERED, `${mylocalsconf.user.name} ${mylocalsconf.user.surname} (${mylocalsconf.user.username})`, aportador);
|
||||
text = printf(txt.MSG_APORTADOR_USER_REGISTERED, `${mylocalsconf.user.name} ${mylocalsconf.user.surname} (${mylocalsconf.user.username})`, ind_order, aportador);
|
||||
}
|
||||
|
||||
let addtext = "";
|
||||
@@ -275,14 +276,14 @@ class Telegram {
|
||||
}
|
||||
}
|
||||
|
||||
getsymb(symb, valid, isnum, verdeif, smileif) {
|
||||
getsymb(symb, valid, isnum, num, smileif) {
|
||||
let str = symb + ': ';
|
||||
if (valid)
|
||||
str += emo.CHECK_VERDE;
|
||||
else
|
||||
str += emo.CROSS_ROSSA;
|
||||
if (isnum) {
|
||||
str += ' ' + getemojibynumber(valid);
|
||||
str += ' ' + getemojibynumber(num);
|
||||
if (smileif)
|
||||
str += emo.SMILE_STAR;
|
||||
}
|
||||
@@ -317,7 +318,7 @@ class Telegram {
|
||||
// mystr += `____________________________________________\n`;
|
||||
|
||||
if (rec.user) {
|
||||
mystr += tools.get__('BENVENUTO', msg) + ' ' + rec.user.name + ' ' + emo.DIZZY;
|
||||
mystr += tools.get__('BENVENUTO', msg) + ' ' + rec.user.name + ' (' + rec.user.username + ') ' + emo.DIZZY;
|
||||
mystr += '\n' + '\n' + this.getsymb(emo.ENVELOPE, rec.user.verified_email);
|
||||
mystr += rec.user.verified_email ? tools.get__('EMAIL_VERIF', msg) : tools.get__('EMAIL_NON_VERIF', msg);
|
||||
|
||||
@@ -328,9 +329,9 @@ class Telegram {
|
||||
// mystr += tools.get__('TELEGRAM_NOT_CONNECTED', msg) + ' ' + emoji.get('e-mail');
|
||||
}
|
||||
|
||||
// numpersone = 3;
|
||||
// numpersone = 2;
|
||||
|
||||
mystr += '\n' + '\n' + this.getsymb(emo.INVITATI, numpersone, true, numpersone >= 2, numpersone >= 3) + tools.get__('INVITATI', msg) + '\n';
|
||||
mystr += '\n' + '\n' + this.getsymb(emo.INVITATI, numpersone >= 2, numpersone, numpersone, numpersone >= 3) + tools.get__('INVITATI', msg) + '\n';
|
||||
|
||||
if (numpersone > 0) {
|
||||
let index = 1;
|
||||
@@ -382,28 +383,31 @@ class Telegram {
|
||||
|
||||
let index = 1;
|
||||
listazoom.forEach((evento) => {
|
||||
let iniziata = false;
|
||||
if (nextzoom)
|
||||
iniziata = (nextzoom._id.toString() === evento._id.toString());
|
||||
let iniziata = false;
|
||||
if (nextzoom)
|
||||
iniziata = (nextzoom._id.toString() === evento._id.toString());
|
||||
|
||||
|
||||
if (iniziata) {
|
||||
mystr += emo.CHECK_VERDE + ' QUESTA CONFERENZA E\' INIZIATA! ' + emo.CHECK_VERDE + '\n';
|
||||
}
|
||||
|
||||
mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start)} ${emo.EYES}`;
|
||||
mystr += `\n${evento.title}\n(${evento.note})\n\n`;
|
||||
if (nextzoom) {
|
||||
if (iniziata) {
|
||||
mystr += emo.FIRE + 'CLICCA QUI PER ENTRARE ! ' + emo.FIRE + '\n';
|
||||
mystr += tools.getlinkzoom(evento.id_conf_zoom) + '\n\n';
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
if (iniziata) {
|
||||
mystr += emo.CHECK_VERDE + ' QUESTA CONFERENZA E\' INIZIATA! ' + emo.CHECK_VERDE + '\n';
|
||||
}
|
||||
)
|
||||
;
|
||||
|
||||
mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start)} ${emo.EYES}`;
|
||||
mystr += `\n${evento.title}\n(${evento.note})\n\n`;
|
||||
if (nextzoom) {
|
||||
if (iniziata) {
|
||||
mystr += emo.FIRE + 'CLICCA QUI PER ENTRARE ! ' + emo.FIRE + '\n';
|
||||
mystr += tools.getlinkzoom(evento.id_conf_zoom) + '\n\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
index++;
|
||||
});
|
||||
|
||||
if (!nextzoom && index > 1) {
|
||||
mystr += "LINK ZOOM DA CONDIVIDERE :\n" + tools.getlinkzoom(listazoom[0].id_conf_zoom) + '\n\n';
|
||||
}
|
||||
|
||||
|
||||
await
|
||||
@@ -429,8 +433,7 @@ class Telegram {
|
||||
if (rec.user) {
|
||||
const mystr = 'Scrivi qui un Messaggio da inviare a TUTTI:';
|
||||
rec.msgall_status = StatusMSGALL.ASK;
|
||||
await
|
||||
this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,6 +473,9 @@ class Telegram {
|
||||
async setUsernameBo(msg) {
|
||||
try {
|
||||
const rec = this.getRecInMem(msg);
|
||||
if (msg.text === undefined)
|
||||
return false;
|
||||
|
||||
console.log('msg.text', msg.text);
|
||||
const text = msg.text;
|
||||
if (text.length < 20) {
|
||||
@@ -480,15 +486,16 @@ class Telegram {
|
||||
const user = await
|
||||
User.findByUsername(this.idapp, rec.username_bo);
|
||||
if (!user) {
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND)
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND);
|
||||
rec.username_bo = '';
|
||||
} else {
|
||||
rec.user = user;
|
||||
await
|
||||
User.SetTelegramCheckCode(this.idapp, rec.username_bo, rec.code);
|
||||
rec.status = Status.WAITFOR_VERIFY_CODE;
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_VERIFY_CODE)
|
||||
this.sendMsg(msg.from.id, printf(txt.MSG_VERIFY_CODE, tools.getHostByIdApp(this.idapp)))
|
||||
|
||||
}
|
||||
}
|
||||
} else if (text.length === 0) {
|
||||
@@ -570,9 +577,9 @@ class Telegram {
|
||||
|
||||
if (usersall) {
|
||||
for (const rec of usersall) {
|
||||
await
|
||||
this.sendMsg(rec.profile.teleg_id, texttosend);
|
||||
await this.sendMsg(rec.profile.teleg_id, texttosend);
|
||||
nummsgsent++;
|
||||
// ++Todo: SLEEP ??? sleep(0.03)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -657,7 +664,7 @@ class Telegram {
|
||||
this.addUser(msg);
|
||||
|
||||
await
|
||||
this.sendMsg(msg.chat.id, getstr(msg.from.language_code, txt.MSG_ASK_USERNAME_BO));
|
||||
this.sendMsg(msg.chat.id, getstr(msg.from.language_code, printf(txt.MSG_ASK_USERNAME_BO, tools.getHostByIdApp(this.idapp))));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -730,7 +737,7 @@ class Telegram {
|
||||
let keyb = MenuStandard;
|
||||
// Check if you are Admin
|
||||
const ismanager = await
|
||||
User.isManagerByIdTeleg(this.idapp, id);
|
||||
User.isAdminByIdTeleg(this.idapp, id);
|
||||
if (ismanager)
|
||||
keyb = MenuPerAdmin;
|
||||
if (menu) {
|
||||
|
||||
@@ -833,4 +833,18 @@ module.exports = {
|
||||
return namesurname
|
||||
},
|
||||
|
||||
getiPAddressUser (req) {
|
||||
try {
|
||||
const striniziale = '::ffff:';
|
||||
if (req.ip.indexOf(striniziale) >= 0){
|
||||
return req.ip.substring(striniziale.length)
|
||||
} else {
|
||||
return req.ip; // Express
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user