Aggiornamenti

This commit is contained in:
Paolo Arena
2020-04-24 10:29:25 +02:00
parent 4a9fa9cf61
commit 2549d43447
21 changed files with 733 additions and 390 deletions

View File

@@ -135,14 +135,14 @@ if (process.env.NODE_ENV === 'production') {
{
idapp: '9',
name: 'SalviamoIlPianeta',
adminemail: 'noisalviamoilpianeta@gmail.com',
adminemail: 'salviamoilpianeta2020@gmail.com',
manageremail: '',
replyTo: '',
host: 'https://salviamoilpianeta.app',
portapp: '0',
dir: '/var/www/salviamoilpianeta.app',
email_from: 'noisalviamoilpianeta@gmail.com',
email_pwd: '',
email_from: 'salviamoilpianeta2020@gmail.com',
email_pwd: 'c6f63e7aba9393c73f56e338a7fe5283a73949363662d26bd375dd05b6f6f37ebkw4vINQ0O/4d8JN71aNH3UsyndeFRgyyMvJMVl4iOk=',
telegram_key:'1202788747:AAErwzIsD7k-3Yj5AX6ci3p7ELMuyASq4vA',
telegram_bot_name: 'SalviamoIlPianeta_bot',
pathreg_add:'_sip',
@@ -263,7 +263,7 @@ if (process.env.NODE_ENV === 'production') {
{
idapp: '9',
name: 'SalviamoIlPianeta (Server Test)',
adminemail: 'noisalviamoilpianeta@gmail.com',
adminemail: 'info.pianetalibero@gmail.com',
manageremail: '',
replyTo: '',
host: 'https://test.salviamoilpianeta.app',
@@ -271,8 +271,8 @@ if (process.env.NODE_ENV === 'production') {
dir: '/var/www/test.salviamoilpianeta.app',
email_from: 'info.pianetalibero@gmail.com',
email_pwd: '2df135e2b6c02b2c68ec6bf6b103751fcb4dfc48c57d0acb302482358ee8141fmaDuooPabDvlThiBI2XMyA==',
telegram_key:'1049833543:AAE1RhGUJVdm0N_vrj0ijHZ04GCkKjl8TuQ',
telegram_bot_name: 'TestSalviamoIlPianeta_bot',
telegram_key:'',
telegram_bot_name: '',
pathreg_add:'_sip',
abilitanave: false,
},
@@ -396,8 +396,11 @@ if (process.env.NODE_ENV === 'production') {
dir: '',
email_from: 'info.pianetalibero@gmail.com',
email_pwd: '66ffeb915e71fada64ad5c26947dd087c262be3b343734a0447c6dee534b888aZcfbjXEuMBWKxvbh60cniw==',
telegram_bot_name: 'paotestlocalebot',
telegram_key:'353996190:AAEcEbfrm_zTK6mBKf8ye9j-PXt958SDxew',
telegram_key: '',
telegram_bot_name: '',
// telegram_key:'1049833543:AAE1RhGUJVdm0N_vrj0ijHZ04GCkKjl8TuQ',
// telegram_bot_name: 'TestSalviamoIlPianeta_bot',
pathreg_add:'_sip',
abilitanave: false,
},

View File

@@ -1,6 +1,6 @@
const server_constants = require('../tools/server_constants');
var {User} = require('../models/user');
var { User } = require('../models/user');
const tools = require('../tools/general');
@@ -12,6 +12,7 @@ const authenticate = (req, res, next) => {
const access = 'auth';
User.findByToken(token, access).then((user) => {
if (!user) {
// tools.mylog("TOKEN " + token);
// tools.mylog(" NOT FOUND! (Maybe Connected to other Page) ACCESS: '" + access + "'");
@@ -19,15 +20,26 @@ const authenticate = (req, res, next) => {
// res.status().send();
}
// Save last time online
user.lasttimeonline = new Date();
if (!!user.deleted) {
if (user.deleted)
user = null;
}
return user.save().then(() => {
req.user = user;
req.token = token;
req.access = access;
next();
});
if (!user) {
return Promise.reject(server_constants.RIS_CODE_HTTP_INVALID_TOKEN);
}
if (!!user) {
// Save last time online
user.lasttimeonline = new Date();
return user.save().then(() => {
req.user = user;
req.token = token;
req.access = access;
next();
});
}
// tools.mylog('userid', user._id);
}).catch((e) => {
@@ -46,7 +58,7 @@ const authenticate_noerror = (req, res, next) => {
req.user = null;
req.token = null;
req.access = null;
}else {
} else {
req.user = user;
req.token = token;
req.access = access;
@@ -59,4 +71,4 @@ const authenticate_noerror = (req, res, next) => {
});
};
module.exports = {authenticate, authenticate_noerror};
module.exports = { authenticate, authenticate_noerror };

View File

@@ -53,7 +53,7 @@ CalZoomSchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp, date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 3) } };
return await CalZoom.find(myfind).sort({ date_start: 1 }).limit(6);
return await CalZoom.find(myfind).sort({ date_start: 1 }).limit(10);
};
CalZoomSchema.statics.getNextZoom = async function (idapp) {

View File

@@ -17,7 +17,9 @@ const cfgserverSchema = new Schema({
required: true,
trim: true,
minlength: 1,
unique: true,
},
idapp: {
type: String,
},
userId: {
type: String,

View File

@@ -29,9 +29,6 @@ const ListaIngressoSchema = new mongoose.Schema({
type: String,
required: true,
},
indprimario: {
type: Number,
},
ind_order: {
type: Number,
},
@@ -52,24 +49,6 @@ const ListaIngressoSchema = new mongoose.Schema({
});
ListaIngressoSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await ListaIngresso.findOne().limit(1).sort({ indprimario: -1 });
if (!!myrec) {
if (myrec._doc.indprimario === 0)
this.indprimario = 1;
else
this.indprimario = myrec._doc.indprimario + 10;
} else {
this.indprimario = 10;
}
}
next();
});
// ListaIngressoSchema.methods.toJSON = function () {
// const ListaIngresso = this;
// const userObject = ListaIngresso.toObject();
@@ -94,13 +73,6 @@ ListaIngressoSchema.statics.getTotInLista = async function (idapp) {
return await ListaIngresso.count(myfind);
};
ListaIngressoSchema.statics.getOrderedList = function (idapp) {
const ListaIngresso = this;
return ListaIngresso.findOne({ idapp }).sort({ indprimario: -1 })
};
ListaIngressoSchema.statics.findByIndOrder = function (idapp, ind_order) {
const ListaIngresso = this;
@@ -271,10 +243,12 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov
num_tess: 1,
added: 1,
deleted: 1,
sospeso: 1,
};
let myfilter2 = {
username: { $exists: true },
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
};
if (solonuovi) {
@@ -292,7 +266,7 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov
}, myobjField, myfilter2);
}
arrrec = await ListaIngresso.aggregate(myquery).sort({ indprimario: 1 })
arrrec = await ListaIngresso.aggregate(myquery).sort({ ind_order: 1 })
.then(async (arrlista) => {
const { User } = require('../models/user');

View File

@@ -34,9 +34,6 @@ const NaveSchema = new mongoose.Schema({
col: {
type: Number,
},
indprimario: {
type: Number,
},
ind_order: {
type: Number,
},
@@ -117,19 +114,6 @@ NaveSchema.statics.findById = function (idapp, id) {
};
NaveSchema.statics.findByIndPrimario = function (idapp, indprimario) {
const Nave = this;
try {
return Nave.findOne({
idapp,
indprimario,
});
} catch (e) {
}
};
NaveSchema.statics.getFieldsForSearch = function () {
return [{ field: 'ind_order', type: tools.FieldType.number },
@@ -419,6 +403,8 @@ function getQueryProj(myfilter) {
name: 1,
surname: 1,
username: 1,
deleted: 1,
sospeso: 1,
'profile.paymenttypes': 1,
'profile.email_paypal': 1,
'profile.cell': 1,
@@ -429,7 +415,6 @@ function getQueryProj(myfilter) {
received_gift: 1,
date_received_gift: 1,
num_tess: 1,
indprimario: 1,
parent_id: 1,
riga: 1,
col: 1,
@@ -458,6 +443,7 @@ function getQueryProj(myfilter) {
$replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] }, "$$ROOT"] } }
// $replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] },] } }
},
{ $match: { $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] } },
{ $project: myobjField }
];
@@ -903,7 +889,6 @@ async function addRecordNaveByParams(params, siRitesse) {
let myNave = new Nave({
idapp: params.idapp,
indprimario: params.indprimario,
ind_order: params.ind_order,
riga: params.riga,
col: params.col,
@@ -1026,7 +1011,6 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
if (ris.deveritessersi) {
console.log('Si deve ritesere: [riga=', params.riga, 'col', params.col, ']');
if (ris.deveritessersi) {
params.indprimario = recmediatore.indprimario;
params.ind_order = recmediatore.ind_order;
params.id = recmediatore._id;
params.num_tess = ris.num_tess + 1;
@@ -1039,7 +1023,6 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
if ((params.riga === 4 + 3) && (params.col === (8 * 2) + 3)) {
// Si ritesse il Fondo AYNI nella Nave 3.3
const userFondo = await User.findByIndOrder(idapp, 0);
params.indprimario = userFondo.indprimario;
params.ind_order = userFondo.ind_order;
params.id = userFondo._id;
params.num_tess = userFondo.num_tess;
@@ -1076,7 +1059,7 @@ NaveSchema.statics.generaNave = async function (idapp, mydata) {
const recfindFondo = await Nave.findByRigaCol(params.idapp, 0, 0, true);
if (!recfindFondo) {
let myNave = new Nave({ idapp, indprimario: 0, ind_order: 0, riga: 0, col: 0 });
let myNave = new Nave({ idapp, ind_order: 0, riga: 0, col: 0 });
myNave.created = new Date();
myNave.parent_id = ObjectID("5e592aecbfd0b75f3021d9c9");
await myNave.save();
@@ -1094,7 +1077,6 @@ NaveSchema.statics.generaNave = async function (idapp, mydata) {
let index = 0;
for (const reclista of arrlistaingresso) {
params.indprimario = reclista.indprimario;
params.ind_order = reclista.ind_order;
params.id = reclista._id;
params.num_tess = reclista.num_tess;
@@ -1114,8 +1096,6 @@ async function addUserToNave(idapp, rec) {
let params = {};
params.indprimario = rec.indprimario;
params.ind_order = rec.ind_order;
params.id = rec._id;
params.num_tess = rec.num_tess;
@@ -1181,10 +1161,12 @@ NaveSchema.statics.visuNaviUtentiEliminati = async function (idapp) {
for (const rec of arrrec) {
if (!rec.username) {
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rec.riga, rec.col, 0);
mystr += '[' + conta + '] [NAVI ' + navepersistente.riga + '.' + navepersistente.col + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order;
mystr += ' num_tess = ' + rec.num_tess;
mystr += '\n';
conta++;
if (!!navepersistente) {
mystr += '[' + conta + '] [NAVI ' + navepersistente.riga + '.' + navepersistente.col + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order;
mystr += ' num_tess = ' + rec.num_tess;
mystr += '\n';
conta++;
}
}
}
@@ -1235,7 +1217,7 @@ NaveSchema.statics.getDonatoridelSognatore = async function (idapp, riganave, co
const Nave = this;
coldonatoreIni = ((colnave - 1) * 64) + (1);
coldonatoreFine = coldonatoreIni + (64);
coldonatoreFine = coldonatoreIni + (63);
const myquery = getQueryProj({
idapp,
@@ -1271,6 +1253,61 @@ NaveSchema.statics.getDonatoridelSognatore = async function (idapp, riganave, co
};
NaveSchema.statics.ricalcolaNave = async function (idapp, nave, riga1don, col1don, ricalcola, index) {
const Nave = this;
try {
if (nave === null) {
nave = await NavePersistente.findByRigaColByDonatore(idapp, riga1don, col1don, 0);
}
nave.rec = await Nave.getNaveByRigaCol(idapp, nave.riga1don, nave.col1don);
if (nave.provvisoria || (ricalcola && (nave.DoniConfermati === nave.DoniTotali) && (nave.DoniTotali >= 7) && nave.DoniMancanti === 0 && nave.DoniAttesaDiConferma === 0)) {
// gia fatto
} else {
nave.index = index;
nave.DoniTotali = 0;
nave.DoniAttesaDiConferma = 0;
nave.DoniMancanti = 0;
nave.DoniConfermati = 0;
const { User } = require('./user');
if (!!nave.tutor)
nave.tutor_namesurname = await User.getNameSurnameByUsername(idapp, nave.tutor);
if (!!nave.rec) {
if (!!nave.rec.donatore) {
nave.DoniTotali = nave.rec.donatore.arrdonatori.filter((rec) => (!(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0))).reduce((sum, item) => sum + 1, 0);
nave.DoniAttesaDiConferma = nave.rec.donatore.arrdonatori.filter((rec) => (!!rec.date_made_gift && !rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0))).reduce((sum, item) => sum + 1, 0);
nave.DoniMancanti = nave.rec.donatore.arrdonatori.filter((rec) => (!rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0))).reduce((sum, item) => sum + 1, 0);
nave.DoniConfermati = nave.rec.donatore.arrdonatori.filter((rec) => rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0)).reduce((sum, item) => sum + 1, 0);
}
}
const fieldsvalue = {
DoniAttesaDiConferma: nave.DoniAttesaDiConferma,
DoniTotali: nave.DoniTotali,
DoniMancanti: nave.DoniMancanti,
DoniConfermati: nave.DoniConfermati,
tutor_namesurname: nave.tutor_namesurname,
};
const risu = await NavePersistente.findOneAndUpdate({ _id: nave._id }, { $set: fieldsvalue }, { new: false });
nave._doc.rec = nave.rec;
}
}catch (e) {
console.error(e.message);
}
return nave;
}
const Nave = mongoose.model('Nave', NaveSchema);
module.exports = { Nave };

View File

@@ -63,6 +63,9 @@ const NavePersistenteSchema = new mongoose.Schema({
DoniConfermati: {
type: Number,
},
DoniTotali: {
type: Number,
},
note_bot: {
type: String
},
@@ -97,7 +100,6 @@ function getQueryProj(myfilter) {
received_gift: 1,
date_received_gift: 1,
num_tess: 1,
indprimario: 1,
parent_id: 1,
riga: 1,
col: 1,
@@ -175,6 +177,8 @@ NavePersistenteSchema.statics.getListaNavi = function (idapp) {
date_start: 1,
provvisoria: 1,
DoniConfermati: 1,
DoniTotali: 1,
DoniMancanti: 1,
}
).sort({ riga: 1, col: 1 });
};

View File

@@ -109,9 +109,6 @@ const UserSchema = new mongoose.Schema({
date_reg: {
type: Date,
},
date_temp_reg: {
type: Date,
},
date_tokenforgot: {
type: Date
},
@@ -139,6 +136,12 @@ const UserSchema = new mongoose.Schema({
note: {
type: String,
},
deleted: {
type: Boolean
},
sospeso: {
type: Boolean
},
profile: {
img: {
type: String
@@ -198,6 +201,15 @@ const UserSchema = new mongoose.Schema({
sex: {
type: Number,
},
chisei: {
type: String
},
iltuoimpegno: {
type: String
},
come_aiutare: {
type: String
},
},
});
@@ -317,7 +329,7 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) {
// Check if with email:
return User.findOne({ idapp, email: username.toLowerCase() })
} else {
return user
return !user.deleted ? user : null
}
}).then(user => {
if (!user)
@@ -374,6 +386,8 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username)
username: 1,
name: 1,
surname: 1,
deleted: 1,
sospeso: 1,
verified_email: 1,
'profile.teleg_id': 1,
'profile.saw_zoom_presentation': 1,
@@ -921,18 +935,22 @@ UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
UserSchema.statics.getUsersList = function (idapp) {
const User = this;
return User.find({ 'idapp': idapp }, {
username: 1,
name: 1,
surname: 1,
verified_email: 1,
made_gift: 1,
perm: 1,
email: 1,
date_reg: 1,
img: 1
})
return User.find({
'idapp': idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
},
{
username: 1,
name: 1,
surname: 1,
verified_email: 1,
made_gift: 1,
perm: 1,
email: 1,
date_reg: 1,
img: 1
}
)
};
@@ -1090,7 +1108,10 @@ UserSchema.statics.findByCellAndNameSurname = function (idapp, cell, name, surna
UserSchema.statics.getUsersRegistered = async function (idapp) {
const User = this;
const myfind = { idapp };
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
};
return await User.count(myfind);
};
@@ -1165,6 +1186,8 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) {
surname: 1,
username: 1,
ind_order: 1,
deleted: 1,
sospeso: 1,
});
@@ -1177,38 +1200,48 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) {
let num1inv = 0;
let num2inv = 0;
let numnoinlista = 0;
let numeliminati = 0;
let numsospesi = 0;
for (const user of arrusers) {
user.numinvitati = await User.getnumInvitati(idapp, user.username);
reg++;
let mianave = await Nave.findOne({ idapp, ind_order: user.ind_order });
let mialistaingresso = await ListaIngresso.findOne({ idapp, ind_order: user.ind_order });
let trovato = false;
if (!mianave) {
mystr += user.username + ' ' + user.name + ' ' + user.surname + ' [' + user.ind_order + '] [inv=' + user.numinvitati + ']'
noninnave++;
trovato = true;
if (user.deleted) {
numeliminati++;
} else {
innave++;
}
user.numinvitati = await User.getnumInvitati(idapp, user.username);
reg++;
let mianave = await Nave.findOne({ idapp, ind_order: user.ind_order });
let mialistaingresso = await ListaIngresso.findOne({ idapp, ind_order: user.ind_order });
let trovato = false;
if (!mianave) {
mystr += user.username + ' ' + user.name + ' ' + user.surname + ' [' + user.ind_order + '] [inv=' + user.numinvitati + ']'
noninnave++;
trovato = true;
} else {
innave++;
}
if (!mialistaingresso) {
mystr += ' NO IN LISTA INGRESSO!';
trovato = true;
numnoinlista++;
}
if (user.sospeso) {
numsospesi++;
}
if (trovato)
mystr += tools.ACAPO;
if (!mialistaingresso) {
mystr += ' NO IN LISTA INGRESSO!';
trovato = true;
numnoinlista++;
}
if (user.numinvitati === 0) {
num0inv++;
}
if (user.numinvitati === 1) {
num1inv++;
}
if (user.numinvitati >= 2) {
num2inv++;
if (trovato)
mystr += tools.ACAPO;
if (user.numinvitati === 0) {
num0inv++;
}
if (user.numinvitati === 1) {
num1inv++;
}
if (user.numinvitati >= 2) {
num2inv++;
}
}
}
@@ -1220,6 +1253,8 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) {
mystrstart += 'Presente in Nave: ' + innave + tools.ACAPO;
mystrstart += 'Non in Nave: ' + noninnave + tools.ACAPO;
mystrstart += 'Non in Lista Imbarco: ' + numnoinlista + tools.ACAPO;
mystrstart += 'Usciti (Nascosti): ' + numeliminati + tools.ACAPO;
mystrstart += 'Sospesi: ' + numsospesi + tools.ACAPO;
mystrstart += tools.ACAPO;
@@ -1240,7 +1275,11 @@ UserSchema.statics.getNumUsersQualified = async function (idapp, numinvitati) {
UserSchema.statics.getEmailNotVerified = async function (idapp) {
const User = this;
const myfind = { idapp, verified_email: false };
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
verified_email: false
};
return await User.count(myfind);
};
@@ -1248,7 +1287,11 @@ UserSchema.statics.getEmailNotVerified = async function (idapp) {
UserSchema.statics.getUsersTelegramAttivo = async function (idapp) {
const User = this;
const myfind = { idapp, 'profile.teleg_id': { $gt: 0 } };
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
'profile.teleg_id': { $gt: 0 }
};
return await User.count(myfind);
};
@@ -1256,7 +1299,11 @@ UserSchema.statics.getUsersTelegramAttivo = async function (idapp) {
UserSchema.statics.getUsersTelegramPending = async function (idapp) {
const User = this;
const myfind = { idapp, 'profile.teleg_checkcode': { $gt: 0 } };
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
'profile.teleg_checkcode': { $gt: 0 }
};
return await User.count(myfind);
};
@@ -1264,7 +1311,11 @@ UserSchema.statics.getUsersTelegramPending = async function (idapp) {
UserSchema.statics.getUsersZoom = async function (idapp) {
const User = this;
const myfind = { idapp, 'profile.saw_zoom_presentation': true };
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
'profile.saw_zoom_presentation': true
};
return await User.count(myfind);
};
@@ -1272,7 +1323,11 @@ UserSchema.statics.getUsersZoom = async function (idapp) {
UserSchema.statics.getSaw_and_Accepted = async function (idapp) {
const User = this;
const myfind = { idapp, 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED };
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED
};
return await User.count(myfind);
};
@@ -1282,6 +1337,7 @@ UserSchema.statics.getUsersDreams = async function (idapp) {
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
'profile.my_dream': { $exists: true },
"$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] }
};
@@ -1294,15 +1350,19 @@ UserSchema.statics.getLastUsers = async function (idapp) {
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
return await User.find({ idapp }, {
username: 1,
name: 1,
surname: 1,
date_temp_reg: 1,
date_reg: 1,
ind_order: 1,
'profile.nationality': 1,
}).sort({ date_temp_reg: -1 }).limit(lastn).then((arr) => {
return await User.find(
{
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
},
{
username: 1,
name: 1,
surname: 1,
date_reg: 1,
ind_order: 1,
'profile.nationality': 1,
}).sort({ date_reg: -1 }).limit(lastn).then((arr) => {
//return JSON.stringify(arr)
return arr
});
@@ -1362,10 +1422,10 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
const query = [
{
$match: { idapp, date_temp_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
$match: { idapp, date_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
},
{
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_temp_reg" } }, count: { $sum: 1 } }
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
},
{
$sort: { _id: 1 }
@@ -1379,10 +1439,10 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
const query = [
{
$match: { idapp, date_temp_reg: { $lt: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
$match: { idapp, date_reg: { $lt: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
},
{
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_temp_reg" } }, count: { $sum: 1 } }
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
},
{
$sort: { _id: 1 }

View File

@@ -7,14 +7,20 @@ const tools = require('../tools/general');
var { authenticate } = require('../middleware/authenticate');
router.post('/updateval', authenticate, (req, res) => {
router.post('/updateval', authenticate, async (req, res) => {
console.log('/updateval', req.body.pairval);
idapp = req.body.idapp;
pair = req.body.pairval;
cfgserver.findOneAndUpdate({chiave: pair.chiave, userID: pair.userId}, { $set: pair }, { new: false }).then((item) => {
// cfgserver.find({ chiave: pair.chiave }, (err, item) => {
res.status(200).send();
}).catch(err => {
return await cfgserver.findOneAndUpdate({ chiave: pair.chiave, idapp, userId: pair.userId }, { $set: pair }, { new: false })
.then((item) => {
// cfgserver.find({ chiave: pair.chiave }, (err, item) => {
if (!!item) {
res.status(200).send();
} else {
res.status(400).send();
}
}).catch(err => {
console.log('ERR:', err);
res.status(400).send();
})

View File

@@ -159,42 +159,25 @@ router.post('/getdoninavi', authenticate, async (req, res) => {
let index = 1;
for (nave of arrnavi) {
nave.rec = await Nave.getNaveByRigaCol(idapp, nave.riga1don, nave.col1don);
/*mypos = {
riga: nave.riga,
col: nave.col,
numup: 3,
};
tools.getRigaColByPosUp(mypos);*/
nave.index = index;
nave.DoniAttesaDiConferma = 0;
nave.DoniMancanti = 0;
nave.DoniConfermati = 0;
nave.tutor_namesurname = await User.getNameSurnameByUsername(idapp, nave.tutor);
if (!!nave.rec) {
if (!!nave.rec.donatore) {
nave.DoniAttesaDiConferma = nave.rec.donatore.arrdonatori.filter((rec) => (!!rec.date_made_gift && !rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && rec.num_tess === 2))).reduce((sum, item) => sum + 1, 0);
nave.DoniMancanti = nave.rec.donatore.arrdonatori.filter((rec) => (!rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && rec.num_tess === 2))).reduce((sum, item) => sum + 1, 0);
nave.DoniConfermati = nave.rec.donatore.arrdonatori.filter((rec) => rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && rec.num_tess === 2)).reduce((sum, item) => sum + 1, 0);
}
}
const fieldsvalue = {
DoniAttesaDiConferma: nave.DoniAttesaDiConferma,
DoniMancanti: nave.DoniMancanti,
DoniConfermati: nave.DoniConfermati,
tutor_namesurname: nave.tutor_namesurname,
};
const risu = await NavePersistente.findOneAndUpdate({ _id: nave._id }, { $set: fieldsvalue }, { new: false });
nave._doc.rec = nave.rec;
nave = await Nave.ricalcolaNave(idapp, nave, 0, 0, ricalcola, index);
index++;
}
} else {
arrnavi = await NavePersistente.findAllIdApp(idapp);
for (nave of arrnavi) {
nave._doc.rec = await Nave.getNaveByRigaCol(idapp, nave.riga1don, nave.col1don);
if (nave.provvisoria || nave.DoniTotali !== nave.DoniConfermati) {
nave._doc.rec = await Nave.getNaveByRigaCol(idapp, nave.riga1don, nave.col1don);
} else {
let rigapos = nave.riga1don;
let colpos = nave.col1don;
if (rigapos < 4) {
rigapos = 4;
colpos = 1;
}
nave._doc.rec = {};
nave._doc.rec.donatore = {};
nave._doc.rec.donatore.navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rigapos, colpos, tools.Placca.SONOFUOCO);
}
}
}

View File

@@ -388,6 +388,8 @@ router.patch('/chval', authenticate, async (req, res) => {
}
}
let index = 0;
await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }).then(async (rec) => {
// tools.mylogshow(' REC TO MODIFY: ', rec);
if (!rec) {
@@ -422,6 +424,12 @@ router.patch('/chval', authenticate, async (req, res) => {
}
}
} else if (mydata.table === 'navi') {
if ('made_gift' in fieldsvalue) {
if (!!fieldsvalue.riga) {
await Nave.ricalcolaNave(idapp, null, fieldsvalue.riga, fieldsvalue.col, true, index)
}
}
}
if (msg !== '')
@@ -433,11 +441,129 @@ router.patch('/chval', authenticate, async (req, res) => {
}
}).catch((e) => {
tools.mylogserr('Error patch USER: ', e);
tools.mylogserr('Error patch USER: ', e.message);
res.status(400).send();
})
});
router.patch('/callfunz', authenticate, async (req, res) => {
// const idapp = req.body.idapp;
const id = req.body.data.id;
const ind_order = req.body.data.ind_order;
const idapp = req.body.idapp;
const mydata = req.body.data;
try {
// If I change my record...
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm)) && !(req.user._id.toString() === id) && !tools.ModificheConsentite(mydata.table, fieldsvalue)) {
// If without permissions, exit
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
const myuser = await User.findOne({ idapp, ind_order });
let rimosso = 0;
if (mydata.myfunc === 345) { // SOSTITUISCI
mianavedasost = await Nave.findOne({ idapp, riga: mydata.data.riga, col: mydata.data.col });
// Sostituisci l'Utente
myusernuovo = await User.getUserShortDataByUsername(idapp, mydata.data.username);
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, mydata.data.riga, mydata.data.col, 0);
if (!!myusernuovo) {
// Controlla prima se è in una Nave Temporanea, allora lo elimina
miaarrnavi = await Nave.find({ idapp, ind_order: myusernuovo.ind_order });
if (miaarrnavi) {
for (const mianave of miaarrnavi) {
let persistente = await NavePersistente.findByRigaColByDonatore(idapp, mianave.riga, mianave.col, 0);
if (persistente.provvisoria) {
fieldsvalue = {
ind_order: -1
};
let ris = await Nave.findByIdAndUpdate(mianave.id, { $set: fieldsvalue });
if (!!ris) {
rimosso++;
}
}
}
}
if (!!myuser) {
// Metti campo 'delete': true su ListaIngresso
olduseringresso = await ListaIngresso.findOne({ idapp, ind_order: myuser.ind_order });
if (!!olduseringresso) {
let fieldsvalue = {
deleted: true
};
const risul = await ListaIngresso.findByIdAndUpdate(olduseringresso.id, { $set: fieldsvalue }, { new: false });
}
}
if (!!myuser) {
// Metti Deleted allo User
fieldsvalue = {
deleted: true
};
await User.findByIdAndUpdate(myuser.id, { $set: fieldsvalue });
}
// Aggiorna la Nave con il Nuovo
fieldsvalue = {
ind_order: myusernuovo.ind_order
};
const dachi = req.user.name + ' ' + req.user.surname;
return await Nave.findByIdAndUpdate(mianavedasost.id, { $set: fieldsvalue })
.then(async (rec) => {
// tools.mylogshow(' REC TO MODIFY: ', rec);
if (!rec) {
return res.status(404).send();
} else {
if (mydata.notifBot) {
// Send Notification to the BOT
let messaggio = 'Sei stato Spostato in una Nuova Nave !';
if (!!navepersistente.date_start) {
messaggio += tools.ACAPO + ' data di Partenza della Nave: ' + tools.getstrDateLong(navepersistente.date_start) + tools.ACAPO;
}
if (!!navepersistente.link_chat) {
messaggio += tools.ACAPO + 'Entra nella Gift Chat: ' + navepersistente.link_chat + tools.ACAPO;
}
const myplacca = await Nave.getNavePos(idapp, navepersistente.riga, navepersistente.col);
messaggio += tools.ACAPO + myplacca;
await telegrambot.sendMsgTelegram(idapp, myusernuovo.username, messaggio);
await telegrambot.sendMsgTelegramToTheManagers(idapp, mydata.notifBot.txt + ' ' + myusernuovo.name + ' ' + myusernuovo.surname + ' [da ' + dachi + ']' + tools.ACAPO + 'Inviato messaggio: ' + messaggio);
await telegrambot.sendMsgTelegram(idapp, req.user.username, mydata.notifBot.txt);
await telegrambot.sendMsgTelegram(idapp, req.user.username, myplacca);
}
// const nomecognomeprima = myuser.name + ' ' + myuser.surname + '(' + myuser.username + ')';
// const nomecognomenuovo = await User.getNameSurnameByUsername(idapp,);
res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
}
}).catch((e) => {
tools.mylogserr('Error patch USER: ', e);
res.status(400).send();
})
}
}
} catch (e) {
console.log(e);
res.status(400).send();
}
});
router.get('/copyfromapptoapp/:idapporig/:idappdest', async (req, res) => {
// const idapporig = req.params.idapporig;
// const idappdest = req.params.idappdest;
@@ -467,7 +593,7 @@ router.get('/copyfromapptoapp/:idapporig/:idappdest', async (req, res) => {
// }
});
router.delete('/delrec/:table/:id', authenticate, (req, res) => {
router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
const id = req.params.id;
const idapp = req.user.idapp;
const tablename = req.params.table;
@@ -485,24 +611,54 @@ router.delete('/delrec/:table/:id', authenticate, (req, res) => {
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
let cancellato = false;
notifBot = tools.NotifyIfDelRecord(tablename);
let myrec = null;
return mytable.findByIdAndRemove(id).then((rec) => {
if (!rec) {
return res.status(404).send();
if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) {
if (tablename === 'users') {
let fieldsvalue = {
deleted: true
};
const rec = await mytable.findByIdAndUpdate(id, { $set: fieldsvalue });
myrec = rec;
cancellato = true;
}
}
tools.mylog('DELETED ', rec._id);
let ris = null;
if (!cancellato) {
ris = await mytable.findByIdAndRemove(id).then((rec) => {
if (!rec) {
return res.status(404).send();
}
myrec = rec;
cancellato = true;
tools.mylog('DELETED ', rec._id);
}).catch((e) => {
console.log(e);
res.status(400).send();
});
}
if (cancellato) {
// Do extra things after deleted
return actions.doOtherThingsAfterDeleted(tablename, rec).then(async (ris) => {
return actions.doOtherThingsAfterDeleted(tablename, myrec).then(async (ris) => {
if (ris) {
if (notifBot) {
// Send Notification to the BOT
let nomerecord = '';
if ((tablename === 'users') || (tablename === 'extralist')) {
nomerecord = rec.name + ' ' + rec.surname + ' (' + rec.username + ')';
nomerecord = myrec.name + ' ' + myrec.surname + ' (' + myrec.username + ')';
}
addtext = 'Eliminato il Record "' + nomerecord + '" dalla tabella ' + tablename + '\n' +
@@ -514,12 +670,11 @@ router.delete('/delrec/:table/:id', authenticate, (req, res) => {
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
}
});
}
res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
return ris;
}).catch((e) => {
console.log(e);
res.status(400).send();
});
});
@@ -651,8 +806,9 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
});
router.get(process.env.LINK_CHECK_UPDATES, authenticate, (req, res) => {
router.get(process.env.LINK_CHECK_UPDATES, authenticate, async (req, res) => {
const userId = req.user._id;
const idapp = req.query.idapp;
// console.log("POST " + process.env.LINK_CHECK_UPDATES + " userId=" + userId);
@@ -660,7 +816,7 @@ router.get(process.env.LINK_CHECK_UPDATES, authenticate, (req, res) => {
return res.status(404).send();
}
cfgserver.find().then((arrcfgrec) => {
await cfgserver.find({ idapp }).then((arrcfgrec) => {
if (!arrcfgrec)
return res.status(404).send();

View File

@@ -47,7 +47,7 @@ router.post('/', authenticate, (req, res) => {
.then(record => {
// tools.mylog('REC SAVED :', record.descr);
tools.sendNotificationToUser(project.userId, 'Project: ' + record.descr, record.descr, '/project/' + project.category, 'project')
tools.sendNotificationToUser(project.userId, 'Project: ' + record.descr, record.descr, '/project/' + project.category, '', 'project', [])
.then(ris => {
if (ris) {
res.send({ record });

View File

@@ -5,78 +5,151 @@ const Subscription = mongoose.model('subscribers');
// const q = require('q');
const webpush = require('web-push');
const tools = require('../tools/general');
const { authenticate } = require('../middleware/authenticate');
const shared_consts = require('../tools/shared_nodejs');
const server_constants = require('../tools/server_constants');
const { User } = require('../models/user');
router.post('/', (req, res) => {
const payload = {
title: req.body.title,
message: req.body.message,
url: req.body.url,
ttl: req.body.ttl,
icon: req.body.icon,
image: req.body.image,
badge: req.body.badge,
tag: req.body.tag
};
const payload = {
title: req.body.title,
message: req.body.message,
url: req.body.url,
ttl: req.body.ttl,
icon: req.body.icon,
image: req.body.image,
badge: req.body.badge,
tag: req.body.tag
};
Subscription.find({}, (err, subscriptions) => {
if (err) {
console.error(`Error occurred while getting subscriptions`);
res.status(500).json({
error: 'Technical error occurred'
});
Subscription.find({}, (err, subscriptions) => {
if (err) {
console.error(`Error occurred while getting subscriptions`);
res.status(500).json({
error: 'Technical error occurred'
});
} else {
let parallelSubscriptionCalls = subscriptions.map((subscription) => {
return new Promise((resolve, reject) => {
const pushSubscription = {
endpoint: subscription.endpoint,
keys: {
p256dh: subscription.keys.p256dh,
auth: subscription.keys.auth
}
};
} else {
let parallelSubscriptionCalls = subscriptions.map((subscription) => {
return new Promise((resolve, reject) => {
const pushSubscription = {
endpoint: subscription.endpoint,
keys: {
p256dh: subscription.keys.p256dh,
auth: subscription.keys.auth
}
};
const pushPayload = JSON.stringify(payload);
const pushOptions = {
vapidDetails: {
subject: process.env.URLBASE_APP1,
privateKey: process.env.PRIVATE_VAPI_KEY,
publicKey: process.env.PUBLIC_VAPI_KEY,
},
TTL: payload.ttl,
headers: {}
};
webpush.sendNotification(
pushSubscription,
pushPayload,
pushOptions
).then((value) => {
resolve({
status: true,
endpoint: subscription.endpoint,
data: value
});
}).catch((err) => {
reject({
status: false,
endpoint: subscription.endpoint,
data: err
});
});
});
const pushPayload = JSON.stringify(payload);
const pushOptions = {
vapidDetails: {
subject: process.env.URLBASE_APP1,
privateKey: process.env.PRIVATE_VAPI_KEY,
publicKey: process.env.PUBLIC_VAPI_KEY,
},
TTL: payload.ttl,
headers: {}
};
webpush.sendNotification(
pushSubscription,
pushPayload,
pushOptions
).then((value) => {
resolve({
status: true,
endpoint: subscription.endpoint,
data: value
});
q.allSettled(parallelSubscriptionCalls).then((pushResults) => {
console.info(pushResults);
}).catch((err) => {
reject({
status: false,
endpoint: subscription.endpoint,
data: err
});
res.json({
data: 'Push triggered'
});
}
});
});
});
});
q.allSettled(parallelSubscriptionCalls).then((pushResults) => {
console.info(pushResults);
});
res.json({
data: 'Push triggered'
});
}
});
});
async function SendMsgTo(idapp, username, params) {
return await User.find({ idapp, username }).then((arrusers) => {
if (arrusers !== null) {
for (const user of arrusers) {
tools.sendNotificationToUser(user._id, params.title, params.content, params.openUrl, params.openUrl2, params.tag, params.actions)
.then(ris => {
if (ris) {
} else {
// already sent the error on calling sendNotificationToUser
}
})
.catch(e => {
console.error(e);
})
}
}
});
}
async function SendMsgToAll(idapp, params) {
const arrusers = await User.find({ idapp },
{
username: 1,
name: 1,
surname: 1,
}
);
let msgsent = 0;
for (const user of arrusers) {
await SendMsgTo(idapp, user.username, params);
msgsent++;
}
return msgsent;
}
router.post('/send', authenticate, async (req, res) => {
const idapp = req.body.idapp;
const params = req.body.params;
let nummsg = 0;
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) && !User.isTutor(req.user.perm))) {
// If without permissions, exit
return res.status(404).send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
try {
if (params.typemsg === shared_consts.TypeMsg.SEND_TO_ALL) {
nummsg = await SendMsgToAll(idapp, params);
}
return res.send({ code: server_constants.RIS_CODE_OK, msg: nummsg + ' Msg Inviati !' });
}catch (e) {
return res.send({ code: server_constants.RIS_CODE_ERR, msg: nummsg + ' Msg Inviati !' });
}
});
router.get('/', (req, res) => {
res.json({
data: 'Invalid Request Bad'
});
res.json({
data: 'Invalid Request Bad'
});
});
module.exports = router;

View File

@@ -23,8 +23,6 @@ router.post('/load', async (req, res) => {
let datastat = {
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),
@@ -34,7 +32,6 @@ router.post('/load', async (req, res) => {
num_modalita_pagamento: await User.getnumPaymentOk(idapp),
num_part_zoom: await User.getUsersZoom(idapp),
num_part_accepted: await User.getSaw_and_Accepted(idapp),
num_users_dream: await User.getUsersDreams(idapp),
arr_nations: await User.findAllDistinctNationality(idapp),
numreg_untilday: await User.calcnumRegUntilDay(idapp),
reg_daily: await User.calcRegDaily(idapp),

View File

@@ -74,7 +74,6 @@ router.post('/', authenticate, (req, res) => {
}
}
});
});
});

View File

@@ -52,7 +52,7 @@ router.post('/', authenticate, (req, res) => {
.then(record => {
// tools.mylog('REC SAVED :', record.descr);
tools.sendNotificationToUser(todo.userId, 'Todo: ' + record.descr, record.descr, '/todo/' + todo.category, 'todo')
tools.sendNotificationToUser(todo.userId, 'Todo: ' + record.descr, record.descr, '/todo/' + todo.category, '', 'todo', [])
.then(ris => {
if (ris) {
res.send({ record });

View File

@@ -64,7 +64,6 @@ router.post('/', async (req, res) => {
user.ipaddr = tools.getiPAddressUser(req);
user.lasttimeonline = new Date();
user.date_reg = new Date();
user.date_temp_reg = new Date();
user.aportador_iniziale = user.aportador_solidario;
if (user.idapp === tools.AYNI) {
user.profile.paymenttypes = ['paypal'];
@@ -175,7 +174,7 @@ router.post('/', async (req, res) => {
return 1;
}
let already_registered = recextra || user.aportador_solidario === tools.APORTADOR_NONE;
let already_registered = (recextra || user.aportador_solidario === tools.APORTADOR_NONE) && (user.idapp === tools.AYNI);
// Check if is an other people aportador_solidario

View File

@@ -184,13 +184,15 @@ if (process.env.PROD !== 1) {
testmsgwebpush();
// sendemail.testemail('2', 'it');
/*
let crypt = tools.cryptdata('');
let miapass = '';
if (miapass !== '') {
let crypt = tools.cryptdata(miapass);
let decrypt = tools.decryptdata(crypt);
console.log('crypted:', crypt);
console.log('decrypted:', decrypt);
*/
}
mycron();
}
@@ -217,9 +219,10 @@ startserv();
function populateDBadmin() {
const cfgserv = [{
_id: new ObjectID(),
idapp: '9',
chiave: 'vers',
userId: 'ALL',
valore: '0.0.50'
valore: '0.1.2'
}];
let cfg = new cfgserver(cfgserv[0]).save();
@@ -227,6 +230,7 @@ function populateDBadmin() {
function startserv() {
// populateDBadmin();
// Check if is Empty (new Server Data)
/*
@@ -256,7 +260,7 @@ function testmsgwebpush() {
User.find({ username: 'paoloar77' }).then((arrusers) => {
if (arrusers !== null) {
for (const user of arrusers) {
tools.sendNotificationToUser(user._id, 'Titolo msg Test', 'Test Messaggio', '/', 'msg')
tools.sendNotificationToUser(user._id, 'Server', 'Il Server è Ripartito', '/', '', 'server', [])
.then(ris => {
if (ris) {

View File

@@ -1,6 +1,6 @@
const tools = require('../tools/general');
const appTelegram = [tools.AYNI];
const appTelegram = [tools.AYNI, tools.SIP];
const appTelegramFinti = ['2'];
const appTelegramDest = [tools.AYNI];
@@ -363,7 +363,7 @@ const txt_es = {
const txt_fr = {
MSG_SCEGLI_MENU: emoji.get('dizzy') + 'Choisissez un élément de menu:' + emoji.get('dizzy'),
MSG_ASK_USERNAME_BO: 'Écrivez dans le message l\'username ou l\'e-mail avec lequel vous vous êtes enregistré sur le site de% s: ',
MSG_ASK_USERNAME_BO: 'Écrivez dans le message l\'username ou l\'e-mail avec lequel vous vous êtes enregistré sur le site de %s: ',
MSG_ERRORE_USERNAME: 'Attention! Vous devez insérer seulement lusername (40 caractères maximum)',
MSG_ERRORE_USERNAME_NOT_FOUND: 'Pour Compléter la Vérification Telegram BOT, vous devez maintenant écrire dans le message ci-dessous l\'Username ou l\'adresse e-mail avec lequel vous vous êtes inscrit sur le site AYNI: ',
MSG_ERRORE_USERNAME_ANNULLA: 'Saisie des données Annullée.Essayez à nouveau ',
@@ -383,15 +383,15 @@ const txt_fr = {
const txt_si = {
MSG_SCEGLI_MENU: emoji.get('dizzy') + 'Izbirni meni:' + emoji.get('dizzy'),
MSG_ASK_USERNAME_BO: 'Vpiši svoje uporabniško ime in e-naslov s katerimi si se registriral na spletni strani % s: ',
MSG_ASK_USERNAME_BO: 'Vpiši svoje uporabniško ime in e-naslov s katerimi si se registriral na spletni strani %s: ',
MSG_ERRORE_USERNAME: 'Pozor! Vpiši samo uporabniško ime (40 znakov) maksimalno',
MSG_ERRORE_USERNAME_NOT_FOUND: 'Ponovno preverite telegram BOT Uporabniško ime ali e-poštno sporočilo, s katerim ste registrirali na spletni strani AYNI: ',
MSG_ERRORE_USERNAME_ANNULLA: 'Preklic. Poskusi ponovno ',
MSG_OPERAZ_ANNULLATA: 'Operacija preklicana',
MSG_ERRORE_VERIFY_CODE_MAXLEN: 'Pozor! Vstavi D mestno kodo',
MSG_VERIFY_CODE: '1. Vrni se na spletno strani AYNI: \n%s\n2. Kopiraj kodo Authenticazione (6 mestno) ki jo najdeš zgoraj zapisano\n3. Napiši (ali prilepi) tu spodaj kot sporočilo: ',
MSG_ERR_VERIFY_CODE: 'Napačna koda za preverjanje!' + emo.EXCLAMATION_MARK + '\nPreveri na strani% s in ponovno napiši 6 mestno kodo.',
MSG_VERIFY_OK: emoji.get('grinning') + 'Dobrodošel% s! Pravilno ste se preveriliz AYNI BOT. ' + ' \nsem tvoj virtualni asisten.\n ' +
MSG_ERR_VERIFY_CODE: 'Napačna koda za preverjanje!' + emo.EXCLAMATION_MARK + '\nPreveri na strani %s in ponovno napiši 6 mestno kodo.',
MSG_VERIFY_OK: emoji.get('grinning') + 'Dobrodošel %s! Pravilno ste se preveriliz AYNI BOT. ' + ' \nsem tvoj virtualni asisten.\n ' +
'Vodenje se nadeljuje z vodenimi koraki, ko se vrneš na spletno stran AYNI. \n\nTa klepet ti bo služil za hitri pregled tvoje table in za sprejemanje pomembnih obvestil glede poteka tvojega potovanja. \n\nUporabite meni tu spodaj, da lahko kontrolirate svojo situacijo. ' + emo.GREEN_HEART,
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Napaka strežnika.Poskusi kasneje ',
MSG_EXIT_TELEGRAM: 'Račun se nahaja v programu Telegram BOT.',
@@ -723,7 +723,7 @@ async function local_sendMsgTelegramToTheManagers(idapp, text, msg, username_bo)
}
function getstr(lang, key) {
function getstr(lang, key, param1) {
let mystr = '';
@@ -760,9 +760,13 @@ function getstr(lang, key) {
}
if (mystr === '')
return txt[key];
else
return mystr;
mystr = txt[key];
if (!!param1) {
mystr = printf(mystr, param1);
}
return mystr;
}
class Telegram {
@@ -804,6 +808,7 @@ class Telegram {
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);
}
}
@@ -1045,7 +1050,7 @@ class Telegram {
try {
let miomenu2 = Menu['it'][key];
trovato = (miomenu2 === menuselect);
}catch (e) {
} catch (e) {
}
}
@@ -1323,7 +1328,8 @@ class Telegram {
const rec = this.getRecInMem(msg);
let mystr = '';
if (rec.user) {
mystr += printf(tools.get__('INFO_LINK_DA_CONDIVIDERE', this.getlang(msg)), tools.getHostByIdApp(this.idapp) + '/signup/' + rec.user.username, tools.getlinkzoom(''));
mystr += printf(tools.get__('INFO_LINK_DA_CONDIVIDERE', this.getlang(msg)), tools.getHostByIdApp(this.idapp) + '/signup/' + rec.user.username);
mystr += tools.ACAPO + tools.ACAPO + printf(tools.get__('INFO_LINK_ZOOM', this.getlang(msg)), tools.getlinkzoom(''));
await this.sendMsg(msg.chat.id, mystr);
}
}
@@ -1567,7 +1573,9 @@ class Telegram {
rec.user = ris.user;
await User.SetTelegramCheckCode(this.idapp, ris.myid.toString(), rec.code);
rec.status = Status.WAITFOR_VERIFY_CODE;
await this.sendMsg(msg.from.id, printf(getstr(rec.user.lang, 'MSG_VERIFY_CODE'), tools.getHostByIdApp(this.idapp)), MenuNoLogin)
await this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_VERIFY_CODE', tools.getHostByIdApp(this.idapp)), MenuNoLogin)
} else {
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp)), MenuNoLogin);
}
}
} else if (text.length === 0) {
@@ -1585,52 +1593,54 @@ class Telegram {
async setVerifyCode(msg) {
try {
const code = msg.text.toString().trim();
const rec = this.getRecInMem(msg);
const user = await User.findByUsername(this.idapp, rec.username_bo, true);
let telegcode = 0;
if (user) {
telegcode = user.profile.teleg_checkcode.toString();
} else {
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_NOT_FOUND'), MenuNoLogin);
return
}
if (code.length < 7) {
if (rec) {
if (code === telegcode) {
// let ris = await this.getUser(msg, rec, false);
rec.status = Status.VERIFIED;
await User.SetTelegramIdSuccess(this.idapp, user._id, msg.from.id).then((recuser) => {
if (recuser) {
let name = recuser.name;
this.sendMsg(msg.from.id, printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), name));
local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' +recuser.lang + ')' + emo.STARS, msg);
} else {
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERR_UNKNOWN_VERIFY_CODE'));
}
});
} else {
if (rec.retry < 2) {
rec.retry++;
await
this.sendMsg(msg.from.id, printf(getstr(this.getlang(msg), 'MSG_ERR_VERIFY_CODE'), tools.getHostByIdApp(this.idapp)));
if (!!msg.text) {
const code = msg.text.toString().trim();
const rec = this.getRecInMem(msg);
const user = await User.findByUsername(this.idapp, rec.username_bo, true);
let telegcode = 0;
if (user) {
telegcode = user.profile.teleg_checkcode.toString();
} else {
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_NOT_FOUND'), MenuNoLogin);
return
}
if (code.length < 7) {
if (rec) {
if (code === telegcode) {
// let ris = await this.getUser(msg, rec, false);
rec.status = Status.VERIFIED;
await User.SetTelegramIdSuccess(this.idapp, user._id, msg.from.id).then((recuser) => {
if (recuser) {
let name = recuser.name;
this.sendMsg(msg.from.id, printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), name));
local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg);
} else {
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERR_UNKNOWN_VERIFY_CODE'));
}
});
} else {
rec.status = Status.NONE;
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'));
this.deleteRecInMem(msg);
if (rec.retry < 2) {
rec.retry++;
await
this.sendMsg(msg.from.id, printf(getstr(this.getlang(msg), 'MSG_ERR_VERIFY_CODE'), tools.getHostByIdApp(this.idapp)));
} else {
rec.status = Status.NONE;
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'));
this.deleteRecInMem(msg);
}
}
}
} else if (msg.text.length === 0) {
if (rec)
rec.status = Status.NONE;
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'))
} else {
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_VERIFY_CODE_MAXLEN'))
}
} else if (msg.text.length === 0) {
if (rec)
rec.status = Status.NONE;
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'))
} else {
await
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_VERIFY_CODE_MAXLEN'))
}
} catch (e) {
console.error('Error setVerifyCode', e);
@@ -1690,54 +1700,55 @@ class Telegram {
tools.writeEventsLog(this.getDestinStr(msg, destin, rec) + ':\n' + texttosend);
for (const utente of usersall) {
if (this.isSelMenu(msg, texttosend === 'LAVAGNA')) {
textdainviare = await this.getLavagnaByUser(utente, msg);
} else if (destin === Destin.A_UTENTE) {
textdainviare = texttosend;
} else {
textdainviare = texttosend;
}
let invia = false;
if (destin === Destin.STAFF) {
invia = User.isManager(utente.perm);
} else if (destin === Destin.TUTTI) {
invia = true;
} else if (destin === Destin.A_UTENTE) {
invia = utente.username === rec.msgall_username_specifico;
} else if (destin === Destin.NO_7_REQ) {
invia = !await User.isUserQualified7(this.idapp, utente.username);
} else if (destin === Destin.NO_9_REQ) {
invia = !await User.isUserQualified9(this.idapp, utente.username);
} else if (destin === Destin.MSG_TO_NAVE) {
invia = !await Nave.findDonatoreByNave(this.idapp, rec.extraparam);
} else if (destin === Destin.SI_INVITATI_NO_7REQ_INVITATI) {
const numinvitati = await User.getnumInvitati(this.idapp, utente.username);
const numinvitatiattivi = await User.getnumInvitatiAttivi(this.idapp, utente.username);
invia = (numinvitati >= 2) && (numinvitatiattivi < 2);
}
if (invia) {
if (cmd === RICEVI_EMAIL) {
preparatesto += utente.email + ', ';
} else if (cmd === CONTA_SOLO) {
// Niente
if (!utente.deleted && !utente.sospeso) {
if (this.isSelMenu(msg, texttosend === 'LAVAGNA')) {
textdainviare = await this.getLavagnaByUser(utente, msg);
} else if (destin === Destin.A_UTENTE) {
textdainviare = texttosend;
} else {
if (destin === Destin.A_UTENTE) {
await this.sistemaRecDest(rec, msg);
await this.sendMsg(utente.profile.teleg_id, '[' + rec.username_bo + ' ti scrive]:\n' + textdainviare, MenuChat);
} else {
await this.sendMsg(utente.profile.teleg_id, textdainviare);
}
await tools.snooze(300)
textdainviare = texttosend;
}
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 });
let invia = false;
if (destin === Destin.STAFF) {
invia = User.isManager(utente.perm);
} else if (destin === Destin.TUTTI) {
invia = true;
} else if (destin === Destin.A_UTENTE) {
invia = utente.username === rec.msgall_username_specifico;
} else if (destin === Destin.NO_7_REQ) {
invia = !await User.isUserQualified7(this.idapp, utente.username);
} else if (destin === Destin.NO_9_REQ) {
invia = !await User.isUserQualified9(this.idapp, utente.username);
} else if (destin === Destin.MSG_TO_NAVE) {
invia = !await Nave.findDonatoreByNave(this.idapp, rec.extraparam);
} else if (destin === Destin.SI_INVITATI_NO_7REQ_INVITATI) {
const numinvitati = await User.getnumInvitati(this.idapp, utente.username);
const numinvitatiattivi = await User.getnumInvitatiAttivi(this.idapp, utente.username);
invia = (numinvitati >= 2) && (numinvitatiattivi < 2);
}
if (invia) {
if (cmd === RICEVI_EMAIL) {
preparatesto += utente.email + ', ';
} else if (cmd === CONTA_SOLO) {
// Niente
} else {
if (destin === Destin.A_UTENTE) {
await this.sistemaRecDest(rec, msg);
await this.sendMsg(utente.profile.teleg_id, '[' + rec.username_bo + ' ti scrive]:\n' + textdainviare, MenuChat);
} else {
await this.sendMsg(utente.profile.teleg_id, textdainviare);
}
await tools.snooze(300)
}
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)
}
}
}
}
}
@@ -1779,7 +1790,7 @@ class Telegram {
selectMenuLang(msg) {
return ((msg.text === Menu.LANG) || (msg.text === Menu.LANG_EN) || (msg.text === Menu.LANG_IT) || (msg.text === Menu.LANG_ES)
|| (msg.text === Menu.LANG_FR) || (msg.text === Menu.LANG_SI) || (msg.text === Menu.LANG_PT) )
|| (msg.text === Menu.LANG_FR) || (msg.text === Menu.LANG_SI) || (msg.text === Menu.LANG_PT))
}
async receiveMsg(msg) {
@@ -1857,7 +1868,7 @@ class Telegram {
await this.addUser(msg);
// await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), printf(txt.MSG_ASK_USERNAME_BO, tools.getHostByIdApp(this.idapp))));
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), printf('MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp))), MenuNoLogin);
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp)), MenuNoLogin);
return false;
}
@@ -2108,8 +2119,7 @@ class Telegram {
"resize_keyboard": true,
"keyboard": await this.getKeyboard(msg.from.id, undefined, this.getlang(msg))
}
})
;
});
}
}

View File

@@ -51,17 +51,18 @@ textlang = {
"Nuova Registrazione": "Nuova Registrazione",
"Effettuata una Nuova Registrazione": "Effettuata una Nuova Registrazione",
"partecipanti": "partecipanti",
'TESTO_ASSISTENZA': "Per entrare nel Sito AYNI:\nhttps://ayni.gifteconomy.app\n\nHai dimenticato la Password per accedere al sito?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entra ⛩ nella nostra Community chat:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat di Aiuto e Supporto: 'AYNI - HELP'\nDa Lunedì al Sabato (8:00 - 21:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Fai la tua domanda e chiedi assistenza.\n2 - Dopo aver ricevuto aiuto esci dalla chat.\nPotrai rientrare ogni qualvolta ne avrai la necessità.",
'TESTO_ASSISTENZA': "Per entrare nel Sito AYNI:\nhttps://ayni.gifteconomy.app\n\nChat AYNI - EMPOWER: Entra ⛩ nella nostra Community chat:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nPER AIUTO: Leggi le Domande più Frequenti:\nhttps://ayni.gifteconomy.app/faq\n\nChat di Supporto 'AYNI - HELP'\nDa Lunedì al Sabato (8:00 - 20:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Fai la tua domanda e chiedi assistenza.\n2 - Dopo aver ricevuto aiuto esci dalla chat.\nPotrai rientrare ogni qualvolta ne avrai la necessità.",
'BENVENUTO': "Benvenuto",
'TUE_NAVI': "Ecco le tue Navi programmate",
'HAI_I_7_REQUISITI': 'PRIMI PASSI OK!\nHai i Primi 7 Requisiti per Entrare nella Lista d\'Imbarco!',
'NON_HAI_I_7_REQUISITI': 'Attenzione!\nAncora non hai i 7 Requisiti per Entrare nella Lista d\'Imbarco!',
'HAI_I_9_REQUISITI': 'COMPLIMENTI!\nHai Completato TUTTI i 9 Passi della Guida! Grazie per Aiutare AYNI ad Espandersi!',
'NON_HAI_I_9_REQUISITI': 'Ricorda che puoi Aiutare a far Crescere ed Espandere il Movimento, Condividendo con chiunque questo nostro viaggio!',
'NON_HAI_I_9_REQUISITI': 'Ricqorda che puoi Aiutare a far Crescere ed Espandere il Movimento, Condividendo con chiunque questo nostro viaggio!',
'INFO_LA_MIA_LAVAGNA': '✨ Lista dei Passi: ✨ \n',
'INFO_LAVAGNA_SITO_COMPLETARE': 'Per completare tutti i requisiti vai sul sito:\n%s\nPer vedere lo stato della tua Nave e dei tuoi invitati, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n',
'INFO_LAVAGNA_SITO': 'Per vedere in dettaglio lo stato della tua Nave, sul sito AYNI, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n',
'INFO_LINK_DA_CONDIVIDERE': 'Link da condividere ai tuoi invitati per farli registrare al sito di Ayni:\n%s\n\nLink da condividere per partecipare allo Zoom (Conferenza OnLine):\n%s',
'INFO_LINK_DA_CONDIVIDERE': 'Link da condividere ai tuoi invitati per farli registrare al sito di Ayni:\n\n%s',
'INFO_LINK_ZOOM': 'Link da condividere per partecipare allo Zoom (Conferenza OnLine):\n%s',
'ZOOM_CONFERENCE': 'Qui trovi le date di programmazione agli Zoom:',
"NON_VERIF": "Non Verificata",
"VERIF": "Verificata",
@@ -84,7 +85,7 @@ textlang = {
'SCEGLI_VOCE': 'scegli una voce:',
'INVITATI_LISTA': 'I Tuoi Invitati (in verde con almeno i primi 7 Requisiti)',
'CIAO': 'Ciao',
'ADDED_TOLISTAINGRESSO': 'Sei stato aggiunto alla Lista delle persone che entreranno nella Lista D\'Imbarco !',
'ADDED_TOLISTAINGRESSO': 'Sei stato aggiunto alla Lista delle persone che entreranno nella Lista D\'Imbarco !\nNei prossimi giorni riceverai un messaggio quando la tua Nave partirà.',
'NO_PROG': 'Attualmente non sei ancora dentro alla Lista d\'Imbarco!',
'SEND_LINK_CHAT_DONATORI': 'Ciao %s!\nLa tua NAVE sta finalmente Salpando!\nEntra nella Gift Chat cliccando qui: %s',
'SOGNATORE': 'SOGNATORE',
@@ -106,7 +107,7 @@ textlang = {
"Nuova Registrazione": "Nova Registracija",
"Effettuata una Nuova Registrazione": "Izpelji novo Registracijo",
"partecipanti": "Udeleženci",
'TESTO_ASSISTENZA': "Za vstop na spletno stran:\nhttps://ayni.gifteconomy.app\n\nSi pozabil geslo za vstop na stran?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nKlepet AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\nKlepet AYNI - EMPOWER: Vstopi ⛩ v našo Skupnost klepet:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nKlepet AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nKlepet za Pomoč in Suport: 'AYNI - HELP'\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Postavi svoje vprašanje in prosi za asistenco.\n2 - KO si sprejel pomoč, izstopi iz klepeta.\n Vstopil boš lahko vedno, ko boš potreboval pomoč.",
'TESTO_ASSISTENZA': "Za vstop na spletno stran:\nhttps://ayni.gifteconomy.app\n\nSi pozabil geslo za vstop na stran?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nKlepet AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\nKlepet AYNI - EMPOWER: Vstopi ⛩ v našo Skupnost klepet:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nKlepet AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nKlepet za Pomoč in Suport: 'AYNI - HELP'\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Postavi svoje vprašanje in prosi za asistenco.\n2 - KO si sprejel pomoč, izstopi iz klepeta.\n Vstopil boš lahko vedno, ko boš potreboval pomoč.",
'BENVENUTO': "Dobrodošel",
'TUE_NAVI': "Tvoje programirane Ladje",
'HAI_I_7_REQUISITI': 'PRVI KORAKI OK!\nIzpolnjuješ Prvih 7 Zahtev za vstop na Listo d\'Vkrcanje!',
@@ -116,7 +117,8 @@ textlang = {
'INFO_LA_MIA_LAVAGNA': '✨ Seznam Krajev: ✨ \n',
'INFO_LAVAGNA_SITO_COMPLETARE': 'Da izpolneš vse zahteve, pojdi na spletno stran:\n%s\nDa pogledaš status svoje Ladje in status svojih povabljencev, klikni na levi strani zgoraj na tri črte in izberi "Tabla".\n',
'INFO_LAVAGNA_SITO': 'Da lahko podrobno pogledaš status svoje Ladje,na spletni strani AYNI, klikni, na levi strani zgoraj, na tri črtice in izberi "Tabla".\n',
'INFO_LINK_DA_CONDIVIDERE': 'Link, ki ga deliš svojim povabljencem, da se lahko registrirajo na spletni strani Ayni:\n%s\n\nLink, ki ga deliš za udeležbo na Zoom (Konferenca OnLine):\n%s',
'INFO_LINK_DA_CONDIVIDERE': 'Link, ki ga deliš svojim povabljencem, da se lahko registrirajo na spletni strani Ayni:\n\n%s',
'INFO_LINK_ZOOM': 'Link, ki ga deliš za udeležbo na Zoom (Konferenca OnLine):\n%s',
'ZOOM_CONFERENCE': 'Tu najdeš datume prihajajočih Zoom-ov:',
"NON_VERIF": "Ni Preverjena",
"VERIF": "Preverjena",
@@ -161,7 +163,7 @@ textlang = {
"Nuova Registrazione": "Nuevo Registro",
"Effettuata una Nuova Registrazione": "Se ha realizado un nuevo registro",
"partecipanti": "participantes",
'TESTO_ASSISTENZA': "Para entrar en el sitio de AYNI:\nhttps://ayni.gifteconomy.app\n\n¿Olvidó su contraseña para acceder al sitio?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (este):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entra en ⛩ en nuestra comunidad de chat:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat de la AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat de ayuda y soporte: 'AYNI - HELP'\nDe lunes a sábado (8:00 - 21:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Haga su pregunta y pida ayuda.\n2 - Después de que consigas ayuda, sal de la sala de chat.\nPuedes volver cuando necesites ayuda..",
'TESTO_ASSISTENZA': "Para entrar en el sitio de AYNI:\nhttps://ayni.gifteconomy.app\n\n¿Olvidó su contraseña para acceder al sitio?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (este):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entra en ⛩ en nuestra comunidad de chat:\n ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat de la AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat de ayuda y soporte: 'AYNI - HELP'\nDe lunes a sábado (8:00 - 21:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - 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",
'HAI_I_7_REQUISITI': '¡LOS PRIMEROS PASOS ESTÁN BIEN!\nTiene los primeros 7 requisitos para entrar en la lista de embarque!',
@@ -171,7 +173,8 @@ textlang = {
'INFO_LA_MIA_LAVAGNA': '✨ Lista de pasos: ✨ \n',
'INFO_LAVAGNA_SITO_COMPLETARE': 'Para completar todos los requisitos vaya al sitio:\n%s\nPara ver el estado de su nave y sus invitados, haga clic en las 3 líneas de arriba a la izquierda y vaya a "Pizarra".\n',
'INFO_LAVAGNA_SITO': 'Para ver en detalle el estado de su nave, en el sitio web de AYNI, haga clic en las 3 líneas de la parte superior izquierda y vaya a "Pizarra"..\n',
'INFO_LINK_DA_CONDIVIDERE': 'Enlaces para compartir con sus invitados para que se registren en el sitio web de Ayni:\n%s\n\nEnlaces para compartir para participar en el Zoom (Conferencia en línea):\n%s',
'INFO_LINK_DA_CONDIVIDERE': 'Enlaces para compartir con sus invitados para que se registren en el sitio web de Ayni:\n\n%s',
'INFO_LINK_ZOOM': 'Enlaces para compartir para participar en el Zoom (Conferencia en línea):\n%s',
'ZOOM_CONFERENCE': 'Aquí puedes encontrar las fechas de programación en el Zoom:',
"NON_VERIF": "No verificado",
"VERIF": "Verificado",
@@ -213,7 +216,7 @@ textlang = {
},
enUs: {
"partecipanti": "participants",
'TESTO_ASSISTENZA': "To enter the AYNI Site:\nhttps://ayni.gifteconomy.app\n\nForgot your password to access the site?\nhttps://ayni.gifteconomy.app/requestresetpwd\nChat AYNI BOT (this one):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Enter ⛩ into our chat community:\nITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nHelp and Support Chat: 'AYNI - HELP'.\nMonday to Saturday (8:00 - 21:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Ask your question and ask for assistance.\n2 - After receiving help, exit the chat.\nYou can come back whenever you need help.",
'TESTO_ASSISTENZA': "To enter the AYNI Site:\nhttps://ayni.gifteconomy.app\n\nForgot your password to access the site?\nhttps://ayni.gifteconomy.app/requestresetpwd\nChat AYNI BOT (this one):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Enter ⛩ into our chat community:\nITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nHelp and Support Chat: 'AYNI - HELP'.\nMonday to Saturday (8:00 - 20:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - 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",
'HAI_I_7_REQUISITI': 'FIRST STEPS OK!\nYou have the First 7 Requirements to Enter the Boarding List!',
@@ -223,7 +226,8 @@ textlang = {
'INFO_LA_MIA_LAVAGNA': '✨ Step List: ✨ \n',
'INFO_LAVAGNA_SITO_COMPLETARE': 'To complete all the requirements go to the site:%s\nTo see the status of your Ship and your guests, click on the 3 lines at the top left and go to "Dashboard"\n',
'INFO_LAVAGNA_SITO': 'To see in detail the status of your ship, on the AYNI website, click on the 3 lines at the top left and go to "Blackboard".\n',
'INFO_LINK_DA_CONDIVIDERE': 'Links to share with your guests to have them register on Ayni\'s website:\n%s\n\nLinks to share to participate in Zoom (Online Conference):\n%s',
'INFO_LINK_DA_CONDIVIDERE': 'Links to share with your guests to have them register on Ayni\'s website:\n\n%s',
'INFO_LINK_ZOOM': 'Links to share to participate in Zoom (Online Conference):\n%s',
'ZOOM_CONFERENCE': 'Here you can find the Zoom Conference Planning:',
"NON_VERIF": "Not Verified",
"VERIF": "Verified",
@@ -268,7 +272,7 @@ textlang = {
"Nuova Registrazione": "Nouvelle inscription",
"Effettuata una Nuova Registrazione": "Un nouvel enregistrement a été effectué",
"partecipanti": "participants",
'TESTO_ASSISTENZA': "Pour entrer sur le site AYNI:\nhttps://ayni.gifteconomy.app\n\nVous avez oublié votre mot de passe pour accéder au site ?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (ce):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER : Entrez ⛩ dans notre Community chat:\nITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat dAide et de Support: 'AYNI - HELP'\nDu lundi au samedi (8:00 - 21:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Posez votre question et demandez dêtre assisté.\n2 - Après avoir reçu laide, quittez le groupe .\\n Vous pourrez y entrer chaque fois quil vous sera nécessaire.",
'TESTO_ASSISTENZA': "Pour entrer sur le site AYNI:\nhttps://ayni.gifteconomy.app\n\nVous avez oublié votre mot de passe pour accéder au site ?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (ce):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER : Entrez ⛩ dans notre Community chat:\nITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat dAide et de Support: 'AYNI - HELP'\nDu lundi au samedi (8:00 - 20:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Posez votre question et demandez dêtre assisté.\n2 - Après avoir reçu laide, quittez le groupe .\\n Vous pourrez y entrer chaque fois quil vous sera nécessaire.",
'BENVENUTO': "Bienvenue",
'TUE_NAVI': "Voici vos navires programmés",
'HAI_I_7_REQUISITI': 'PREMIÈRES ÉTAPES OK!\nvous avez les 7 premiers Requis pour Entrer dans la liste d\'embarquement!',
@@ -278,7 +282,8 @@ textlang = {
'INFO_LA_MIA_LAVAGNA': '✨ Liste des étapes: ✨ \n',
'INFO_LAVAGNA_SITO_COMPLETARE': 'Pour remplir toutes les conditions, rendez-vous sur le site:\n%s\nPour voir le statut de votre navire et de vos invités, cliquez sur les 3 lignes en haut à gauche et allez sur "Tableau noir".\n',
'INFO_LAVAGNA_SITO': 'Pour voir en détail le statut de votre navire, sur le site de l\'AYNI, cliquez sur les 3 lignes en haut à gauche et allez sur "Tableau noir".\n',
'INFO_LINK_DA_CONDIVIDERE': 'Liens à partager avec vos invités pour qu\'ils s\'inscrivent sur le site web d\'Ayni:\n%s\n\nLiens à partager pour participer à Zoom (Conférence en ligne):\n%s',
'INFO_LINK_DA_CONDIVIDERE': 'Liens à partager avec vos invités pour qu\'ils s\'inscrivent sur le site web d\'Ayni:\n\n%s',
'INFO_LINK_ZOOM': 'Liens à partager pour participer à Zoom (Conférence en ligne):\n%s',
'ZOOM_CONFERENCE': 'Vous trouverez ici les dates de programmation sur Zoom:',
"NON_VERIF": "Non vérifié",
"VERIF": "Vérifié",
@@ -323,7 +328,7 @@ textlang = {
"Nuova Registrazione": "Nuova Registrazione",
"Effettuata una Nuova Registrazione": "Effettuata una Nuova Registrazione",
"partecipanti": "partecipanti",
'TESTO_ASSISTENZA': "Per entrare nel Sito AYNI:\nhttps://ayni.gifteconomy.app\n\nHai dimenticato la Password per accedere al sito?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entra ⛩ nella nostra Community chat:ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat di Aiuto e Supporto: 'AYNI - HELP'\nDa Lunedì al Sabato (8:00 - 21:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Fai la tua domanda e chiedi assistenza.\n2 - Dopo aver ricevuto aiuto esci dalla chat.\nPotrai rientrare ogni qualvolta ne avrai la necessità.",
'TESTO_ASSISTENZA': "Per entrare nel Sito AYNI:\nhttps://ayni.gifteconomy.app\n\nHai dimenticato la Password per accedere al sito?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\nChat AYNI BOT (questa):\nhttps://t.me/notevoleaynibot\n\nChat AYNI - EMPOWER: Entra ⛩ nella nostra Community chat:ITA 🇮🇹: https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g\n SLO 🇸🇮: https://t.me/aynislovenija\n ESP 🇪🇸 - PRT 🇵🇹: https://t.me/joinchat/AL2qKBqJRuIEuc2FivgAzg\n ENG 🇬🇧: https://t.me/joinchat/AL2qKBYX0yVvOJ6Ssf9hKg\n FRA 🇫🇷: https://t.me/joinchat/Kz0wtxieJjzoC3L_DsrdZw \n\nChat AYNI-BIBLIO: https://t.me/joinchat/AL2qKExZKvenLgpVhOyefQ \n\nChat di Aiuto e Supporto: 'AYNI - HELP'\nDa Lunedì al Sabato (8:00 - 20:00)\nhttps://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w\n1 - Fai la tua domanda e chiedi assistenza.\n2 - Dopo aver ricevuto aiuto esci dalla chat.\nPotrai rientrare ogni qualvolta ne avrai la necessità.",
'BENVENUTO': "Benvenuto",
'TUE_NAVI': "Ecco le tue Navi programmate",
'HAI_I_7_REQUISITI': 'PRIMI PASSI OK!\nHai i Primi 7 Requisiti per Entrare nella Lista d\'Imbarco!',
@@ -333,7 +338,8 @@ textlang = {
'INFO_LA_MIA_LAVAGNA': '✨ Lista dei Passi: ✨ \n',
'INFO_LAVAGNA_SITO_COMPLETARE': 'Per completare tutti i requisiti vai sul sito:\n%s\nPer vedere lo stato della tua Nave e dei tuoi invitati, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n',
'INFO_LAVAGNA_SITO': 'Per vedere in dettaglio lo stato della tua Nave, sul sito AYNI, clicca sulle 3 linee in alto a sinistra ed accedi alla voce "Lavagna".\n',
'INFO_LINK_DA_CONDIVIDERE': 'Link da condividere ai tuoi invitati per farli registrare al sito di Ayni:\n%s\n\nLink da condividere per partecipare allo Zoom (Conferenza OnLine):\n%s',
'INFO_LINK_DA_CONDIVIDERE': 'Link da condividere ai tuoi invitati per farli registrare al sito di Ayni:\n\n%s',
'INFO_LINK_ZOOM': 'Link da condividere per partecipare allo Zoom (Conferenza OnLine):\n%s',
'ZOOM_CONFERENCE': 'Qui trovi le date di programmazione agli Zoom:',
"NON_VERIF": "Non Verificata",
"VERIF": "Verificata",
@@ -383,6 +389,7 @@ module.exports = {
LANGADMIN: 'it',
AYNI: '7',
SIP: '9',
APORTADOR_NONE: '------',
@@ -393,6 +400,7 @@ module.exports = {
SEND_LINK_CHAT_DONATORI: 1,
SEND_MSG: 2,
SEND_MSG_SINGOLO: 3,
SEND_TO_ALL: 10,
},
Placca: {
@@ -545,7 +553,7 @@ module.exports = {
console.log('sendBackNotif:', subscription, payload);
// Pass object into sendNotification
webpush.sendNotification(subscription, JSON.stringify(payload)).catch(err => console.error(err))
return webpush.sendNotification(subscription, JSON.stringify(payload))
.catch(err => {
if (err.statusCode === 410) {
// Gone: is not valid anymore (Expired probably!), so I have to delete from my db
@@ -554,14 +562,20 @@ module.exports = {
console.log('Subscription is no longer valid: ', err);
}
})
.then(ris => {
// console.log('ris', ris)
})
.catch(err => console.error(err))
},
sendNotificationToUser: function (userId, title, content, openUrl, tag) {
sendNotificationToUser: function (userId, title, content, openUrl, openUrl2, tag, actions) {
let payload = {
actions,
title: title,
message: content,
content,
url: openUrl,
url2: openUrl2,
tag,
// ttl: req.body.ttl,
// icon: req.body.icon,
@@ -621,7 +635,7 @@ module.exports = {
console.log('************ INVIO WEBPUSH.SENDNOTIFICATION N° ', conta, '/', trovati, 'A', subscription.browser);
// console.log('vapidDetails', pushOptions.vapidDetails);
payload.title = process.env.URLBASE_APP1 + ' Msg n° ' + conta + '/' + trovati;
// payload.title = process.env.URLBASE_APP1 + ' Msg n° ' + conta + '/' + trovati;
// payload.message += subscription.browser ;
const pushPayload = JSON.stringify(payload);
@@ -869,7 +883,7 @@ module.exports = {
const data = {};
if (rec.type === this.FieldType.exact) {
data[rec.field] = params.filter.trim();
}else if (rec.type === this.FieldType.string) {
} else if (rec.type === this.FieldType.string) {
data[rec.field] = myregexp;
} else if (rec.type === this.FieldType.number) {
data[rec.field] = parseInt(params.filter.trim());

View File

@@ -26,13 +26,23 @@ module.exports = {
Tutor: 8,
},
MessageOptions: {
MessageOptions: {
Notify_ByEmail: 2,
Notify_ByPushNotification: 4
},
TypeMsg: {
SEND_TO_ALL: 1
},
TypeMsg_Actions: {
NORMAL: 0,
YESNO: 1,
OPZ1_2: 2,
},
fieldsUserToChange() {
return ['_id', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'date_temp_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'numinvitati', 'numinvitatiattivi', 'qualified']
return ['_id', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'numinvitati', 'numinvitatiattivi', 'qualified']
}
};