Payeer e AdvCash

This commit is contained in:
Paolo Arena
2020-09-04 00:06:49 +02:00
parent 4e59979efd
commit 0ce46aab1e
22 changed files with 425 additions and 111 deletions

0
.env.old Normal file → Executable file
View File

0
docs/query_mongodb.js Normal file → Executable file
View File

6
documentation/passi.txt Normal file → Executable file
View File

@@ -7,6 +7,8 @@
// ++Todo: PRIORITA' ALTA:
- Togliere gli imbarchi: far pagare subito la persona.
- Errore durante la sostituzione...
- far pagare direttamente al Sognatore.
@@ -23,9 +25,9 @@
QUINDI QUALCUNO HA PRESO IL SUO POSTO.
- 7.64 : NATALINA NON HA LA RITESSITURA !!
- 7.64 : NATALINA NON HA LA RITESSITURA !!
- Controllare che ci sono registrazioni doppie !! (stesso username e stessa email!)
- Controllare che ci sono registrazioni doppie !! (stesso username e stessa email!)
- SubAccount:
filtro.

0
emails/admin/registration/esEs/html.pug Normal file → Executable file
View File

0
emails/admin/registration/esEs/subject.pug Normal file → Executable file
View File

0
emails/registration/it/textold.pug Normal file → Executable file
View File

0
src/server/locales/enUs.json Normal file → Executable file
View File

0
src/server/locales/fr.json Normal file → Executable file
View File

0
src/server/locales/pt.json Normal file → Executable file
View File

0
src/server/locales/si.json Normal file → Executable file
View File

View File

@@ -81,6 +81,12 @@ const FlottaSchema = new mongoose.Schema({
revolut: {
type: String,
},
payeer_id: {
type: String,
},
advcash_id: {
type: String,
},
note_payment: {
type: String,
},
@@ -114,6 +120,8 @@ function getQueryProj(myfilter) {
username: 1,
'profile.paymenttypes': 1,
'profile.email_paypal': 1,
'profile.payeer_id': 1,
'profile.advcash_id': 1,
'profile.revolut': 1,
'profile.cell': 1,
made_gift: 1,

View File

@@ -254,6 +254,7 @@ ListaIngressoSchema.statics.addUserInListaIngresso = async function (idapp, user
if (!nuovo) {
listaingresso = await ListaIngresso.findByUsernameETess(idapp, username, 1);
}
// listaingresso = null; // TOGLIEREE
if (!listaingresso) {
listaingresso = new ListaIngresso({
_id: new ObjectID(),

View File

@@ -447,6 +447,8 @@ function getQueryProj(myfilter) {
'profile.teleg_id': 1,
'profile.nationality': 1,
'profile.email_paypal': 1,
'profile.payeer_id': 1,
'profile.advcash_id': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
@@ -1500,6 +1502,8 @@ NaveSchema.statics.getFlotta = async function (idapp, riga, col_prima, col_ultim
if (!!usersognatore) {
flotta.link_payment = usersognatore.profile.link_payment;
flotta.email_paypal = usersognatore.profile.email_paypal;
flotta.payeer_id = usersognatore.profile.payeer_id;
flotta.advcash_id = usersognatore.profile.advcash_id;
flotta.revolut = usersognatore.profile.revolut;
flotta.note_payment = usersognatore.profile.note_payment;
}

View File

@@ -448,11 +448,15 @@ NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function (
if (nuovo) {
myflotta.email_paypal = '';
myflotta.payeer_id = '';
myflotta.advcash_id = '';
myflotta.revolut = '';
myflotta.link_payment = '';
myflotta.note_payment = '';
if (!!sognatore) {
myflotta.email_paypal = sognatore.profile.email_paypal;
myflotta.payeer_id = sognatore.profile.payeer_id;
myflotta.advcash_id = sognatore.profile.advcash_id;
myflotta.revolut = sognatore.profile.revolut;
myflotta.link_payment = sognatore.profile.link_payment;
myflotta.note_payment = sognatore.profile.note_payment;
@@ -462,6 +466,10 @@ NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function (
if (!!sognatore) {
if (!myflotta.email_paypal)
myflotta.email_paypal = sognatore.profile.email_paypal;
if (!myflotta.payeer_id)
myflotta.payeer_id = sognatore.profile.payeer_id;
if (!myflotta.advcash_id)
myflotta.advcash_id = sognatore.profile.advcash_id;
if (!myflotta.revolut)
myflotta.revolut = sognatore.profile.revolut;
if (!myflotta.link_payment)

View File

@@ -19,6 +19,8 @@ const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const queryclass = require('../classes/queryclass');
const telegrambot = require('../telegram/telegrambot');
mongoose.Promise = global.Promise;
mongoose.level = "F";
@@ -185,6 +187,12 @@ const UserSchema = new mongoose.Schema({
email_paypal: {
type: String
},
payeer_id: {
type: String
},
advcash_id: {
type: String
},
revolut: {
type: String
},
@@ -222,6 +230,9 @@ const UserSchema = new mongoose.Schema({
saw_zoom_presentation: {
type: Boolean
},
ask_zoom_partecipato: {
type: Boolean
},
qualified: {
type: Boolean
},
@@ -296,6 +307,36 @@ UserSchema.statics.setPermissionsById = function (id, perm) {
};
UserSchema.statics.setZoomPresenza = async function (idapp, id, presenza) {
const User = this;
const telegrambot = require('../telegram/telegrambot');
let allData = {};
allData.myuser = await User.getUserById(idapp, id);
if (!!allData.myuser)
allData.precDataUser = await User.getInfoUser(idapp, allData.myuser.username);
return await User.findByIdAndUpdate(id, { $set: { 'profile.saw_zoom_presentation': presenza } })
.then((rec) => {
if (presenza) {
const messaggio = tools.get__('ZOOM_CONFERMATO');
telegrambot.sendMsgTelegram(rec.idapp, rec.username, messaggio);
telegrambot.sendMsgTelegramToTheManagersAndZoomeri(idapp, `L\'utente ${rec.name} ${rec.surname} (${rec.username}) è stato confermato per aver visto lo Zoom di Benvenuto`);
} else {
telegrambot.sendMsgTelegramToTheManagersAndZoomeri(idapp, `L\'utente ${rec.name} ${rec.surname} (${rec.username}) è stato annullata la sua richiesta per aver visto lo Zoom di Benvenuto! (Non ci risulta)`);
}
return User.findByIdAndUpdate(id, { $set: { 'profile.ask_zoom_partecipato': false } })
.then((user) => {
User.checkIfSbloccatiRequisiti(idapp, allData, id);
});
});
};
UserSchema.statics.isAdmin = function (perm) {
try {
return ((perm & shared_consts.Permissions.Admin) === shared_consts.Permissions.Admin);
@@ -320,6 +361,14 @@ UserSchema.statics.isTraduttrici = function (perm) {
}
};
UserSchema.statics.isZoomeri = function (perm) {
try {
return ((perm & shared_consts.Permissions.Zoomeri) === shared_consts.Permissions.Zoomeri);
} catch (e) {
return false
}
};
UserSchema.statics.isTutor = function (perm) {
try {
return ((perm & shared_consts.Permissions.Tutor) === shared_consts.Permissions.Tutor);
@@ -454,10 +503,13 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username)
verified_email: 1,
'profile.teleg_id': 1,
'profile.saw_zoom_presentation': 1,
'profile.ask_zoom_partecipato': 1,
'profile.qualified': 1,
'profile.qualified_2invitati': 1,
'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.payeer_id': 1,
'profile.advcash_id': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
@@ -505,10 +557,13 @@ UserSchema.statics.getDownlineByUsername = async function (idapp, username, incl
verified_email: 1,
'profile.teleg_id': 1,
'profile.saw_zoom_presentation': 1,
'profile.ask_zoom_partecipato': 1,
'profile.qualified': 1,
'profile.qualified_2invitati': 1,
'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.payeer_id': 1,
'profile.advcash_id': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
@@ -587,16 +642,14 @@ UserSchema.statics.getQueryQualified = function () {
'profile.teleg_id': { $gt: 1 },
'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED,
'profile.saw_zoom_presentation': true,
'profile.my_dream': { $exists: true },
$or: [
{ 'profile.link_payment': { $exists: true } },
{ 'profile.email_paypal': { $exists: true } },
{ 'profile.payeer_id': { $exists: true } },
{ 'profile.advcash_id': { $exists: true } },
{ 'profile.revolut': { $exists: true } },
],
// 'profile.paymenttypes': { "$in": ['paypal'] },
$and: [
{ "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } },
// { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } }
],
// $where: "this.profile.paymenttypes.length >= 1",
}]
}
@@ -700,6 +753,7 @@ UserSchema.statics.isUserQualified9 = async function (idapp, username) {
};
/*
UserSchema.statics.getnumPaymentOk = function (idapp) {
const User = this;
@@ -719,6 +773,7 @@ UserSchema.statics.getnumPaymentOk = function (idapp) {
]
});
};
*/
UserSchema.statics.getUsersNationalityQuery = function (idapp) {
const query = [
@@ -1148,6 +1203,8 @@ UserSchema.statics.getRecByIndOrder = async function (idapp, ind_order) {
surname: 1,
'profile.teleg_id': 1,
'profile.email_paypal': 1,
'profile.payeer_id': 1,
'profile.advcash_id': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
@@ -1184,6 +1241,33 @@ UserSchema.statics.getusersManagers = async function (idapp) {
});
};
UserSchema.statics.getusersManagersAndZoomeri = async function (idapp) {
const User = this;
return await User.find(
{
idapp,
or: [
{ 'profile.manage_telegram': true },
{
perm:
{
$bit:
Number(shared_consts.Permissions.Zoomeri)
}
}
],
},
{ 'profile.teleg_id': 1 })
.then((arrrec) => {
return (!!arrrec) ? arrrec : null;
}).catch((e) => {
console.error('getusersManagers', e);
});
};
UserSchema.statics.getUsersTelegALL = async function (idapp, username) {
const User = this;
@@ -1302,6 +1386,8 @@ UserSchema.statics.getFieldsForSearch = function () {
{ field: 'email', type: tools.FieldType.string },
{ field: 'profile.cell', type: tools.FieldType.string },
{ field: 'profile.email_paypal', type: tools.FieldType.string },
{ field: 'profile.payeer_id', type: tools.FieldType.string },
{ field: 'profile.advcash_id', type: tools.FieldType.string },
{ field: 'profile.revolut', type: tools.FieldType.string },
{ field: 'profile.link_payment', type: tools.FieldType.string },
{ field: 'profile.teleg_id', type: tools.FieldType.number },
@@ -2105,6 +2191,143 @@ UserSchema.statics.NessunaNavePresenteByUsername = async function (idapp, userna
};
UserSchema.statics.getInfoUser = async function (idapp, username) {
return {
username,
is7req: await User.isUserQualified7(idapp, username),
is9req: await User.isUserQualified9(idapp, username),
}
}
UserSchema.statics.checkIfSbloccatiRequisiti = async function (idapp, allData, id) {
const User = this;
const telegrambot = require('../telegram/telegrambot');
if (!allData.myuser)
return false;
if (await Nave.checkIfNaveExist(idapp, allData.myuser.username)) {
// Se già sei dentro la Nave, allora sei OK
return true; //TOGLEREE
}
// Controlla se Sblocca i 7 requisiti
const is7req = await User.isUserQualified7(idapp, allData.myuser.username);
const is9req = await User.isUserQualified9(idapp, allData.myuser.username);
const userlista = await ListaIngresso.getListaTessByUsername(idapp, allData.myuser.username);
//if (userlista.length > 0) { //TOGLIERE
if (userlista.length === 0) {
// Se non sono ancora dentro alla lista, allora controllo
if (!!allData.precDataUser) {
if ((!allData.precDataUser.is7req && is7req) && !await User.isUserAlreadyQualified(idapp, allData.myuser.username)) {
await User.setUserQualified(idapp, allData.myuser.username);
// ORA HAI I 7 REQUISITI !
// const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_7_REQUISITI', allData.myuser.lang);
// telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, true); // Anche a STAFF
// Aggiungilo alla ListaIngresso
risingr = await ListaIngresso.addUserInListaIngresso(idapp, allData.myuser.username, allData.myuser.aportador_iniziale, allData.myuser.lang, true, false);
}
}
}
if (!!allData.precDataUser) {
if ((!allData.precDataUser.is9req && is9req) && !await User.isUserAlreadyQualified_2Invitati(idapp, allData.myuser.username)) {
await User.setUserQualified_2Invitati(idapp, allData.myuser.username);
// ORA HAI I 9 REQUISITI !
const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_9_REQUISITI', allData.myuser.lang);
telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, false); // Anche a STAFF
}
}
// CHECK APORTADOR SOLIDARIO:
if (!!allData.useraportador) {
/*
const is9reqAportador = await User.isUserQualified9(idapp, allData.myuser.aportador_solidario);
if (!allData.precDataAportador.is9req && is9reqAportador) {
// ORA HAI I 9 REQUISITI !
const msgtext = telegrambot.getCiao(idapp, allData.myuser.aportador_solidario, allData.useraportador.lang) + tools.gettranslate('HAI_I_9_REQUISITI', allData.useraportador.lang);
telegrambot.sendMsgTelegram(idapp, allData.myuser.aportador_solidario, msgtext, true); // Anche a STAFF
}
*/
}
};
UserSchema.statics.mettiSognoePaypal = async function (idapp, modifica) {
const User = this;
let num = 0;
arrusers = await User.find({
'idapp': idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } },
{ subaccount: { $exists: false } }, { subaccount: { $exists: true, $eq: false } }]
});
for (const rec of arrusers) {
if (rec.profile.saw_zoom_presentation) {
aggiornato = false;
my_dream_ok = !!rec.profile.my_dream;
if (my_dream_ok)
my_dream_ok = rec.profile.my_dream.length >= 8;
if (!my_dream_ok) {
if (modifica) {
rec.profile.my_dream = '............';
aggiornato = true;
}
num++;
}
revolut_ok = !!rec.profile.revolut;
paypal_ok = !!rec.profile.email_paypal;
if (paypal_ok)
paypal_ok = rec.profile.email_paypal.length > 8;
if ((!revolut_ok) && (!paypal_ok)) {
if (modifica) {
rec.profile.email_paypal = rec.email;
aggiornato = true;
}
num++;
}
if (aggiornato && modifica) {
let allData = {};
allData.myuser = await User.getUserById(idapp, rec.id);
if (!!allData.myuser)
allData.precDataUser = await User.getInfoUser(idapp, allData.myuser.username);
else
allData.precDataUser = null;
const risupd = await User.findByIdAndUpdate(rec._id, {
'profile.email_paypal': rec.profile.email_paypal,
'profile.my_dream': rec.profile.my_dream
}, { new: false });
if (risupd) {
await User.checkIfSbloccatiRequisiti(idapp, allData, rec.id);
}
}
}
}
return { num };
};
UserSchema.statics.flagUtentiNaviNonPresenti = async function (idapp) {
const User = this;

View File

@@ -15,6 +15,10 @@ const telegrambot = require('../../telegram/telegrambot');
module.exports = {
doOtherThingsAfterDeleted: async function (tablename, rec, notifBot, req) {
try {
const { User } = require('../../models/user');
const telegrambot = require('../../telegram/telegrambot');
let ris = null;
const { ListaIngresso } = require('../../models/listaingresso');
@@ -73,7 +77,7 @@ module.exports = {
addtext = 'Eliminato il Record "' + nomerecord + '" dalla tabella ' + tablename + '\n' +
'Eseguito da ' + req.user.name + ' ' + req.user.surname + ' \n';
await telegrambot.sendMsgTelegramToTheManagers(idapp, addtext);
await telegrambot.sendMsgTelegramToTheManagers(rec.idapp, addtext);
}
}

View File

@@ -65,8 +65,11 @@ UserCost = {
'profile.teleg_id',
'profile.saw_zoom_presentation',
'profile.saw_and_accepted',
'profile.revolut',
'profile.payeer_id',
'profile.advcash_id',
'profile.link_payment',
'profile.email_paypal',
'profile.my_dream',
'profile.paymenttypes']
};
@@ -289,70 +292,6 @@ router.post('/gettable', authenticate, (req, res) => {
});
async function checkIfSbloccatiRequisiti(idapp, allData, id) {
if (!allData.myuser)
return false;
if (await Nave.checkIfNaveExist(idapp, allData.myuser.username)) {
// Se già sei dentro la Nave, allora sei OK
return true;
}
// Controlla se Sblocca i 7 requisiti
const is7req = await User.isUserQualified7(idapp, allData.myuser.username);
const is9req = await User.isUserQualified9(idapp, allData.myuser.username);
const userlista = await ListaIngresso.getListaTessByUsername(idapp, allData.myuser.username);
if (userlista.length === 0) {
// Se non sono ancora dentro alla lista, allora controllo
if (!!allData.precDataUser) {
if ((!allData.precDataUser.is7req && is7req) && !await User.isUserAlreadyQualified(idapp, allData.myuser.username)) {
await User.setUserQualified(idapp, allData.myuser.username);
// ORA HAI I 7 REQUISITI !
// const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_7_REQUISITI', allData.myuser.lang);
// telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, true); // Anche a STAFF
// Aggiungilo alla ListaIngresso
risingr = await ListaIngresso.addUserInListaIngresso(idapp, allData.myuser.username, allData.myuser.aportador_iniziale, allData.myuser.lang, true, false);
}
}
}
if (!!allData.precDataUser) {
if ((!allData.precDataUser.is9req && is9req) && !await User.isUserAlreadyQualified_2Invitati(idapp, allData.myuser.username)) {
await User.setUserQualified_2Invitati(idapp, allData.myuser.username);
// ORA HAI I 9 REQUISITI !
const msgtext = telegrambot.getCiao(idapp, allData.myuser.username, allData.myuser.lang) + tools.gettranslate('HAI_I_9_REQUISITI', allData.myuser.lang);
telegrambot.sendMsgTelegram(idapp, allData.myuser.username, msgtext, false); // Anche a STAFF
}
}
// CHECK APORTADOR SOLIDARIO:
if (!!allData.useraportador) {
/*
const is9reqAportador = await User.isUserQualified9(idapp, allData.myuser.aportador_solidario);
if (!allData.precDataAportador.is9req && is9reqAportador) {
// ORA HAI I 9 REQUISITI !
const msgtext = telegrambot.getCiao(idapp, allData.myuser.aportador_solidario, allData.useraportador.lang) + tools.gettranslate('HAI_I_9_REQUISITI', allData.useraportador.lang);
telegrambot.sendMsgTelegram(idapp, allData.myuser.aportador_solidario, msgtext, true); // Anche a STAFF
}
*/
}
}
async function getInfoUser(idapp, username) {
return {
username,
is7req: await User.isUserQualified7(idapp, username),
is9req: await User.isUserQualified9(idapp, username),
}
}
router.patch('/setlang', authenticate, async (req, res) => {
const username = req.body.data.username;
@@ -407,7 +346,7 @@ router.patch('/chval', authenticate, async (req, res) => {
allData = {};
allData.myuser = await User.getUserById(idapp, id);
if (!!allData.myuser)
allData.precDataUser = await getInfoUser(idapp, allData.myuser.username);
allData.precDataUser = await User.getInfoUser(idapp, allData.myuser.username);
else
allData.precDataUser = null;
// allData.useraportador = await ListaIngresso.getUserByInvitante_Username(idapp, allData.myuser.aportador_solidario);
@@ -513,7 +452,7 @@ router.patch('/chval', authenticate, async (req, res) => {
if (mydata.table === 'users') {
if (camporequisiti) {
await checkIfSbloccatiRequisiti(idapp, allData, id);
await User.checkIfSbloccatiRequisiti(idapp, allData, id);
}
}
@@ -524,6 +463,14 @@ router.patch('/chval', authenticate, async (req, res) => {
}
if (mydata.table === 'users') {
if ('saw_zoom_presentation' in fieldsvalue) {
if (fieldsvalue['saw_zoom_presentation']) {
const messaggio = tools.get__('ZOOM_CONFERMATO');
await telegrambot.sendMsgTelegram(idapp, myuser.username, messaggio);
await telegrambot.sendMsgTelegramToTheManagersAndZoomeri(idapp, `L\'utente ${rec.name} ${rec.surname} (${rec.username}) è stato confermato per aver visto lo Zoom di Benvenuto`);
}
}
if ('aportador_solidario' in fieldsvalue) {
ind_order_ingr = mydata.ind_order_ingr;
// SERVE SE CI METTO LE MINUSCOLE/MAIUSCOLE SBAGLIATE in invitante_username!
@@ -760,8 +707,11 @@ router.patch('/callfunz', authenticate, async (req, res) => {
// ELIMINO LA LISTAINGRESSO CHE STO SOSTITUENDO (SOLO SE NON VIENE USATA DA ALTRA NAVE!)
let eliminatoingr = await ListaIngresso.eliminaListaIngresso(idapp, mianavedasost.ind_order, req, mianavedasost.num_tess);
if (!eliminatoingr){
return res.send({ code: server_constants.RIS_CODE_ERR, msg: 'La Sostituzione non può avvenire ! Contattare Paolo. (ind_order=' + mianavedasost.ind_order + ')' });
if (!eliminatoingr) {
return res.send({
code: server_constants.RIS_CODE_ERR,
msg: 'La Sostituzione non può avvenire ! Contattare Paolo. (ind_order=' + mianavedasost.ind_order + ')'
});
}
}
}
@@ -937,6 +887,17 @@ router.patch('/callfunz', authenticate, async (req, res) => {
}
}
} else if (mydata.myfunc === shared_consts.CallFunz.ZOOM_GIA_PARTECIPATO) {
if (!!myuser.username) {
FormDaMostrare = telegrambot.getFormDaMostrare(idapp, mydata.myfunc, myuser);
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${myuser.name} ${myuser.surname} (${myuser.username}) ha detto di aver già visto lo Zoom di Benvenuto`, false, FormDaMostrare);
const ris = await User.findByIdAndUpdate(myuser.id, { $set: { 'profile.ask_zoom_partecipato': true } });
if (ris)
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
}
}
return res.send({ code: server_constants.RIS_CODE_ERR });
@@ -1036,7 +997,10 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
if (cancellato) {
// Do extra things after deleted
return actions.doOtherThingsAfterDeleted(tablename, myrec, notifBot, req);
ris = await actions.doOtherThingsAfterDeleted(tablename, myrec, notifBot, req);
if (!!ris) {
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
}
}
res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });

View File

@@ -33,7 +33,7 @@ router.post('/load', async (req, res) => {
num_teleg_pending: await User.getUsersTelegramPending(idapp),
// num_qualificati: await User.getNumUsersQualified(idapp, 2),
// num_requisiti: await User.getNumUsersQualified(idapp, 0),
num_modalita_pagamento: await User.getnumPaymentOk(idapp),
// num_modalita_pagamento: await User.getnumPaymentOk(idapp),
num_part_zoom: await User.getUsersZoom(idapp),
num_part_accepted: await User.getSaw_and_Accepted(idapp),
arr_nations: await User.findAllDistinctNationality(idapp),

View File

@@ -68,11 +68,10 @@ router.post('/', async (req, res) => {
return 1;
}
if (tools.blockwords(body.username)) {
tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
await tools.snooze(100000);
res.status(400).send({ code: server_constants.RIS_CODE_USERNAME_NOT_VALID, msg: '' });
return 1;
if (tools.blockwords(body.username) || tools.blockwords(body.name) || tools.blockwords(body.surname)) {
// tools.writeIPToBan(user.ipaddr + ': [' + user.username + '] ' + user.name + ' ' + user.surname);
await tools.snooze(5000);
return res.status(404).send();
}
@@ -168,6 +167,8 @@ router.post('/', async (req, res) => {
user.profile.saw_and_accepted = recorig.profile.saw_and_accepted;
user.profile.my_dream = recorig.profile.my_dream;
user.profile.email_paypal = recorig.profile.email_paypal;
user.profile.payeer_id = recorig.profile.payeer_id;
user.profile.advcash_id = recorig.profile.advcash_id;
user.profile.revolut = recorig.profile.revolut;
user.profile.link_payment = recorig.profile.link_payment;
user.profile.note_payment = recorig.profile.note_payment;
@@ -507,6 +508,10 @@ async function eseguiDbOp(idapp, mydata, locale) {
ris = await User.flagUtentiNaviNonPresenti(idapp);
} else if (mydata.dbop === 'generaFlotte') {
ris = await NavePersistente.generaFlotte(idapp);
} else if (mydata.dbop === 'mettiSognoePaypal') {
ris = await User.mettiSognoePaypal(idapp, true);
} else if (mydata.dbop === 'mettiSognoePaypalView') {
ris = await User.mettiSognoePaypal(idapp, false);
} else if (mydata.dbop === 'addNavePerUtentiNaviNonPresenti') {
ris = await User.addNavePerUtentiNaviNonPresenti(idapp);
} else if (mydata.dbop === 'creaTessituraeConv') {

View File

@@ -244,8 +244,13 @@ const NOME_COGNOME = 'nomecognome';
const CHEDI_SE_IMBARCARTI = 'chiedi_se_imbarcarti';
const InlineCmd = {
VOGLIO_IMBARCARMI: 'voglio_imbarcarmi',
NON_VOGLIO_IMBARCARMI: 'non_voglio_imbarcarmi'
VOGLIO_IMBARCARMI: 'w_imb',
NON_VOGLIO_IMBARCARMI: 'nw_imb'
};
const InlineZoomConferma = {
CONFERMA_ZOOM_PRESENZA: 'conf_pres',
NON_CONFERMA_ZOOM_PRESENZA: 'nonconf_pres'
};
const SendMsgCmd = [CONTA_SOLO, RICEVI_EMAIL, NOME_COGNOME, CHEDI_SE_IMBARCARTI];
@@ -473,6 +478,30 @@ module.exports = {
REGISTRATION: 1
},
getFormDaMostrare: function (idapp, myfunc, myuser) {
FormDaMostrare = null;
const cl = getclTelegByidapp(idapp);
if (myfunc === shared_consts.CallFunz.ZOOM_GIA_PARTECIPATO) {
FormDaMostrare = cl.getInlineKeyboard(myuser.lang, [
{
text: 'Conferma Presenza Zoom',
// callback_data: { action: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA, username: myuser.username }
callback_data: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA + '|' + myuser.username
},
{
text: 'Annulla Presenza Zoom',
// callback_data: { action: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA, username: myuser.username }
callback_data: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA + '|' + myuser.username
},
]);
}
return FormDaMostrare;
},
getCiao: function (idapp, username, lang) {
return tools.gettranslate('CIAO', lang) + ' ' + username + '!\n';
},
@@ -511,7 +540,7 @@ module.exports = {
},
sendMsgTelegramToTheManagers: async function (idapp, text, onlyintofile) {
sendMsgTelegramToTheManagers: async function (idapp, text, onlyintofile, MyForm = null) {
tools.writeManagersLog(text);
@@ -519,8 +548,26 @@ module.exports = {
const usersmanagers = await User.getusersManagers(idapp);
if (usersmanagers) {
for (const rec of usersmanagers) {
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + ': ' + text, undefined, undefined, true);
await tools.snooze(200)
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + ': ' + text, undefined, undefined, true, MyForm);
await tools.snooze(100)
}
}
}
return true
},
sendMsgTelegramToTheManagersAndZoomeri: async function (idapp, text, onlyintofile, MyForm = null) {
tools.writeManagersLog(text);
if (!onlyintofile) {
// const usersmanagers = await User.getusersManagersAndZoomeri(idapp);
const usersmanagers = await User.getusersManagers(idapp);
if (usersmanagers) {
for (const rec of usersmanagers) {
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + ': ' + text, undefined, undefined, true, MyForm);
await tools.snooze(100)
}
}
}
@@ -560,6 +607,10 @@ module.exports = {
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
if (!!user.profile.revolut)
msg = msg.replace('{revolut}', user.profile.revolut);
if (!!user.profile.payeer_id)
msg = msg.replace('{payeer_id}', user.profile.payeer_id);
if (!!user.profile.advcash_id)
msg = msg.replace('{advcash_id}', user.profile.advcash_id);
if (!!user.profile.email_paypal)
msg = msg.replace('{email_paypal}', user.profile.email_paypal);
if (!!user.profile.note_payment)
@@ -691,7 +742,7 @@ module.exports = {
strout += '\n (' + index + ') ' + user.name + ' ' + user.surname + ':';
if (mydata.inviareale) {
await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg, undefined, undefined, true);
await tools.snooze(300);
await tools.snooze(100);
strout += ' -> (MSG OK)';
if (mydata.inviaemail && !!user.email) {
@@ -836,7 +887,7 @@ module.exports = {
return ris;
},
sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec) {
sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec, MyForm = null) {
if (!idtelegram)
return;
@@ -844,7 +895,7 @@ module.exports = {
if (cl && idtelegram) {
let myform = null;
return await cl.sendMsg(idtelegram, text, null, null, message_id, chat_id, ripr_menuPrec)
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id, chat_id, ripr_menuPrec)
}
}
@@ -912,7 +963,7 @@ async function local_sendMsgTelegramToTheManagers(idapp, text, msg, username_bo)
if (cl && idtelegram) {
await cl.sendMsg(idtelegram, text, undefined, undefined, undefined, undefined, true)
}
await tools.snooze(300)
await tools.snooze(100)
}
}
return true
@@ -1357,7 +1408,6 @@ class Telegram {
ispayment(user) {
if (user) {
let ispaypal = false;
if (!!user.profile.paymenttypes) {
/*if (user.profile.paymenttypes.includes('paypal')) {
if (user.profile.email_paypal) {
@@ -1737,7 +1787,7 @@ class Telegram {
let help = "";
let helpaperta = true;
if (tools.isMonToSat() && tools.isBetweenTwoTime('8:00:00', '19:50:00')) {
if (tools.isMonToFri() && tools.isBetweenTwoTime('9:00:00', '19:00:00')) {
help = '✅ ' + this.getlink('help');
} else {
help = "🔴 [ORA CHIUSA - NOW CLOSED]";
@@ -2021,11 +2071,13 @@ class Telegram {
FormDaMostrare = this.getInlineKeyboard(lang, [
{
text: Menu[lang].SI,
callback_data: { action: InlineCmd.VOGLIO_IMBARCARMI, username: utente.username }
// callback_data: { action: InlineCmd.VOGLIO_IMBARCARMI, username: utente.username }
callback_data: InlineCmd.VOGLIO_IMBARCARMI + '|' + utente.username
},
{
text: Menu[lang].NO,
callback_data: { action: InlineCmd.NON_VOGLIO_IMBARCARMI, username: utente.username }
// callback_data: { action: InlineCmd.NON_VOGLIO_IMBARCARMI, username: utente.username }
callback_data: InlineCmd.NON_VOGLIO_IMBARCARMI + '|' + utente.username
},
]);
inviaveramente = true;
@@ -2053,16 +2105,16 @@ class Telegram {
// break;
}
await tools.snooze(300);
await tools.snooze(100);
nummsgsent++;
}
if (!SendMsgCmd.includes(cmd)) {
if ((nummsgsent % 50) === 0) {
myid = await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(this.getlang(msg), 'MSG_MSG_INCORSO'), null, { message_id: myid });
await tools.snooze(300)
if ((nummsgsent % 100) === 0) {
myid = await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(this.getlang(msg), 'MSG_MSG_INCORSO'), null, null, myid);
await tools.snooze(100)
}
}
}
@@ -2404,6 +2456,7 @@ class Telegram {
return res;
} catch (e) {
console.error(e);
return 0
}
}
@@ -2627,7 +2680,22 @@ if (!tools.testing()) {
const myclTelegram = getclTelegBytoken(bot.token);
const data = callbackQuery.data;
let dataarr = [];
let data = {
action: 0,
username: ''
};
const datastr = callbackQuery.data;
if (!!datastr) {
dataarr = datastr.split("|");
if (!!dataarr) {
data = {
action: dataarr[0],
username: dataarr[1],
}
}
}
const msg = callbackQuery.message;
const opts = {
chat_id: msg.chat.id,
@@ -2654,6 +2722,14 @@ if (!tools.testing()) {
const msgadd = '[' + user.username + '] ' + user.name + ' ' + user.surname + ' ha risposto che NON VUOLE IMBARCARSI !';
await local_sendMsgTelegramToTheManagers(user.idapp, msgadd, msg, false); // Anche a STAFF
} else if (data.action === InlineZoomConferma.CONFERMA_ZOOM_PRESENZA) {
await User.setZoomPresenza(user.idapp, user._id, true);
} else if (data.action === InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA) {
await User.setZoomPresenza(user.idapp, user._id, false);
}
}
}

View File

@@ -55,10 +55,10 @@ textlang = {
"partecipanti": "partecipanti",
'TESTO_ASSISTENZA': "<strong><a href=\"%s\">👉 Per entrare nel Sito AYNI</a></strong>\n\n" +
"👉 <strong><a href=\"https://ayni.gifteconomy.app/requestresetpwd\">Hai dimenticato la password?</a></strong>\n\n" +
"👉 Entra nel Canale d'Informazione per Importanti Avvisi!\n<strong><a href=\"%s\">Canale AYNI-BIBLIO</a></strong>\n\n" +
"👉 <strong>Chat AYNI - EMPOWER</strong>: Entra ⛩ nella nostra Community chat\n%s\n\n" +
"👉 Canale News e Informazioni <strong><a href=\"%s\">AYNI-BIBLIO</a></strong>\n\n" +
"👉 <strong>PER AIUTO</strong>: Leggi le Domande più Frequenti:\n%s\n\n" +
"Chat di Supporto <strong>'AYNI - HELP'</strong>\n<strong>Da Lunedì al Sabato (8:00 - 20:00)</strong>\n%s\n" +
"👉 <strong>PER AIUTO</strong>: Leggi le Domande più Frequenti:\n%s\n<b>Oppure chiedi prima al tuo Invitante!</b>\n\n" +
"SOLO se non trovi la risposta che ti serve puoi accedere alla Chat di Supporto <strong>'AYNI - HELP'</strong>\n<strong>Da Lunedì al Venerdí (9:00 - 19:00)</strong>\n%s\n" +
"1 - Fai la tua <strong>domanda</strong> e chiedi assistenza.\n2 - Dopo aver ricevuto aiuto <strong>Esci dalla chat</strong>.\nPotrai rientrare ogni qualvolta ne avrai la necessità.",
'BENVENUTO': "Benvenuto",
'TUE_NAVI': "Ecco le tue Navi programmate",
@@ -117,6 +117,7 @@ textlang = {
'NAVE': 'NAVE',
'MSG_SEND_FROM': 'Msg Inviato da',
'VUOI_IMBARCARTI': 'Attenzione! Ci risulta che attualmente non ti è stato assegnato <strong>Nessun Imbarco</strong>.\nQuesto può essere dovuto ad un errore durante la fase di aggiornamento del sito, oppure perchè tu stesso hai cancellato l\'imbarco.\n\n<strong>Vuoi Aggiungerti ora al prossimo Imbarco per continuare nel tuo Viaggio in AYNI</strong>? ',
'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!',
},
si: {
"Email je že bila preverjena": "Email je že bila preverjenaL'Email è già stata Verificata",
@@ -185,6 +186,7 @@ textlang = {
'NAVE': 'LADJE',
'MSG_SEND_FROM': 'sporočilo, ki ga je poslal',
'VUOI_IMBARCARTI': 'Pozor! Opazili smo, da ti trenutno ni bila dodeljena <strong>Nobena ladjica</strong>.\nTo je lahko posledica napake med fazo posodabljanja spletnega mesta ali ker si sam zbrisal svoj vpis.\n\n<strong>Ali želiš nadaljevati plovbo, če želiš nadaljevati potovanje z AYNI </strong>?',
'ZOOM_CONFERMATO': 'Potrjeno je bilo, da ste videli dobrodošlico video konference!',
},
es: {
"L'Email è già stata Verificata": "El correo electrónico ya ha sido verificado",
@@ -195,7 +197,7 @@ textlang = {
"¿Olvidó su contraseña para acceder al sitio?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n" +
"Chat AYNI BOT (este):\nhttps://t.me/notevoleaynibot\n\n" +
"Chat AYNI - EMPOWER: Entra en ⛩ en nuestra comunidad de chat:\n%s\n\n" +
"Chat de ayuda y soporte: 'AYNI - HELP'\nDe lunes a sábado (8:00 - 21:00)\n%s\n" +
"Chat de ayuda y soporte: 'AYNI - HELP'\nDe lunes a viernes (9:00 - 19:00)\n%s\n" +
"1 - Haga su pregunta y pida ayuda.\n2 - Después de que consigas ayuda, sal de la sala de chat.\nPuedes volver cuando necesites ayuda..",
'BENVENUTO': "Bienvenido",
'TUE_NAVI': "Aquí están sus naves programadas",
@@ -251,6 +253,7 @@ textlang = {
'NAVE': 'NAVE',
'MSG_SEND_FROM': 'Mensaje enviado por',
'VUOI_IMBARCARTI': '¡Atención! Entendemos que actualmente no está asignado a <strong>No Boarding</strong>.\nEsto puede deberse a un error durante la fase de actualización del sitio web, o porque usted mismo ha cancelado el embarque.\n\n¿Quieres añadirte ahora al próximo embarque para continuar tu viaje en AYNI?',
'ZOOM_CONFERMATO': '¡Se ha confirmado que ha visto la Video Conferencia de Bienvenida!',
},
enUs: {
"partecipanti": "participants",
@@ -258,7 +261,7 @@ textlang = {
"https://ayni.gifteconomy.app/requestresetpwd\nChat AYNI BOT (this one):\nhttps://t.me/notevoleaynibot\n\n" +
"Chat AYNI - EMPOWER: Enter ⛩ into our chat community:\n%s\n\n" +
"Canale News AYNI-BIBLIO:\n%s\n\n" +
"Help and Support Chat: 'AYNI - HELP'.\nMonday to Saturday (8:00 - 20:00)\n%s\n" +
"Help and Support Chat: 'AYNI - HELP'.\nMonday to Friday (9:00 - 19:00)\n%s\n" +
"1 - Ask your question and ask for assistance.\n2 - After receiving help, exit the chat.\nYou can come back whenever you need help.",
'BENVENUTO': "Welcome",
'TUE_NAVI': "Here are your programmed ships",
@@ -314,6 +317,7 @@ textlang = {
'NAVE': 'SHIP',
'MSG_SEND_FROM': 'Msg sent by',
'VUOI_IMBARCARTI': 'Attention! We understand that you have <strong>No Boarding</strong> assigned.\nThis may be due to an error during the site update phase, or because you have cancelled boarding yourself.\n\n<strong>Do you want to add now to the Next Boarding to continue your AYNI Trip</strong>?',
'ZOOM_CONFERMATO': 'You have been confirmed to have seen the Welcome Video Conference!',
},
fr: {
"L'Email è già stata Verificata": "Le courrier électronique a déjà été vérifié",
@@ -325,7 +329,7 @@ textlang = {
"Chat AYNI BOT (ce):\nhttps://t.me/notevoleaynibot\n\n" +
"Chat AYNI - EMPOWER : Entrez ⛩ dans notre Community chat:\n%s\n\n" +
"Canale News AYNI-BIBLIO:\n%s\n\n" +
"Chat dAide et de Support: 'AYNI - HELP'\nDu lundi au samedi (8:00 - 20:00)\n%s\n" +
"Chat dAide et de Support: 'AYNI - HELP'\nDu lundi au Vendredi (9:00 - 19:00)\n%s\n" +
"1 - Posez votre question et demandez dêtre assisté.\n2 - Après avoir reçu laide, quittez le groupe.\nVous pourrez y entrer chaque fois quil vous sera nécessaire.",
'BENVENUTO': "Bienvenue",
'TUE_NAVI': "Voici vos navires programmés",
@@ -381,6 +385,7 @@ textlang = {
'NAVE': 'NAVIRE',
'MSG_SEND_FROM': 'Message envoyé par',
'VUOI_IMBARCARTI': 'Attention ! Nous comprenons que vous n\'êtes actuellement pas affecté <strong>Pas d\'embarquement</strong>.\nCela peut être dû à une erreur lors de la phase de mise à jour du site, ou parce que vous avez vous-même annulé l\'embarquement.\n\n<strong>Voulez-vous vous ajouter maintenant au prochain embarquement pour continuer votre voyage AYNI</strong> ? ',
'ZOOM_CONFERMATO': 'Vous avez été confirmé comme ayant vu la vidéoconférence de bienvenue !',
},
pt: {
"L'Email è già stata Verificata": "",
@@ -392,7 +397,7 @@ textlang = {
"Chat AYNI BOT (isto):\nhttps://t.me/notevoleaynibot\n\n" +
"Chat AYNI - EMPOWER: Entrar em ⛩ na nossa comunidade de chat:%s\n\n" +
"Canale News AYNI-BIBLIO:\n%s\n\n" +
"Chat de Ajuda e Suporte: 'AYNI - HELP'.\nDe segunda a sábado (8:00 - 20:00 ITALY)\n%s\n" +
"Chat de Ajuda e Suporte: 'AYNI - HELP'.\nDe segunda a Sexta (9:00 - 19:00 ITALY)\n%s\n" +
"1 - Faça a sua pergunta e peça ajuda.\n2 - Depois de receber ajuda, saia do chat.\nPode voltar sempre que precisar de o fazer..",
'BENVENUTO': "Bem-vindo",
'TUE_NAVI': "Aqui estão os seus navios programados",
@@ -448,6 +453,7 @@ textlang = {
'NAVE': 'NAVE',
'MSG_SEND_FROM': 'Mensagem enviada por',
'VUOI_IMBARCARTI': 'Atenção! Compreendemos que actualmente não lhe é atribuído <strong>Sem Embarque</strong>.\nIsto pode ser devido a um erro durante a fase de actualização do site, ou porque você mesmo cancelou o embarque.\n\n<strong>Deseja juntar-se agora ao próximo embarque para continuar a sua viagem AYNI</strong>?',
'ZOOM_CONFERMATO': 'Foi-lhe confirmado que assistiu à Conferência de Vídeo de Boas-vindas!',
},
};
@@ -1006,6 +1012,8 @@ module.exports = {
filtriadded.push({ 'profile.qualified': true });
if (params.filterand.includes(shared_consts.FILTER_USER_NO_ZOOM))
filtriadded.push({ 'profile.saw_zoom_presentation': false });
if (params.filterand.includes(shared_consts.FILTER_ASK_ZOOM_VISTO))
filtriadded.push({ 'profile.ask_zoom_partecipato': false });
if (params.filterand.includes(shared_consts.FILTER_USER_NO_INVITANTE))
filtriadded.push({
aportador_solidario: { $exists: false }
@@ -1184,6 +1192,11 @@ module.exports = {
return dayOfWeek >= 1 && dayOfWeek <= 6
},
isMonToFri() {
const dayOfWeek = new Date(new Date()).getDay();
return dayOfWeek >= 1 && dayOfWeek <= 5
},
// var startTime = '15:10:10';
// var endTime = '22:30:00';
isBetweenTwoTime(startTime, endTime) {
@@ -1740,9 +1753,12 @@ module.exports = {
},
blockwords(mystr) {
if (mystr.includes('ttp')) {
const arrwords = ['http', 'Http', 'Asasfasfas', '://', 'mrbit'];
for (const myword of arrwords) {
if (mystr.includes(myword)) {
return true;
}
}
return false;
},

View File

@@ -22,6 +22,7 @@ module.exports = {
FILTER_NASCOSTI: 4096,
FILTER_NAVI_NON_PRESENTI: 8192,
FILTER_QUALIFIED: 16384,
FILTER_ASK_ZOOM_VISTO: 32768,
Permissions: {
Admin: 1,
@@ -29,6 +30,7 @@ module.exports = {
Teacher: 4,
Tutor: 8,
Traduttrici: 16,
Zoomeri: 32,
},
MessageOptions: {
@@ -53,6 +55,7 @@ module.exports = {
DAMMI_PRIMO_UTENTE_LIBERO: 390,
GET_VALBYTABLE: 400,
SET_VALBYTABLE: 410,
ZOOM_GIA_PARTECIPATO: 510
},
fieldsUserToChange() {