- Nuovo Sistema di Flotte per Tutor.

X - Mettere anche la email del sognatore, per chi è abituato ad inviarla in quel modo...
X - Controllare che sul sito compaiano le informazioni del Sognatore...
This commit is contained in:
Paolo Arena
2020-06-08 13:31:05 +02:00
parent 140e181fcc
commit c939be279e
21 changed files with 2037 additions and 254 deletions

View File

@@ -1,8 +1,5 @@
------------
// ++Todo: FATTO: DA CONTROLLARE
X - Se sei imbarcata i tuoi due invitati usati per quella posizione sono bloccati. Se ne hai in più li puoi regalare
- L'ultimo Utente della Creazione della Nave, compare ancora il Sognatore !!!
Sistemato: TESTARE SE ORA È' OK...
@@ -12,24 +9,61 @@ X - Se sei imbarcata i tuoi due invitati usati per quella posizione sono bloccat
// ++Todo: PRIORITA' ALTA:
CONTROLLARE:
- Puoi imbarcarti non piu di 2 volte temporanee.
- Togliere Sogno e Video.
- Sistemare la Creazione delle Navi... in semi-automatico.
- Profili Incompleti:
Poter inviare dei messaggi in automatico per ricordargli di completare ...
- Controllare gli Account di Andrea (sembrano mescolati....) socio856 è dentro invece non doveva esserci...
- socio856 non è stato raggruppato con socio85 (Andrea Lai)
- Se non hai fatto una registrazione con verifica email o BOT:
Mandare email dicendo che se non t'iscrivi, verrai cancellato.
- Se non si è qualificato entro 7 gg, manda un msg a lui e all'invitante che verrà cancellato entro 7 gg.
- Mettere il tragitto anche sul BOT.
- Se sei in conversazione e premi i menu, esci dalla conversazione !
- CHIEDERE ALLA PERSONA SE VUOLE ESSERE SOSPESO OPPURE CANCELLATO!
Se ha solo questo imbarco:
- Come da tua richiesta, sei stato sostituito.
- Vuoi cancellare questo profilo? -> "Nascosto"
- Vuoi Sospendere il profilo? -> "Sospeso"
- Se l'utente entra ed è "Nascosto":
- Gli chiedo se vuole ripristinare l'account...
- Rimettere "made_gift" a false se si ha sbagliato...
- Mettere 3 giorni.
- Fondo Ayni 9.152 : aggiungere registrazione Paolo2 Arena. e mettere paypal.me
- Mandare msg ai Non Invitati, o inferiori di 2.
- aggiungere le note di pagamento, a nome di chi è il pagamento?
- Inviare il Link che punta alla Pagina del Sito, per effettuare il Dono!
E per eventualmente Entrare nella GIFT CHAT!
- Mettere i messaggi del DONO in LINGUA (metterli sul server).
- ULTIMA FLOTTA DA - A DEFINITIVA
- ULTIMA NAVE DEFINITIVA...N.NN
- Non poter sostituire i Ritessuti ! D8
- Il LastNave non sembra essere corretto!
- Sistemare la Creazione delle Navi... in semi-automatico.
// ++Todo: PRIORITA' NORMALE:
- Se entro con la seconda utenza, gli mando messaggio che dice che deve collegarsi con la prima utenza....
- AGGIUNGERCI L'USERNAME REALE ! ALTRIMENTI PRENDE IL PRINCIPALE !!
- Fare funzione che passa un Utente secondario in un utente Primario! (c'è gia)
@@ -37,7 +71,6 @@ CONTROLLARE:
// ++Todo: DA FARE PIU AVANTI:
- Sistemare poter modificare le Pagine.
- Per il Fondo Ayni, prevedere anche altri Metodi di Pagamento... Revolut, N26, ecc...
ed inserirlo sul sito per il Sognatore (flag Pagato al Fondo: nave.offerta_al_fondo).
@@ -74,9 +107,11 @@ SOSTITUISCI:
- Sistemare che in Edit Pagina, se è troppo grande, va oltre l'altezza della finestra.
- Attivare le Traduttrici alle Pagine
- Inviare messaggi solo per ITALIANI (o di lingua cmq).
- Aggiornare le FAQ in lingua
- Attivare le Traduttrici alle Pagine
- CONTROLLARE CON ARGENTINA E PORTOGALLO e Brasile:
@@ -123,3 +158,23 @@ ANDREA
//++TODO: *** FATTI ***
// ++Todo: FATTO: DA CONTROLLARE
X - Se sei imbarcata i tuoi due invitati usati per quella posizione sono bloccati. Se ne hai in più li puoi regalare
X - Numero d'invitati sbagliato -> Nogalska
X - 50 persone non hanno un'imbarco -> Chiamare funzione che gliela rimette.
X - Poter Inviare un msg preconfezionato a chi non la la nave !
X Poter cliccare SI per aggiungersi ad un Nuovo Imbarco.
X - Se entro con la seconda utenza, gli mando messaggio che dice che deve collegarsi con la prima utenza....
X - Sistemare poter modificare le Pagine.
X - SISTEMARE QUANDO L'ULTIMA NAVE DELLA FLOTTA C'E' UN SOGNATORE CHE HA LA NAVE DI RITORNO!
X - IL MEDIATORE DEVE AVERE LA SUA RITESSUTURA !!! ( TOGLIERE L'IF NEL CASO NON SIA SOGNATORE)
X - Mettere anche la email del sognatore, per chi è abituato ad inviarla in quel modo...
X - Controllare che sul sito compaiano le informazioni del Sognatore...

7
emails/standard/html.pug Executable file
View File

@@ -0,0 +1,7 @@
p #{dataemail.emailbody}
style(type="text/css").
html, body {
padding: 0;
margin: 0;
}

1
emails/standard/subject.pug Executable file
View File

@@ -0,0 +1 @@
=`${dataemail.emailtitle}`

325
src/server/models/flotta.js Executable file
View File

@@ -0,0 +1,325 @@
const mongoose = require('mongoose');
const _ = require('lodash');
const tools = require('../tools/general');
const { ListaIngresso } = require('./listaingresso');
const { Settings } = require('./settings');
const { User } = require('./user');
const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
mongoose.set('debug', process.env.DEBUG);
const FlottaSchema = new mongoose.Schema({
idapp: {
type: String,
required: true,
},
index: {
type: Number
},
riga: {
type: Number,
},
col_prima: {
type: Number,
},
col_ultima: {
type: Number,
},
date_start: {
type: Date
},
date_close: {
type: Date
},
provvisoria: {
type: Boolean,
},
DoniAttesaDiConferma: {
type: Number,
},
DoniMancanti: {
type: Number,
},
DoniConfermati: {
type: Number,
},
DoniTotali: {
type: Number,
},
note_interne: {
type: String
},
sognatore: {
type: String
},
sognatore_nomecognome: {
type: String
},
link_superchat: {
type: String,
},
link_payment: {
type: String,
},
email_paypal: {
type: String,
},
note_payment: {
type: String,
},
tutor1: {
type: String,
},
tutor2: {
type: String,
},
tutor3: {
type: String,
},
tutorslo: {
type: String,
},
msg_inviato: {
type: Boolean,
},
});
function getQueryProj(myfilter) {
myobjField = {
_id: 1,
idapp: 1,
lang: 1,
ind_order: 1,
name: 1,
surname: 1,
username: 1,
'profile.paymenttypes': 1,
'profile.email_paypal': 1,
'profile.cell': 1,
made_gift: 1,
commento_al_sognatore: 1,
sent_msg_howto_make_gift: 1,
date_made_gift: 1,
note: 1,
received_gift: 1,
date_received_gift: 1,
num_tess: 1,
parent_id: 1,
riga: 1,
col: 1,
created: 1,
// date_start: 1,
// date_gift_chat_open: 1,
// link_chat: 1,
// provvisoria: 1,
// note_bot: 1,
// note_interne: 1,
// tutor: 1,
// tutor_namesurname: 1,
};
const query = [
{ $match: myfilter },
{
$lookup: {
from: "listaingressos",
localField: "ind_order",
foreignField: "ind_order", // field in the user collection
as: "mylista"
}
},
{
$replaceRoot: { newRoot: { $mergeObjects: [ { $arrayElemAt: [ "$mylista", 0 ] }, "$$ROOT" ] } }
},
{
$lookup: {
from: "users",
as: "user",
let: {username: '$username' },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$username', '$$username'] },
{ $eq: ['$idapp', myfilter.idapp] },
]
}
}
}
]
}
},
{
$replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] }, "$$ROOT"] } }
// $replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] },] } }
},
{ $project: myobjField }
];
return query;
}
FlottaSchema.statics.findById = function (idapp, id) {
const Flotta = this;
const myquery = getQueryProj({ idapp, '_id': ObjectID(id) });
return Flotta.aggregate(myquery);
};
FlottaSchema.statics.getFieldsForSearch = function () {
return [{ field: 'ind_order', type: tools.FieldType.number },
{ field: 'col', type: tools.FieldType.number }]
};
FlottaSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
FlottaSchema.statics.findAllIdApp = function (idapp) {
const Flotta = this;
const myfind = { idapp };
return Flotta.find(myfind).sort({ riga: 1, col: 1 });
};
FlottaSchema.statics.getListaFlotta = function (idapp) {
const Flotta = this;
const myfind = { idapp };
return Flotta.find(myfind).sort({ riga: 1, col_prima: 1 });
};
FlottaSchema.statics.getLastFlotta = function (idapp) {
const Flotta = this;
const myfind = { idapp, date_start: { $lte: tools.IncDateNow(0) }, provvisoria: false };
return Flotta.findOne(myfind).sort({ riga: -1, col_prima: -1 }).limit(1);
};
FlottaSchema.statics.findByRigaColByDonatore = function (idapp, riga, col, offset) {
const Flotta = this;
mypos = {
riga,
col,
numup: 3 + offset,
};
tools.getRigaColByPosUp(mypos);
return Flotta.findOne({ idapp, riga: mypos.riga, col_prima: mypos.col });
};
FlottaSchema.statics.findByRigaCol = function (idapp, riga, col) {
const Flotta = this;
return Flotta.findOne({ idapp, riga, col });
};
FlottaSchema.statics.getLastRigaCol = async function (idapp) {
return Flotta.findOne({ idapp }).sort({ riga: -1, col_prima: -1 });
};
FlottaSchema.statics.getLastRigaColDefinitiva = async function (idapp) {
return Flotta.findOne({ idapp, provvisoria: false }).sort({ riga: -1, col_prima: -1 });
};
FlottaSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await Flotta.findOne().limit(1).sort({ _id: -1 });
if (!!myrec) {
this.index = myrec._doc.index + 1;
} else {
this.index = 1;
}
}
next();
});
FlottaSchema.statics.addRecordFlottaByParams = async function (params) {
// Check if Exist:
const giapresente = await Flotta.findOne({
idapp: params.idapp,
riga: params.riga,
col: params.col
});
if (!giapresente) {
// Prende la nave prima:
const lastnave = await Flotta.findOne({idapp}).sort({riga: -1, col: -1});
let nextgiftchat = null;
if (((params.col - 1) % 8 === 0)) {
nextgiftchat = getNextDayNave(lastnave.date_gift_chat_open);
} else {
nextgiftchat = lastnave.date_gift_chat_open;
}
const next_date_start = tools.AddDate(nextgiftchat, 7);
let myFlotta = new Flotta({
idapp: params.idapp,
riga: params.riga,
col: params.col,
riga1don: params.riga1don,
col1don: params.col1don,
date_gift_chat_open: nextgiftchat,
date_start: next_date_start,
provvisoria: true,
});
return await myFlotta.save();
}
return false;
};
FlottaSchema.statics.getFlottaByNavePersistente = async function (idapp, navepers) {
const Flotta = this;
// const indcolflottaprima = tools.getPrimaColFlotta(navepers.col1don + 7);
const myflotta = await Flotta.findOne({ idapp, riga: navepers.riga,
$and: [
{ col_prima: { $lte: navepers.col1don } },
{ col_ultima: { $gte: navepers.col1don } } ]
});
return myflotta;
};
const Flotta = mongoose.model('Flotta', FlottaSchema);
module.exports = { Flotta };

View File

@@ -78,6 +78,12 @@ const GraduatoriaSchema = new mongoose.Schema({
invitante_username: {
type: String,
},
navestr: {
type: String,
},
note: {
type: String,
},
date_added: { // Data d'Ingresso (Completato i Requisiti o premuto Bottone Magico)
type: Date,
},
@@ -197,11 +203,15 @@ GraduatoriaSchema.statics.addSingoloInGraduatoria_InFondo = async function (idap
const { ListaIngresso } = require('../models/listaingresso');
if (!!lastimbarco) {
arrindex[recingr.username] = lastimbarco.indimbarco;
} else {
arrindex[recingr.username] = 1;
}
const newingr = await ListaIngresso.aggiornaRecListaIngr(idapp, recingr, arrindex);
const myrectoadd = addRecGraduatoria(idapp, newingr);
const myrectoadd = addRecGraduatoria(idapp, newingr, 100000);
return await myrectoadd.save(myrectoadd)
.then((ris) => {
@@ -211,6 +221,7 @@ GraduatoriaSchema.statics.addSingoloInGraduatoria_InFondo = async function (idap
console.error(e.message);
});
};
function addRecGraduatoria(idapp, ingr, index) {
@@ -233,6 +244,8 @@ function addRecGraduatoria(idapp, ingr, index) {
numinvitatiattiviTot: ingr.numinvitatiattiviTot,
punteggio: ingr.punteggio,
invitante_username: ingr.invitante_username,
navestr: ingr.navestr,
note: ingr.note,
date_added: ingr.date_added,
});
@@ -312,12 +325,24 @@ GraduatoriaSchema.statics.isWorking = function (idapp) {
};
GraduatoriaSchema.statics.isUpdating = function (idapp) {
return Settings.getValDbSettings(idapp, tools.UPDATE_GRADUATORIA, false);
};
GraduatoriaSchema.statics.setWorking = function (idapp, stato) {
return Settings.setBool(idapp, 'GRAD_WORK', stato);
};
GraduatoriaSchema.statics.setGradUpdating = function (idapp, stato) {
return Settings.setBool(idapp, tools.UPDATE_GRADUATORIA, stato);
};
function getinvit(index, myrec) {
let inv = myrec.numinvitati;
let invattivi = myrec.numinvitatiattivi;

View File

@@ -54,6 +54,9 @@ const ListaIngressoSchema = new mongoose.Schema({
num_tess: {
type: Number,
},
navestr: {
type: String,
},
note: {
type: String,
},
@@ -614,8 +617,8 @@ ListaIngressoSchema.statics.GeneraGraduatoria = async function (idapp, solonuovi
let myquery = '';
//++Todo: DA TOGLIERE IL COMMENTO !!!
// if (await Graduatoria.isWorking(idapp))
// return;
if (await Graduatoria.isWorking(idapp))
return;
await Graduatoria.setWorking(idapp, true);
@@ -627,6 +630,7 @@ ListaIngressoSchema.statics.GeneraGraduatoria = async function (idapp, solonuovi
surname: 1,
username: 1,
invitante_username: 1,
navestr: 1,
email: 1,
lang: 1,
num_tess: 1,
@@ -638,8 +642,13 @@ ListaIngressoSchema.statics.GeneraGraduatoria = async function (idapp, solonuovi
try {
let myfilter2 = {
surname: { $exists: true },
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
$or: [{ surname: { $exists: true } }, { deleted: { $exists: false } }, {
deleted: {
$exists: true,
$eq: false
}
}],
};
if (solonuovi) {
@@ -931,8 +940,13 @@ ListaIngressoSchema.statics.getarray = async function (idapp, filtri, myobjField
let myfilter2 = {
surname: { $exists: true },
$or: [{ 'user.deleted': { $exists: false } }, { 'user.deleted': { $exists: true, $eq: false } }],
$or: [{ surname: { $exists: true } }, { 'user.deleted': { $exists: false } }, {
'user.deleted': {
$exists: true,
$eq: false
}
}],
};
let myquery = getQueryProj(
@@ -949,8 +963,8 @@ ListaIngressoSchema.statics.getarrayIndOrder = async function (idapp, filtri, my
const ListaIngresso = this;
let myfilter2 = {
surname: { $exists: true },
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
$or: [{ surname: { $exists: true } }, { deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
};
let myquery = getQueryIndOrder(
@@ -973,7 +987,8 @@ ListaIngressoSchema.statics.getIngrEUserByFilter = async function (idapp, myfilt
ind_order: 1,
name: 1,
surname: 1,
index: 1
index: 1,
num_tess: 1
});
if (!!arr) {
@@ -989,7 +1004,7 @@ ListaIngressoSchema.statics.getInvitati = async function (idapp, username, inclu
let myq = {
idapp,
$or: [{ 'user.deleted': { $exists: false } }, { 'user.deleted': { $exists: true, $eq: false } }],
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
invitante_username: username,
};
@@ -1043,7 +1058,7 @@ ListaIngressoSchema.statics.getnumInvitatiBase = async function (idapp, username
idapp,
invitante_username: username,
// username: { $ne: username },
$or: [{ 'user.deleted': { $exists: false } }, { 'user.deleted': { $exists: true, $eq: false } }],
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
},
{ username: 1, ind_order: 1 },
myfilter2,
@@ -1058,7 +1073,7 @@ ListaIngressoSchema.statics.getnumInvitatiBase = async function (idapp, username
idapp,
aportador_solidario: username,
//$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
$or: [{ 'user.deleted': { $exists: false } }, { 'user.deleted': { $exists: true, $eq: false } }],
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
};
if (attivi) {
@@ -1114,13 +1129,37 @@ ListaIngressoSchema.statics.getnumInvitati = async function (idapp, username) {
};
ListaIngressoSchema.statics.Esegui_CronTab = async function (idapp) {
ListaIngressoSchema.statics.Esegui_CronTab = async function (idapp, mydata) {
const ListaIngresso = this;
console.log('Lancia CronTab: [IDAPP=' + idapp + ']');
await ListaIngresso.GeneraGraduatoria(idapp, true);
let num = 0;
try {
if (!await Graduatoria.isUpdating()) {
await Graduatoria.setGradUpdating(idapp, true);
ris = await Nave.delNaviProvvisorie(idapp);
mystr = await ListaIngresso.GeneraGraduatoria(idapp, true);
await Graduatoria.setWorking(idapp, false);
num = await Nave.generaNave(idapp, mydata, false);
}
} catch (e) {
console.error('ERRORE CronTab: [IDAPP=' + idapp + ']', e.message);
} finally {
await Graduatoria.setGradUpdating(idapp, false);
await Graduatoria.setWorking(idapp, false);
console.log('FINE CronTab: [IDAPP=' + idapp + ']');
}
return num;
};
ListaIngressoSchema.statics.getnumInvitatiAttivi = function (idapp, username) {

102
src/server/models/msg_template.js Executable file
View File

@@ -0,0 +1,102 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const tools = require('../tools/general');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const MsgTemplateSchema = new Schema({
idapp: {
type: String,
},
typemsg: {
type: Number,
},
title: {
type: String,
},
title_it: {
type: String,
},
msg_it: {
type: String,
},
title_enUs: {
type: String,
},
msg_enUs: {
type: String,
},
title_si: {
type: String,
},
msg_si: {
type: String,
},
title_fr: {
type: String,
},
msg_fr: {
type: String,
},
title_es: {
type: String,
},
msg_es: {
type: String,
},
title_pt: {
type: String,
},
msg_pt: {
type: String,
},
});
MsgTemplateSchema.statics.getFieldsForSearch = function () {
return [{ field: 'title', type: tools.FieldType.string },
]
};
MsgTemplateSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
MsgTemplateSchema.statics.getMsgByLang = async function (idapp, typemsg, lang) {
const MsgTemplate = this;
try {
const mymsg = await MsgTemplate.findOne({ idapp, typemsg });
if (!!mymsg) {
if ((!!mymsg["msg_" + lang]) && (!!mymsg["title_" + lang])) {
return { body: mymsg["msg_" + lang], title: mymsg["title_" + lang] }
}
}
} catch (e) {
return { body: '', title: '' };
}
return { body: '', title: '' };
};
MsgTemplateSchema.statics.findAllIdApp = async function (idapp) {
const MsgTemplate = this;
const myfind = { idapp };
return await MsgTemplate.find(myfind, (err, arrrec) => {
return arrrec
});
};
const MsgTemplate = mongoose.model('MsgTemplate', MsgTemplateSchema);
module.exports = { MsgTemplate };

View File

@@ -7,6 +7,7 @@ const { ListaIngresso } = require('./listaingresso');
const { NavePersistente } = require('./navepersistente');
const { Settings } = require('./settings');
const { User } = require('./user');
const { Flotta } = require('../models/flotta');
const { ObjectID } = require('mongodb');
@@ -73,6 +74,9 @@ const NaveSchema = new mongoose.Schema({
type: Number,
default: 1
},
commento_al_sognatore: {
type: String
},
note: {
type: String
},
@@ -272,6 +276,21 @@ NaveSchema.statics.getusersByNave = function (idapp, navemediatore) {
};
NaveSchema.statics.getusersByFlotta = function (idapp, riga, col_prima, col_ultima) {
const miaquery = {
idapp,
riga: riga + 3,
$and: [
{ col: { $gte: col_prima } },
{ col: { $lte: col_ultima } }
],
};
return Nave.find(miaquery);
};
NaveSchema.statics.findRecByRigaColParent = async function (idapp, riga, col, numparentUp) {
const Nave = this;
@@ -427,7 +446,10 @@ function getQueryProj(myfilter) {
'profile.paymenttypes': 1,
'profile.teleg_id': 1,
'profile.email_paypal': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.cell': 1,
commento_al_sognatore: 1,
made_gift: 1,
sent_msg_howto_make_gift: 1,
date_made_gift: 1,
@@ -502,6 +524,7 @@ function getQueryInvitante(myfilter) {
username: 1,
invitante_username: 1,
made_gift: 1,
commento_al_sognatore: 1,
sent_msg_howto_make_gift: 1,
date_made_gift: 1,
note: 1,
@@ -574,13 +597,6 @@ NaveSchema.statics.getCol = function (idapp) {
return Settings.getKeyNum(idapp, 'col', 1);
};
function getPrimoFuocoByIndCol(col) {
// let ris = Math.ceil(col - (col % 8)) + 1;
let ris = ((Math.ceil(col / 8) - 1) * 8) + 1;
if (ris <= 0)
ris = 1;
return ris
}
async function getusertextbyrec(myrec, symbol, lettera, riga, col, ind) {
let visu_test = false;
@@ -619,10 +635,16 @@ function checkifNullThenEmpty(rec, riga, col) {
NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset, solorecord) {
const Nave = this;
const { Flotta } = require('../models/flotta');
try {
let recsognatori = await Nave.findSognatoriByFuoco(idapp, riga, col, offset);
let recmediatore = await Nave.findMediatoreByFuoco(idapp, riga, col, offset);
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, riga, col, offset);
let flotta = null;
if (!!navepersistente)
flotta = await Flotta.getFlottaByNavePersistente(idapp, navepersistente);
if (!solorecord) {
mystr = tools.ACAPO;
@@ -658,7 +680,7 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset,
let arrdonatori = [];
// let numcol = Math.pow(2, indriga - 1);
let primofuoco = getPrimoFuocoByIndCol(col * Math.pow(2, offset));
let primofuoco = tools.getPrimoFuocoByIndCol(col * Math.pow(2, offset));
let ind = 1;
for (let indcol = primofuoco; indcol < primofuoco + 8; indcol++) {
@@ -689,6 +711,7 @@ NaveSchema.statics.getPlaccaGenerica = async function (idapp, riga, col, offset,
recsognatori,
recmediatore,
navepersistente,
flotta,
arrdonatori
};
@@ -1014,7 +1037,7 @@ async function addRecordNaveByParams(params, siRitesse) {
const giapresente = await Nave.findOne({
idapp: params.idapp,
ind_order: params.ind_order,
num_tess: params.num_tess
num_tess: params.num_tess,
});
if (!!giapresente) {
if (params.persistenti) {
@@ -1037,10 +1060,14 @@ async function addRecordNaveByParams(params, siRitesse) {
});
myNave.created = new Date();
if (!!params.note) {
myNave.note = params.note;
}
// console.log('[' + params.riga + ',' + params.col + ']');
// console.log('parent = [' + params.rigaparent + ',' + params.colparent + ']');
const recfindparent = await Nave.findByRigaCol(idapp, params.rigaparent, params.colparent, false);
const recfindparent = await Nave.findByRigaCol(params.idapp, params.rigaparent, params.colparent, false);
// console.log('recfindparent = [' + recfindparent + ']');
// console.table(recfindparent);
@@ -1058,14 +1085,17 @@ async function addRecordNaveByParams(params, siRitesse) {
if (!!result) {
if (params.persistenti) {
let fields_to_update = { added: true };
let fields_to_update = { added: true, navestr: mypos.riga + '.' + mypos.col };
await ListaIngresso.findOneAndUpdate({ _id: params.id.toString() }, { $set: fields_to_update }, { new: false });
} else {
let fields_to_update = { navestr: mypos.riga + '.' + mypos.col };
await ListaIngresso.findOneAndUpdate({ _id: params.id.toString() }, { $set: fields_to_update }, { new: false });
}
params.conta++;
// Check if the Ship has Completed
if (idapp === tools.AYNI) {
if (params.idapp === tools.AYNI) {
if ((params.col % 8) === 0) {
// Completed 8 people
if (!params.primavolta) {
@@ -1089,8 +1119,8 @@ async function addRecordNaveByParams(params, siRitesse) {
else
params.colparent = Math.ceil(params.col / 2);
await Nave.setRiga(idapp, params.riga);
await Nave.setCol(idapp, params.col);
await Nave.setRiga(params.idapp, params.riga);
await Nave.setCol(params.idapp, params.col);
return true;
}
@@ -1126,6 +1156,8 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
const { User } = require('./user');
try {
if (init) {
params.idapp = idapp;
params.conta = 0;
@@ -1147,12 +1179,12 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
const inserito = await addRecordNaveByParams(params, false);
if (inserito) {
if (idapp === tools.AYNI) {
if ((((params.col) % 8) === 0) && (params.col % 64 !== 0)) {
let recmediatore = await Nave.findMediatoreByFuoco(idapp, myriga, mycol, 0);
let sognatore = await Nave.getSognatoreByRigaColMediatore(idapp, recmediatore);
if ((((params.col) % 8) === 0) && ((params.col % 64 !== 0) || (sognatore.username !== recmediatore.username))) {
if (!!recmediatore) {
const ris = await Nave.checkifDeveRitessersi(recmediatore);
if (ris.deveritessersi) {
console.log('Si deve ritessere: [riga=', params.riga, 'col', params.col, ']');
// console.log('Si deve ritessere: [riga=', params.riga, 'col', params.col, ']');
if (ris.deveritessersi) {
params.ind_order = recmediatore.ind_order;
params.id = recmediatore._id;
@@ -1163,7 +1195,6 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
}
}
}
}
/**
if ((params.riga === 4 + 3) && (params.col === (8 * 2) + 3)) {
@@ -1183,6 +1214,9 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
if (addednowreal) {
}
} catch (e) {
console.error(e.message);
}
};
@@ -1233,6 +1267,7 @@ NaveSchema.statics.generaNave = async function (idapp, mydata, persistenti) {
params.ind_order = reclista.ind_order;
params.id = reclista.idListaIngresso;
params.num_tess = reclista.num_tess;
params.note = reclista.note;
params.persistenti = persistenti;
await Nave.addUserFromListaIngresso_IntoNave(index === 0, idapp, params, false);
@@ -1307,26 +1342,49 @@ NaveSchema.statics.pulisciNonPresenzeInNave = async function (idapp) {
NaveSchema.statics.visuNaviUtentiEliminati = async function (idapp) {
const Nave = this;
let numrec = 0;
const { ListaIngresso } = require('./listaingresso');
const { User } = require('./user');
const myquery = getQueryProj({ idapp });
arrrec = await Nave.aggregate(myquery).sort({ riga: 1, col: 1 });
arrnavi = await Nave.find({ idapp }).sort({ riga: 1, col: 1 });
let mystr = 'ELIMINATI: \n';
let conta = 0;
for (const rec of arrrec) {
if (!rec.username) {
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rec.riga, rec.col, 0);
for (const nave of arrnavi) {
const recingr = await ListaIngresso.findOne({
idapp,
ind_order: nave.ind_order,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
});
let rec = null;
if (!!recingr) {
rec = await User.findOne({ idapp, username: recingr.username });
}
if (!rec || !rec.username || rec.deleted) {
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, nave.riga, nave.col, 0);
if (!!navepersistente) {
mystr += '[' + conta + '] [NAVI ' + navepersistente.riga + '.' + navepersistente.col + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order;
mystr += ' num_tess = ' + rec.num_tess;
mystr += '[' + conta + '] [NAVI ' + navepersistente.riga + '.' + navepersistente.col + '] [' + nave.riga + '.' + nave.col + '] ' + ' ord= ' + nave.ind_order;
mystr += ' num_tess = ' + nave.num_tess + ' ';
if (!!rec) {
if (!!rec.username) {
mystr += ' [' + rec.username + '] ';
}
if (!!rec.name) {
mystr += ' (' + rec.name + ' ' + rec.surname + ') ';
}
if (rec.deleted) {
mystr += ' (CANCELLATO)';
}
}
mystr += '\n';
conta++;
}
}
}
return { mystr, num: conta };
};
@@ -1421,6 +1479,58 @@ NaveSchema.statics.getDonatoridelSognatore = async function (idapp, riganave, co
};
NaveSchema.statics.getFlotta = async function (idapp, riga, col_prima, col_ultima) {
const Nave = this;
const myquery = getQueryProj({
idapp,
riga: riga + 3,
col: { $gte: col_prima, $lte: col_ultima }
});
const { Flotta } = require('../models/flotta');
const flotta = await Flotta.findOne({ idapp, riga, col_prima });
const { User } = require('./user');
const usersognatore = await User.findOne({idapp, username: flotta.sognatore });
if (!!usersognatore) {
flotta.link_payment = usersognatore.profile.link_payment;
flotta.email_paypal = usersognatore.profile.email_paypal;
flotta.note_payment = usersognatore.profile.note_payment;
}
const arrnaviout = [];
const arrnavi = await Nave.aggregate(myquery);
for (const nave of arrnavi) {
// Se è il mediatore, allora non includerlo nei Donatori!
mypos = {
riga: nave.riga,
col: nave.col,
numup: 3,
};
tools.getRigaColByPosUp(mypos);
const navemediatore = await Nave.findByRigaCol(idapp, mypos.riga, mypos.col, true);
if (!!navemediatore) {
if (navemediatore.ind_order !== nave.ind_order) {
arrnaviout.push(nave);
}
} else {
arrnaviout.push(nave);
}
}
flotta._doc.log_attivita = tools.readFlottaLog(idapp, flotta.riga, flotta.col_prima);
return { arrdonatori: arrnaviout, flotta };
};
NaveSchema.statics.isDefinitiva = async function (idapp, mynave) {
const nave = await NavePersistente.findByRigaColByDonatore(idapp, mynave.riga, mynave.col, 0);
return (!!nave) ? !nave.provvisoria : false;
@@ -1553,9 +1663,47 @@ NaveSchema.statics.checkIfMadeGift = async function (idapp, username) {
};
NaveSchema.statics.getSognatoreByRigaColMediatore = async function (idapp, navemediatore) {
NaveSchema.statics.delNaviProvvisorie = async function (idapp) {
const Nave = this;
const ris = this.getRigaColSognatoreByMediatore(idapp, navemediatore.riga, navemediatore.col, 3);
let num = 0;
const arrnavi = await Nave.find({ idapp });
for (const nave of arrnavi) {
let persistente = await NavePersistente.findByRigaColByDonatore(idapp, nave.riga, nave.col, 0);
if (!!persistente) {
if (persistente.provvisoria) {
let ris = await Nave.deleteOne({ _id: nave._id });
if (!!ris) {
num++;
}
}
}
}
// Pulisci gli added se era stato cancellato dalla nave
await Nave.pulisciNonPresenzeInNave(idapp);
const data = await Nave.getLastRigaCol(idapp);
await Nave.setRiga(idapp, data.riga);
await Nave.setCol(idapp, data.col + 1);
const maxcol = tools.getmaxcol(data.riga);
if (data.col === maxcol) {
await Nave.setRiga(idapp, data.riga + 1);
await Nave.setCol(idapp, 1);
}
return { num };
};
NaveSchema.statics.getSognatoreByRigaColMediatore = async function (idapp, navemediatore) {
const Nave = this;
const ris = tools.getRigaColSognatoreByMediatore(idapp, navemediatore.riga, navemediatore.col);
const myquery = getQueryProj({
idapp,
@@ -1573,7 +1721,6 @@ NaveSchema.statics.getSognatoreByRigaColMediatore = async function (idapp, navem
return null;
};
const Nave = mongoose.model('Nave', NaveSchema);
module.exports = { Nave };

View File

@@ -7,6 +7,8 @@ const { ListaIngresso } = require('./listaingresso');
const { Settings } = require('./settings');
const { User } = require('./user');
const { Flotta } = require('./flotta');
const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
@@ -92,6 +94,8 @@ function getQueryProj(myfilter) {
username: 1,
'profile.paymenttypes': 1,
'profile.email_paypal': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.cell': 1,
made_gift: 1,
sent_msg_howto_make_gift: 1,
@@ -125,13 +129,13 @@ function getQueryProj(myfilter) {
}
},
{
$replaceRoot: { newRoot: { $mergeObjects: [ { $arrayElemAt: [ "$mylista", 0 ] }, "$$ROOT" ] } }
$replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$mylista", 0] }, "$$ROOT"] } }
},
{
$lookup: {
from: "users",
as: "user",
let: {username: '$username' },
let: { username: '$username' },
pipeline: [
{
$match: {
@@ -250,10 +254,13 @@ NavePersistenteSchema.statics.findByRigaCol = function (idapp, riga, col) {
NavePersistenteSchema.statics.getLastRigaCol = async function (idapp) {
const NavePersistente = this;
return NavePersistente.findOne({ idapp }).sort({ riga: -1, col: -1 });
};
NavePersistenteSchema.statics.getLastRigaColDefinitiva = async function (idapp) {
const NavePersistente = this;
return NavePersistente.findOne({ idapp, provvisoria: false }).sort({ riga: -1, col: -1 });
};
@@ -272,7 +279,8 @@ NavePersistenteSchema.pre('save', async function (next) {
function getNextDayNave(miadata) {
const dayofweek = [1, 3, 5]; // LUNEDI, MERCOLEDI, VENERDI
// const dayofweek = [1, 2, 4, 5]; // LUNEDI, MARTEDI', GIOVEDI, VENERDI
const dayofweek = [1, 4]; // LUNEDI, GIOVEDI
let mydate = tools.AddDate(miadata, 1);
@@ -285,6 +293,7 @@ function getNextDayNave(miadata) {
}
NavePersistenteSchema.statics.addRecordNavePersistenteByParams = async function (params) {
const NavePersistente = this;
// Check if Exist:
const giapresente = await NavePersistente.findOne({
@@ -295,7 +304,7 @@ NavePersistenteSchema.statics.addRecordNavePersistenteByParams = async function
if (!giapresente) {
// Prende la nave prima:
const lastnave = await NavePersistente.findOne({idapp}).sort({riga: -1, col: -1});
const lastnave = await NavePersistente.findOne({ idapp: params.idapp }).sort({ riga: -1, col: -1 });
let nextgiftchat = null;
@@ -323,6 +332,160 @@ NavePersistenteSchema.statics.addRecordNavePersistenteByParams = async function
return false;
};
NavePersistenteSchema.statics.generaFlotte = async function (idapp) {
const NavePersistente = this;
// await Flotta.deleteMany({ idapp });
const arrnavi = await NavePersistente.find({ idapp, col: { $mod: [8, 1] } }).sort({ riga: 1, col: 1 });
let num = 0;
for (const navepers of arrnavi) {
const ris = await NavePersistente.aggiornaFlottaByNavePersistente(idapp, navepers);
if (ris)
num++;
}
return { num }
};
NavePersistenteSchema.statics.changeField = async function (idapp, flotta, fieldvalue) {
let myval = {};
if ('date_close' in fieldvalue) {
myval['date_gift_chat_open'] = fieldvalue['date_close'];
} else {
myval = fieldvalue;
}
const ris = await NavePersistente.updateMany({
idapp,
riga: flotta.riga,
$and: [
{ col1don: { $gte: flotta.col_prima } },
{ col1don: { $lte: flotta.col_ultima } },
]
}, { $set: myval });
return ris;
};
NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function (idapp, naveinput) {
const { Nave } = require('../models/nave');
const { User } = require('./user');
let num = 0;
try {
let nuovo = false;
// let primacol = false;
indcolflottaprima = tools.getPrimaColFlotta(naveinput.col1don + 7);
console.log(num, ' -> [', naveinput.riga, '.', naveinput.col, '] indcolflottaprima=', indcolflottaprima);
let ini = Math.ceil(indcolflottaprima / 8);
let fine = ini + 7;
const arrnavi = await NavePersistente.find({
idapp,
riga: naveinput.riga,
$and: [{ col: { $gte: ini } }, { col: { $lte: fine } }]
}).sort({ riga: 1, col: 1 });
let primogiro = true;
let myflotta = await Flotta.findOne({ idapp, riga: naveinput.riga, col_prima: indcolflottaprima });
if (!myflotta) {
myflotta = new Flotta({
_id: new ObjectID(),
idapp,
});
nuovo = true;
}
for (const navepers of arrnavi) {
if (primogiro) {
myflotta.DoniAttesaDiConferma = 0;
myflotta.DoniMancanti = 0;
myflotta.DoniConfermati = 0;
myflotta.DoniTotali = 0;
primogiro = false;
}
if (nuovo) {
myflotta.riga = navepers.riga;
myflotta.col_prima = indcolflottaprima;
myflotta.col_ultima = indcolflottaprima + 63;
myflotta.sognatore = '';
myflotta.sognatore_nomecognome = '';
myflotta.link_superchat = '';
myflotta.msg_inviato = false;
}
myflotta.date_start = navepers.date_start;
myflotta.date_close = navepers.date_gift_chat_open;
let sognatore = await Nave.getSognatoreByRigaColMediatore(idapp, { riga: navepers.riga, col: navepers.col });
if (myflotta.sognatore_nomecognome === '') {
myflotta.sognatore = sognatore.username;
if (!!sognatore.username)
myflotta.sognatore_nomecognome = await User.getNameSurnameByUsername(idapp, sognatore.username);
}
if (nuovo) {
myflotta.email_paypal = '';
myflotta.link_payment = '';
myflotta.note_payment = '';
if (!!sognatore) {
myflotta.email_paypal = sognatore.profile.email_paypal;
myflotta.link_payment = sognatore.profile.link_payment;
myflotta.note_payment = sognatore.profile.note_payment;
}
}
if (!!sognatore) {
if (!myflotta.email_paypal)
myflotta.email_paypal = sognatore.profile.email_paypal;
if (!myflotta.link_payment)
myflotta.link_payment = sognatore.profile.link_payment;
if (!myflotta.note_payment)
myflotta.note_payment = sognatore.profile.note_payment;
}
myflotta.provvisoria = navepers.provvisoria;
if (!!navepers.DoniAttesaDiConferma && !isNaN(navepers.DoniAttesaDiConferma))
myflotta.DoniAttesaDiConferma += navepers.DoniAttesaDiConferma;
if (!!navepers.DoniMancanti && !isNaN(navepers.DoniMancanti))
myflotta.DoniMancanti += navepers.DoniMancanti;
if (!!navepers.DoniConfermati && !isNaN(navepers.DoniConfermati))
myflotta.DoniConfermati += navepers.DoniConfermati;
if (!!navepers.DoniTotali && !isNaN(navepers.DoniTotali))
myflotta.DoniTotali += navepers.DoniTotali;
}
await myflotta.save();
return true;
} catch (e) {
console.log(e.message);
return false;
}
};
const NavePersistente = mongoose.model('NavePersistente', NavePersistenteSchema);

View File

@@ -56,7 +56,7 @@ SettingsSchema.statics.getValDbSettings = function (idapp, key, def) {
return Settings.findOne({ idapp, key })
.then((myrec) => {
// console.log('getValDbSettings', myrec, 'idapp', idapp);
if (myrec) {
if (!!myrec) {
if (myrec.type === tools.FieldType.date)
return myrec.value_date;
else if (myrec.type === tools.FieldType.number)
@@ -112,6 +112,8 @@ SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
myrec = await Settings.findOneAndUpdate({ idapp, key }, { $set: { value_num: value } }, { new: false });
}
return myrec
};
SettingsSchema.statics.setBool = async function (idapp, key, valbool) {
@@ -130,6 +132,8 @@ SettingsSchema.statics.setBool = async function (idapp, key, valbool) {
myrec = await Settings.findOneAndUpdate({ idapp, key }, { $set: { value_bool: valbool } }, { new: false });
}
return myrec
};

View File

@@ -6,6 +6,7 @@ const _ = require('lodash');
const tools = require('../tools/general');
const { Flotta } = require('../models/flotta');
const { Settings } = require('../models/settings');
const { ListaIngresso } = require('../models/listaingresso');
const { Graduatoria } = require('../models/graduatoria');
@@ -153,6 +154,15 @@ const UserSchema = new mongoose.Schema({
sospeso: {
type: Boolean
},
non_voglio_imbarcarmi: {
type: Boolean
},
navinonpresenti: {
type: Boolean
},
subaccount: {
type: Boolean
},
profile: {
img: {
type: String
@@ -175,6 +185,12 @@ const UserSchema = new mongoose.Schema({
email_paypal: {
type: String
},
link_payment: {
type: String
},
note_payment: {
type: String
},
paymenttypes: [],
username_telegram: {
type: String
@@ -203,10 +219,13 @@ const UserSchema = new mongoose.Schema({
saw_zoom_presentation: {
type: Boolean
},
special_req: {
qualified: {
type: Boolean
},
vuole_ritessersi: {
qualified_2invitati: {
type: Boolean
},
special_req: {
type: Boolean
},
sex: {
@@ -345,7 +364,17 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) {
return User.findOne({
idapp, username: username,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } },
{
$and: [
{ deleted: { $exists: true, $eq: true } },
{ subaccount: { $exists: true, $eq: true } }
]
}
],
}).then((user) => {
if (!user) {
// Check if with email:
@@ -354,7 +383,7 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) {
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
})
} else {
return !user.deleted ? user : null
return !user.deleted || (user.deleted && user.subaccount) ? user : null
}
}).then(user => {
if (!user)
@@ -409,6 +438,7 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username)
'username': username,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
}, {
idapp: 1,
lang: 1,
index: 1,
ind_order: 1,
@@ -421,8 +451,12 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username)
verified_email: 1,
'profile.teleg_id': 1,
'profile.saw_zoom_presentation': 1,
'profile.qualified': 1,
'profile.qualified_2invitati': 1,
'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.my_dream': 1,
'profile.paymenttypes': 1,
'profile.cell': 1,
@@ -467,8 +501,12 @@ UserSchema.statics.getDownlineByUsername = async function (idapp, username, incl
verified_email: 1,
'profile.teleg_id': 1,
'profile.saw_zoom_presentation': 1,
'profile.qualified': 1,
'profile.qualified_2invitati': 1,
'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.my_dream': 1,
'profile.paymenttypes': 1,
'profile.cell': 1,
@@ -558,7 +596,6 @@ UserSchema.statics.getQueryQualified = function () {
}
UserSchema.statics.isUserQualified7 = async function (idapp, username) {
const User = this;
@@ -576,6 +613,72 @@ UserSchema.statics.isUserQualified7 = async function (idapp, username) {
return !!myrec;
};
UserSchema.statics.isUserAlreadyQualified = async function (idapp, username) {
const User = this;
if (username === undefined)
return false;
const myquery = {
'idapp': idapp,
'username': username,
'profile.qualified': { $exists: true, $eq: true },
};
const myrec = await User.findOne(myquery);
return !!myrec;
};
UserSchema.statics.isUserAlreadyQualified_2Invitati = async function (idapp, username) {
const User = this;
if (username === undefined)
return false;
const myquery = {
'idapp': idapp,
'username': username,
'profile.qualified_2invitati': { $exists: true, $eq: true },
};
const myrec = await User.findOne(myquery);
return !!myrec;
};
UserSchema.statics.setUserQualified = async function (idapp, username) {
const User = this;
if (username === undefined)
return false;
const myquery = {
'idapp': idapp,
'username': username,
};
const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified': true } }, { new: false } );
return !!myrec;
};
UserSchema.statics.setUserQualified_2Invitati = async function (idapp, username) {
const User = this;
if (username === undefined)
return false;
const myquery = {
'idapp': idapp,
'username': username,
};
const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified_2invitati': true } }, { new: false } );
return !!myrec;
};
UserSchema.statics.isUserQualified9 = async function (idapp, username) {
const User = this;
@@ -873,6 +976,22 @@ UserSchema.statics.SetTelegramCheckCode = async function (idapp, id, teleg_check
};
UserSchema.statics.NonVoglioImbarcarmi = async function (idapp, username) {
const User = this;
const fields_to_update = {
non_voglio_imbarcarmi: true
};
return await User.findOneAndUpdate({
idapp,
username,
}, { $set: fields_to_update }, { new: false }).then((record) => {
return !!record;
});
};
UserSchema.statics.SetTelegramIdSuccess = async function (idapp, id, teleg_id) {
const User = this;
@@ -923,7 +1042,7 @@ UserSchema.statics.SetTelegramWasBlocked = async function (idapp, teleg_id) {
'profile.teleg_id': 0,
};
if (process.env.PROD === 1) {
if (process.env.PROD === "1") {
const ris = await User.findOneAndUpdate({
idapp,
@@ -1007,10 +1126,15 @@ UserSchema.statics.getRecByIndOrder = async function (idapp, ind_order) {
ind_order: 1,
old_order: 1,
username: 1,
email: 1,
name: 1,
lang: 1,
surname: 1,
'profile.teleg_id': 1,
'profile.email_paypal': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.paymenttypes': 1,
};
const rec = await ListaIngresso.getarray(idapp,
@@ -1161,6 +1285,7 @@ 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.link_payment', type: tools.FieldType.string },
{ field: 'profile.teleg_id', type: tools.FieldType.number },
{ field: 'profile.username_telegram', type: tools.FieldType.string },
{ field: 'aportador_solidario', type: tools.FieldType.string }]
@@ -1235,6 +1360,8 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us
for (let mypos of dashboard.arrposizioni) {
mypos.rec = await Nave.getNaveByRigaCol(idapp, mypos.riga, mypos.col);
mypos.nave_partenza = await NavePersistente.findByRigaColByDonatore(idapp, mypos.riga, mypos.col, 0);
if (!!mypos.nave_partenza)
mypos.flotta = await Flotta.getFlottaByNavePersistente(idapp, mypos.nave_partenza);
}
@@ -1924,6 +2051,111 @@ UserSchema.statics.changeInvitante = async function (idapp, username, invitante_
};
UserSchema.statics.NessunaNavePresenteByUsername = async function (idapp, username) {
const User = this;
const rec = await User.findOne({ idapp, username }, { username: 1, ind_order: 1 });
if (!!rec) {
// Controlla se è qualificato!
const qualified = await User.isUserQualified7(idapp, rec.username);
if (qualified) {
// Ha un'imbarco almeno?
const arrimbarchi = await ListaIngresso.findOne({
idapp, username: rec.username,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
});
const arrnavi = await Nave.findOne({
idapp, ind_order: rec.old_order,
});
if (!arrimbarchi && !arrnavi) {
// NEANCHE 1 !
const recout = await User.findOneAndUpdate({
idapp,
username
}, { $set: { navinonpresenti: true } }, { new: false });
return (!!recout);
}
}
}
return false;
};
UserSchema.statics.flagUtentiNaviNonPresenti = async function (idapp) {
const User = this;
let num = 0;
await User.updateMany({ idapp }, { $set: { navinonpresenti: false } });
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) {
const nessunanave = await User.NessunaNavePresenteByUsername(idapp, rec.username);
if (nessunanave)
num++;
}
return { num };
};
UserSchema.statics.addNavePerUtentiNaviNonPresenti = async function (idapp) {
const User = this;
let num = 0;
arrusers = await User.find({
'idapp': idapp,
navinonpresenti: true
});
for (const user of arrusers) {
// Controlla se è qualificato!
mydata = tools.AddDate(user.date_reg, 7);
const newrecingr = await ListaIngresso.addUserInListaIngresso(idapp, user.username, user.aportador_solidario, user.lang, true, true, mydata);
await tools.snooze(1000);
num++;
}
return { num };
};
UserSchema.statics.convSubAccount = async function (idapp) {
const User = this;
// Solo i Cancellati !
arrusers = await User.find({ 'idapp': idapp, deleted: true });
let num = 0;
for (const rec of arrusers) {
// Cerca il suo Principale!
const trovato = await User.findOne({
idapp,
'profile.teleg_id': rec.profile.teleg_id,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
});
if (trovato) {
num++;
await User.findByIdAndUpdate(rec._id, { subaccount: true }, { new: false });
}
}
return { num };
};
UserSchema.statics.DbOp = async function (idapp, mydata) {
const User = this;
try {

View File

@@ -13,7 +13,7 @@ const tools = require('../../tools/general');
const telegrambot = require('../../telegram/telegrambot');
module.exports = {
doOtherThingsAfterDeleted: async function (tablename, rec, notifBot) {
doOtherThingsAfterDeleted: async function (tablename, rec, notifBot, req) {
try {
let ris = null;
if (tablename === 'users') {
@@ -42,12 +42,13 @@ module.exports = {
ris = await Graduatoria.deleteOne({ idListaIngresso: ObjectID(rec._id) });
if (!!ris) {
let msg = 'Eliminato Imbarco di ' + rec.name + ' ' + rec.surname + ' [Index = ' + rec.index + ']';
let msg = 'Eliminato Imbarco di ' + rec.name + ' ' + rec.surname + ' (ind_order=' + rec.ind_order + ', num_tess=' + rec.num_tess + ') [Num = ' + rec.index + `] (da ${req.user.name} ${req.user.surname} )` ;
await telegrambot.sendMsgTelegramToTheManagers(rec.idapp, msg);
tools.writeSostituzioniLog(msg);
}
// Elimina anche la Nave se è temporanea!
const arrnave = await Nave.find({ idapp: rec.idapp, ind_order: rec.ind_order });
const arrnave = await Nave.find({ idapp: rec.idapp, ind_order: rec.ind_order, num_tess: rec.num_tess });
for (const mynave of arrnave) {
if (!!mynave) {
if (!await Nave.isDefinitiva(rec.idapp, mynave)) {

View File

@@ -10,7 +10,9 @@ const { authenticate } = require('../middleware/authenticate');
const { User } = require('../models/user');
const { Nave } = require('../models/nave');
const { Flotta } = require('../models/flotta');
const { NavePersistente } = require('../models/navepersistente');
const { MsgTemplate } = require('../models/msg_template');
const mongoose = require('mongoose');
const Subscription = mongoose.model('subscribers');
@@ -94,10 +96,11 @@ router.post('/msgnave', authenticate, async (req, res) => {
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_SINGOLO) {
let mymsg = '';
if (!!mydata.username_mitt) {
mymsg = '[' + tools.getres__('MSG_SEND_FROM', res) + ' ' + mydata.username_mitt + ']:' + tools.ACAPO;
mymsg = '[' + tools.getres__('MSG_SEND_FROM', res) + ' ' + mydata.username_mitt + ' a ' + mydata.username + ']:' + tools.ACAPO;
}
mymsg += mydata.msgpar1;
ris = await telegrambot.sendMsgTelegram(idapp, mydata.username, mymsg, true, mydata.username_mitt); // Anche a STAFF
// ris = await telegrambot.sendMsgTelegram(idapp, mydata.username, mymsg, true, mydata.username_mitt); // Anche a STAFF
ris = await telegrambot.sendMsgTelegram(idapp, mydata.username, mymsg, true); // Anche a STAFF
} else
ris = await telegrambot.sendMsgTelegramToNave(idapp, mydata);
@@ -113,6 +116,27 @@ router.post('/msgnave', authenticate, async (req, res) => {
});
router.post('/msgflotta', authenticate, async (req, res) => {
const idapp = req.body.idapp;
let mydata = req.body;
try {
let ris = null;
ris = await telegrambot.sendMsgTelegramToNave(idapp, mydata);
if (ris)
res.send({ code: server_constants.RIS_CODE_OK, ris });
else
res.send({ code: server_constants.RIS_CODE_ERR, ris: null });
} catch (e) {
res.status(400).send(e);
}
});
router.post('/getnave', authenticate, async (req, res) => {
const idapp = req.body.idapp;
const riga = req.body.riga;
@@ -144,6 +168,9 @@ router.post('/getnave', authenticate, async (req, res) => {
router.post('/getnavi', authenticate, async (req, res) => {
const idapp = req.body.idapp;
const { Flotta } = require('../models/flotta');
let arrnavi = await NavePersistente.findAllIdApp(idapp);
// let arrnavi = await NavePersistente.find({idapp, date_gift_chat_open: { $gte: tools.IncDateNow(-1000 * 3600 * 24 * 7 ) } }).sort({ riga: 1, col: 1 });
@@ -163,6 +190,8 @@ router.post('/getnavi', authenticate, async (req, res) => {
// }
// nave._doc.rec.donatore.navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, riganave, colnave, 0);
nave._doc.rec.donatore.navepersistente = await NavePersistente.findOne({ idapp, riga: riganave, col: colnave });
if (!!nave._doc.rec.donatore.navepersistente)
nave._doc.rec.donatore.flotta = await Flotta.getFlottaByNavePersistente(idapp, nave._doc.rec.donatore.navepersistente);
}
const navi_partenza = await NavePersistente.findAllIdApp(idapp);
@@ -176,6 +205,48 @@ router.post('/getnavi', authenticate, async (req, res) => {
});
router.post('/getmsg_templates', authenticate, async (req, res) => {
const idapp = req.body.idapp;
let ris = await MsgTemplate.findAllIdApp(idapp);
if (!!ris)
res.send({ code: server_constants.RIS_CODE_OK, ris });
else
res.status(400).send(e);
});
router.post('/getflotte', authenticate, async (req, res) => {
const idapp = req.body.idapp;
let arrflotte = await Flotta.findAllIdApp(idapp);
if (!!arrflotte)
res.send({ code: server_constants.RIS_CODE_OK, arrflotte });
else
res.status(400).send(e);
});
router.post('/getflotta', authenticate, async (req, res) => {
const idapp = req.body.idapp;
const riga = req.body.riga;
const col_prima = req.body.col_prima;
const col_ultima = req.body.col_ultima;
let ris = await Nave.getFlotta(idapp, riga, col_prima, col_ultima);
ris.flotta._doc.log_attivita = tools.readFlottaLog(idapp, ris.flotta.riga, ris.flotta.col_prima);
if (!!ris)
res.send({ code: server_constants.RIS_CODE_OK, flotta: ris.flotta, arrdonatori: ris.arrdonatori });
else
res.status(400).send(e);
});
router.post('/getdoninavi', authenticate, async (req, res) => {
const idapp = req.body.idapp;
const ricalcola = req.body.ricalcola;
@@ -185,7 +256,7 @@ router.post('/getdoninavi', authenticate, async (req, res) => {
if (showall)
arrnavi = await NavePersistente.findAllIdApp(idapp);
else
arrnavi = await NavePersistente.find({idapp, date_gift_chat_open: { $gte: tools.IncDateNow(-1000 * 3600 * 24 * 7 ) } }).sort({ riga: 1, col: 1 });
arrnavi = await NavePersistente.find({idapp, date_gift_chat_open: { $gte: tools.IncDateNow(-1000 * 3600 * 24 * 10 ) } }).sort({ riga: 1, col: 1 });
let test = false;
@@ -201,6 +272,7 @@ router.post('/getdoninavi', authenticate, async (req, res) => {
}
} else {
// arrnavi = await NavePersistente.findAllIdApp(idapp);
let index = 1;
for (nave of arrnavi) {
if (nave.provvisoria || nave.DoniTotali !== nave.DoniConfermati) {
nave._doc.rec = await Nave.getNaveByRigaCol(idapp, nave.riga1don, nave.col1don);
@@ -214,8 +286,13 @@ router.post('/getdoninavi', authenticate, async (req, res) => {
nave._doc.rec = {};
nave._doc.rec.donatore = {};
nave._doc.rec.donatore.navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rigapos, colpos, tools.Placca.SONOFUOCO);
index++;
}
if (index > 8 * 6 ) {
break;
}
}
}
ris = { arrnavi };

View File

@@ -30,6 +30,7 @@ const _ = require('lodash');
const { User } = require('../models/user');
const { Nave } = require('../models/nave');
const { Flotta } = require('../models/flotta');
const { NavePersistente } = require('../models/navepersistente');
// const { ExtraList } = require('../models/extralist');
const { Booking } = require('../models/booking');
@@ -49,6 +50,7 @@ const { MailingList } = require('../models/mailinglist');
const { Settings } = require('../models/settings');
const { SendMsg } = require('../models/sendmsg');
const { Permission } = require('../models/permission');
const { MsgTemplate } = require('../models/msg_template');
const tools = require('../tools/general');
@@ -220,6 +222,10 @@ function getTableByTableName(tablename) {
mytable = MailingList;
else if (tablename === 'navi')
mytable = Nave;
else if (tablename === 'flotte')
mytable = Flotta;
else if (tablename === 'msg_templates')
mytable = MsgTemplate;
else if (tablename === 'navepersistente')
mytable = NavePersistente;
else if (tablename === 'listaingressos')
@@ -285,6 +291,9 @@ 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;
@@ -298,24 +307,29 @@ async function checkIfSbloccatiRequisiti(idapp, allData, id) {
if (userlista.length === 0) {
// Se non sono ancora dentro alla lista, allora controllo
if (!allData.precDataUser.is7req && is7req) {
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
if (tools.isAbilitaNave(idapp)) {
// Aggiungilo alla ListaIngresso
risingr = await ListaIngresso.addUserInListaIngresso(idapp, allData.myuser.username, allData.myuser.aportador_iniziale, allData.myuser.lang, true, false);
}
}
}
if (!allData.precDataUser.is9req && is9req) {
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) {
/*
@@ -391,7 +405,10 @@ router.patch('/chval', authenticate, async (req, res) => {
if (camporequisiti) {
allData = {};
allData.myuser = await User.getUserById(idapp, id);
if (!!allData.myuser)
allData.precDataUser = await getInfoUser(idapp, allData.myuser.username);
else
allData.precDataUser = null;
// allData.useraportador = await ListaIngresso.getUserByInvitante_Username(idapp, allData.myuser.aportador_solidario);
// allData.precDataAportador = await getInfoUser(idapp, allData.myuser.aportador_solidario);
}
@@ -404,9 +421,42 @@ router.patch('/chval', authenticate, async (req, res) => {
if (!rec) {
return res.status(404).send();
} else {
let addmsg = '';
if (mydata.table === 'navi' && ('made_gift' in fieldsvalue)) {
if (fieldsvalue['made_gift'] && !rec.received_gift) {
if (mydata.tipomsg) {
let mypos = {
idapp,
riga: rec.riga,
col: rec.col,
numup: 3
};
tools.getRigaColByPosUp(mypos);
const myuser = await User.findByIndOrder(idapp, rec.ind_order);
if (!!myuser) {
const mydatamsg = {
tipomsg: tools.TipoMsg.SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE,
navemediatore: { riga: mypos.riga, col: mypos.col },
};
const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg, myuser.lang, myuser, false);
addmsg = rismsg.body;
}
}
await mytable.findByIdAndUpdate(id, { $set: { received_gift: true } });
}
}
// SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE
if (mydata.notifBot) {
// Send Notification to the BOT
await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, mydata.notifBot.txt);
if (!!addmsg)
await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, addmsg);
addtext = '[Msg Inviato a ' + mydata.notifBot.un + ']:' + '\n' + mydata.notifBot.txt;
telegrambot.sendMsgTelegramToTheManagers(idapp, addtext, true);
}
@@ -417,6 +467,12 @@ router.patch('/chval', authenticate, async (req, res) => {
}
}
if (mydata.table === 'flotte') {
if (('date_start' in fieldsvalue) || ('date_close' in fieldsvalue)) {
await NavePersistente.changeField(idapp, rec, fieldsvalue);
}
}
if (mydata.table === 'users') {
if ('aportador_solidario' in fieldsvalue) {
ind_order_ingr = mydata.ind_order_ingr;
@@ -446,7 +502,13 @@ router.patch('/chval', authenticate, async (req, res) => {
return false;
}
} else if ('deleted' in fieldsvalue) {
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${rec.name} ${rec.surname} (${rec.username}) è stato cancellato (nascosto) da ${req.user.name} ${req.user.surname}`);
let msg = '';
if (fieldsvalue.deleted)
msg = 'cancellato (nascosto)';
else
msg = 'Ripristinato';
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${rec.name} ${rec.surname} (${rec.username}) è stato ${msg} da ${req.user.name} ${req.user.surname}`);
}
}
@@ -475,6 +537,13 @@ router.patch('/chval', authenticate, async (req, res) => {
// return false;
}
}
if ('note' in fieldsvalue) {
// Aggiornalo anche in Graduatorie
await Graduatoria.findOneAndUpdate({
idapp,
idListaIngresso: id
}, { $set: { note: fieldsvalue.note } }, { new: false })
}
}
if (tools.ModificheConsentite(mydata.table, fieldsvalue)) {
@@ -496,7 +565,10 @@ 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)
const navepers = await Nave.ricalcolaNave(idapp, null, fieldsvalue.riga, fieldsvalue.col, true, index);
if (!!navepers)
await NavePersistente.aggiornaFlottaByNavePersistente(idapp, navepers);
}
}
}
@@ -539,8 +611,29 @@ router.patch('/askfunz', authenticate, async (req, res) => {
if (!!userfree)
return res.send({ code: server_constants.RIS_CODE_OK, out: userfree });
/*} else if (mydata.myfunc === shared_consts.CallFunz.GET_VALBYTABLE) {
const mytable = getTableByTableName(mydata.table);
const coltoshow = {
[mydata.coltoshow]: 1
};
const ris = await mytable.findOne({ _id: id }, coltoshow);
return ris;
} else if (mydata.myfunc === shared_consts.CallFunz.SET_VALBYTABLE) {
const mytable = getTableByTableName(mydata.table);
const value = mydata.value;
const coltoset = {
[mydata.coltoshow]: value
};
const ris = await mytable.findOneAndUpdate({ _id: id }, { $set: coltoset }, { new: false });
if (!!ris)
return res.send({ code: server_constants.RIS_CODE_OK });*/
}
return res.send({ code: server_constants.RIS_CODE_ERR });
});
router.patch('/callfunz', authenticate, async (req, res) => {
@@ -586,10 +679,11 @@ router.patch('/callfunz', authenticate, async (req, res) => {
if (!!myusernuovo) {
if (!mydata.data.AddImbarco && !!mianavedasost && mianavedasost.ind_order > 0) {
// Controlla prima se è in una Nave Temporanea, allora lo elimina dalla PRIMA Nave Temporanea
// Controlla prima se è in una Nave Temporanea, allora lo elimina dall'ultima Nave Temporanea
miaarrnavi = await Nave.getArrPosizioniByUsername(idapp, username);
if (miaarrnavi) {
miaarrnavi = miaarrnavi.reverse(); // parto dall'ultima
for (const mianave of miaarrnavi) {
let persistente = await NavePersistente.findByRigaColByDonatore(idapp, mianave.riga, mianave.col, 0);
if (persistente.provvisoria) {
@@ -629,7 +723,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
const risdel = await ListaIngresso.deleteOne({ _id: olduseringresso.id });
if (!!risdel) {
await actions.doOtherThingsAfterDeleted('listaingressos', myrecuser, false)
await actions.doOtherThingsAfterDeleted('listaingressos', myrecuser, false, req)
}
}
}
@@ -651,6 +745,28 @@ router.patch('/callfunz', authenticate, async (req, res) => {
await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${myuservecchio.name} ${myuservecchio.surname} (${myuservecchio.username}) è stato cancellato (nascosto) perchè sostituito (da ${req.user.name} ${req.user.surname} )`);
}
}
if (mydata.data.notifBot) {
const mydatamsg = {
tipomsg: tools.TipoMsg.SEND_MSG_A_UTENTE_SOSTITUITO,
navemediatore: { riga: navepersistente.riga, col: navepersistente.col },
};
mydatamsg.flotta = await Flotta.getFlottaByNavePersistente(idapp, navepersistente);
const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg, myuservecchio.lang, myuservecchio, false);
if (!!rismsg) {
let messaggio = rismsg.body;
mytitle = rismsg.title;
if (!!messaggio) {
await telegrambot.sendMsgTelegram(idapp, myusernuovo.username, messaggio);
}
}
}
}
@@ -681,7 +797,6 @@ router.patch('/callfunz', authenticate, async (req, res) => {
}, { $set: { ind_order: -1 } }, { new: false });
// Aggiorna la Nave con il Nuovo
fieldsvalue = {
ind_order
@@ -695,31 +810,50 @@ router.patch('/callfunz', authenticate, async (req, res) => {
if (!rec) {
return res.status(404).send();
} else {
// Send Notification to the BOT
let messaggio = tools.get__('SPOSTATO', req.user.lang);
if (!!navepersistente.date_start) {
messaggio += tools.ACAPO + tools.get__('DATA_PART_NAVE', req.user.lang) + tools.getstrDateLong(navepersistente.date_gift_chat_open) + tools.ACAPO;
}
if (!!navepersistente.link_chat) {
messaggio += tools.ACAPO + '👉🏻👉🏻 <strong><a href="' + navepersistente.link_chat + '">' + tools.get__('ENTRA_GIFT_CHAT', req.user.lang) + '</a></strong> ' + tools.ACAPO;
}
const mydatamsg = {
tipomsg: tools.TipoMsg.SEND_MSG_EFFETTUA_IL_DONO,
navemediatore: { riga: navepersistente.riga, col: navepersistente.col },
};
const myplacca = await Nave.getNavePos(idapp, navepersistente.riga, navepersistente.col);
messaggio += tools.ACAPO + myplacca;
mydatamsg.flotta = await Flotta.getFlottaByNavePersistente(idapp, navepersistente);
const mymsg = mydata.notifBot.txt + ' ' + myusernuovo.name + ' ' + myusernuovo.surname + ' [da ' + dachi + ']' + tools.ACAPO + 'Inviato messaggio: ' + messaggio;
const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg, myusernuovo.lang, myusernuovo, false);
if (mydata.data.notifBot && !!navepersistente.link_chat) {
let messaggio = rismsg.body;
mytitle = rismsg.title;
// const myplacca = await Nave.getNavePos(idapp, navepersistente.riga, navepersistente.col);
// messaggio += tools.ACAPO + myplacca;
let testostaff = '';
if (mydata.notifBot)
testostaff = mydata.notifBot.txt;
const mymsg = testostaff + ' ' + myusernuovo.name + ' ' + myusernuovo.surname + ' [da ' + dachi + ']' + tools.ACAPO + 'Inviato messaggio: ' + messaggio;
if (mydata.data.notifBot) {
await telegrambot.sendMsgTelegram(idapp, myusernuovo.username, messaggio);
await telegrambot.sendMsgTelegramToTheManagers(idapp, mymsg);
await telegrambot.sendMsgTelegram(idapp, req.user.username, mydata.notifBot.txt);
await telegrambot.sendMsgTelegram(idapp, req.user.username, myplacca);
if (mydata.data.inviaemail) {
await sendemail.sendEmail_ByText(myusernuovo.lang, myusernuovo.email, myusernuovo, idapp, {
emailbody: messaggio,
emailtitle: mytitle
});
}
await telegrambot.sendMsgTelegramToTheManagers(idapp, testostaff);
await telegrambot.sendMsgTelegram(idapp, req.user.username, testostaff);
// await telegrambot.sendMsgTelegram(idapp, req.user.username, myplacca);
} else {
tools.writeManagersLog(mymsg);
}
const msgsost = '[NAVE ' + navepersistente.riga + '.' + navepersistente.col + '] Sostituito ' + myuservecchio.username + ' (' + myuservecchio.name + ' ' + myuservecchio.surname + ') ' + ' con -> ' + myusernuovo.username + ' (' + myusernuovo.name + ' ' + myusernuovo.surname + ') ' + ' [da ' + dachi + ']';
tools.writeSostituzioniLog(msgsost);
tools.writeFlottaLog(idapp, msgsost, mydatamsg.flotta.riga, mydatamsg.flotta.col_prima);
await telegrambot.sendMsgTelegramToTheManagers(idapp, msgsost);
// const nomecognomeprima = myuser.name + ' ' + myuser.surname + '(' + myuser.username + ')';
// const nomecognomenuovo = await User.getNameSurnameByUsername(idapp,);
@@ -728,7 +862,7 @@ router.patch('/callfunz', authenticate, async (req, res) => {
}
}).catch((e) => {
tools.mylogserr('Error patch USER: ', e);
tools.mylogserr('Error patch USER: ', e.message);
res.status(400).send();
})
}
@@ -759,15 +893,28 @@ router.patch('/callfunz', authenticate, async (req, res) => {
const myrec = await ListaIngresso.getIngrEUserByFilter(idapp, { idapp, _id: ObjectID(mydata.data.id) });
if (!!myrec) {
const risdel = await ListaIngresso.deleteOne({ _id: mydata.data.id });
const myingr = await ListaIngresso.find({ _id: mydata.data.id });
// Controlla se ci sono 2 navi
const arrnavi = await Nave.find({ idapp, ind_order: mydata.ind_order });
if (!!risdel) {
return await actions.doOtherThingsAfterDeleted('listaingressos', myrec, false)
let risdel = false;
if (arrnavi.length === 1) {
// Solo 1 nave da cancellare, quindi cancello anche l'ingresso
risdel = await ListaIngresso.deleteOne({ _id: mydata.data.id });
} else {
// non cancellare la listaingresso (perchè con lo stesso ind_order ho piu navi !
risdel = true
}
if (risdel) {
return await actions.doOtherThingsAfterDeleted('listaingressos', myrec, false, req)
.then((ris) => {
if (!!ris)
if (!!ris) {
// tools.mylog('DELETED Others things ...');
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
}
});
}
}
@@ -871,7 +1018,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
if (cancellato) {
// Do extra things after deleted
return actions.doOtherThingsAfterDeleted(tablename, myrec, notifBot);
return actions.doOtherThingsAfterDeleted(tablename, myrec, notifBot, req);
}
res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });

View File

@@ -3,6 +3,7 @@ const router = express.Router();
const { User } = require('../models/user');
const { Nave } = require('../models/nave');
const { Flotta } = require('../models/flotta');
const { NavePersistente } = require('../models/navepersistente');
const { ListaIngresso } = require('../models/listaingresso');
const { Graduatoria } = require('../models/graduatoria');
@@ -135,7 +136,10 @@ 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.link_payment = recorig.profile.link_payment;
user.profile.note_payment = recorig.profile.note_payment;
user.profile.paymenttypes = recorig.profile.paymenttypes;
user.profile.qualified = recorig.profile.qualified;
let msgseconda = '!!! REGISTRATA ';
if (numero === '2')
msgseconda += 'SECONDA';
@@ -312,6 +316,13 @@ router.post('/login', (req, res) => {
tools.mylogshow(msg);
// telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
res.status(404).send({ code: server_constants.RIS_CODE_LOGIN_ERR });
} else if (!!user.subaccount && user.subaccount) {
await tools.snooze(1000);
// const msg = "Tentativo di Login ERRATO [" + body.username + ' , ' + body.password + ']\n' + '[IP: ' + tools.getiPAddressUser(req) + ']';
// tools.mylogshow(msg);
// telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
res.status(404).send({ code: server_constants.RIS_CODE_LOGIN_ERR_SUBACCOUNT });
return null;
}
return user
})
@@ -364,7 +375,7 @@ router.post('/login', (req, res) => {
}
})
.catch((e) => {
tools.mylog("ERRORE IN LOGIN: " + e);
tools.mylog("ERRORE IN LOGIN: " + e.message);
if (!resalreadysent)
res.status(400).send({ code: server_constants.RIS_CODE_LOGIN_ERR_GENERIC });
});
@@ -411,16 +422,7 @@ async function eseguiDbOp(idapp, mydata, locale) {
try {
if (mydata.dbop === 'rigeneraTutto') {
mydata.dbop = 'delNaviProvvisorie';
await eseguiDbOp(idapp, mydata, locale);
mydata.dbop = 'GeneraGraduatoria';
await eseguiDbOp(idapp, mydata, locale);
mydata.dbop = 'creaNavi';
ris = await eseguiDbOp(idapp, mydata, locale);
await ListaIngresso.Esegui_CronTab(idapp, mydata);
} else if (mydata.dbop === 'creaNavi') {
const num = await Nave.generaNave(idapp, mydata, false);
ris = { num };
@@ -439,36 +441,8 @@ async function eseguiDbOp(idapp, mydata, locale) {
// ris = { num };
} else if (mydata.dbop === 'delNaviProvvisorie') {
let num = 0;
ris = await Nave.delNaviProvvisorie(idapp);
const arrnavi = await Nave.find({ idapp });
for (const nave of arrnavi) {
let persistente = await NavePersistente.findByRigaColByDonatore(idapp, nave.riga, nave.col, 0);
if (!!persistente) {
if (persistente.provvisoria) {
let ris = await Nave.deleteOne({ _id: nave._id });
if (!!ris) {
num++;
}
}
}
}
// Pulisci gli added se era stato cancellato dalla nave
await Nave.pulisciNonPresenzeInNave(idapp);
const data = await Nave.getLastRigaCol(idapp);
await Nave.setRiga(idapp, data.riga);
await Nave.setCol(idapp, data.col + 1);
const maxcol = tools.getmaxcol(data.riga);
if (data.col === maxcol) {
await Nave.setRiga(idapp, data.riga + 1);
await Nave.setCol(idapp, 1);
}
ris = { num };
} else if (mydata.dbop === 'visuListaNave') {
mystr = await Nave.showListaOrd(idapp);
ris = { mystr };
@@ -494,6 +468,14 @@ async function eseguiDbOp(idapp, mydata, locale) {
ris = { mystr };
} else if (mydata.dbop === 'visuNaviUtentiEliminati') {
ris = await Nave.visuNaviUtentiEliminati(idapp);
} else if (mydata.dbop === 'convSubAccount') {
ris = await User.convSubAccount(idapp);
} else if (mydata.dbop === 'flagUtentiNaviNonPresenti') {
ris = await User.flagUtentiNaviNonPresenti(idapp);
} else if (mydata.dbop === 'generaFlotte') {
ris = await NavePersistente.generaFlotte(idapp);
} else if (mydata.dbop === 'addNavePerUtentiNaviNonPresenti') {
ris = await User.addNavePerUtentiNaviNonPresenti(idapp);
} else if (mydata.dbop === 'creaTessituraeConv') {
ris = await ListaIngresso.creaTessituraeConv(idapp);
ris = { mystr };
@@ -506,6 +488,7 @@ async function eseguiDbOp(idapp, mydata, locale) {
} else if (mydata.dbop === 'convNaviTessinListaIngressoRec') {
let num = 0;
const arrnavitess = await Nave.find({ idapp, num_tess: { $gte: 3 } });
for (const recnave of arrnavitess) {
@@ -699,7 +682,7 @@ async function eseguiDbOp(idapp, mydata, locale) {
} else if (mydata.dbop === 'visuPlacca') {
mystr = '✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨\n' +
'ECCO LE NUOVE NAVI DEFINITIVE CHE APRONO DOMANI LA GIFT CHAT !!! DALLA ' + mydata.riga + '.' + mydata.col + ' ALLA ' + mydata.riga + '.' + (parseInt(mydata.col) + 7) + '\n' +
'NAVI CHE SALPANO DALLA ' + mydata.riga + '.' + mydata.col + ' ALLA ' + mydata.riga + '.' + (parseInt(mydata.col) + 7) + '\n' +
'AUGURI ALLA NUOVA SOGNATRICE !!!\n' +
'✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨';

View File

@@ -306,6 +306,33 @@ module.exports = {
// Send Email also to the Admin
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
},
sendEmail_ByText: async function (lang, emailto, user, idapp, rec) {
tools.mylog('sendEmail_ByText');
mylocalsconf = {
idapp,
dataemail: await this.getdataemail(idapp),
locale: lang,
nomeapp: tools.getNomeAppByIdApp(idapp),
name: user.name,
surname: user.surname,
usernameorig: user.name + ' ' + user.surname,
emailto: emailto,
};
mylocalsconf.dataemail.emailbody = rec.emailbody;
mylocalsconf.dataemail.emailtitle = rec.emailtitle;
const replyto = tools.getreplyToEmailByIdApp(idapp);
return this.sendEmail_base('standard', emailto, mylocalsconf, replyto);
// Send Email also to the Admin
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
},
Add_to_MailingList_AndSendEmailNotify: async function (lang, user, idapp, sendnews) {
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));

View File

@@ -62,6 +62,9 @@ const users_router = require('./router/users_router');
const site_router = require('./router/site_router');
const admin_router = require('./router/admin_router');
const { ListaIngresso } = require('./models/listaingresso');
const { MyEvent } = require('./models/myevent');
const telegrambot = require('./telegram/telegrambot');
@@ -256,10 +259,12 @@ function mycron() {
async function mycron_30min() {
for (const app of MYAPPS) {
const enablecrontab = await Settings.getValDbSettings(app.idapp, tools.ENABLE_CRONTAB, false);
let enablecrontab = false;
enablecrontab = await Settings.getValDbSettings(app.idapp, tools.ENABLE_CRONTAB, false);
if (enablecrontab) {
ListaIngresso.Esegui_CronTab(app.idapp);
ListaIngresso.Esegui_CronTab(app.idapp, {});
}
}
}
@@ -293,12 +298,18 @@ cron.schedule('*/2 * * * *', () => {
mycron();
});
// Cron every X minutes
cron.schedule('*/30 * * * *', async () => {
cron.schedule('*/60 * * * *', async () => {
mycron_30min();
});
// mycron_30min();
// tools.writelogfile('test', 'prova.txt');
async function resetProcessingJob() {
arrrec = await Newstosent.find({});

View File

@@ -12,10 +12,16 @@ const { CalZoom } = require('../models/calzoom');
const { Nave } = require('../models/nave');
const shared_consts = require('../tools/shared_nodejs');
const { ListaIngresso } = require('../models/listaingresso');
const { MsgTemplate } = require('../models/msg_template');
const emoji = require('node-emoji');
const i18n = require("i18n");
let url = process.env.URL || 'https://<PUBLIC-URL>';
const Benvenuto = emoji.get('heartbeat') + emoji.get('heartbeat') + emoji.get('heartbeat') + ' Benvenuto!';
const emo = {
@@ -151,8 +157,10 @@ const Menu = {
MSG_TO_NAVE: emoji.get('incoming_envelope') + 'Msg_to_Navi',
MSG_NO_7_REQ: emoji.get('incoming_envelope') + 'No 7 Req.',
MSG_NO_9_REQ: emoji.get('incoming_envelope') + 'No 9 Req',
NESSUN_IMBARCO_7REQ: emoji.get('incoming_envelope') + 'No Imbarco (7 Req)',
MSG_SI_INVITATI_NO_7REQ_INVITATI: emoji.get('incoming_envelope') + 'Inv e NO 7 Req',
MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
MSGPAOLO: emoji.get('incoming_envelope') + ' Invia a PAOLO',
MSGATUTTI: emoji.get('incoming_envelope') + ' Invia a TUTTI',
it: {
ACCEDI: emo.PERSON + ' Accedi',
@@ -231,8 +239,15 @@ const Menu = {
const CONTA_SOLO = 'contasolo';
const RICEVI_EMAIL = 'riceviemail';
const NOME_COGNOME = 'nomecognome';
const CHEDI_SE_IMBARCARTI = 'chiedi_se_imbarcarti';
const SendMsgCmd = [CONTA_SOLO, RICEVI_EMAIL];
const InlineCmd = {
VOGLIO_IMBARCARMI: 'voglio_imbarcarmi',
NON_VOGLIO_IMBARCARMI: 'non_voglio_imbarcarmi'
};
const SendMsgCmd = [CONTA_SOLO, RICEVI_EMAIL, NOME_COGNOME, CHEDI_SE_IMBARCARTI];
const MenuNoLogin = {
@@ -276,11 +291,11 @@ const MenuYesNo = {
};
const MenuAdmin = {
it: { menu: [[Menu.MSGSTAFF, Menu.MSGATUTTI, Menu.it.INDIETRO], [Menu.MSG_NO_7_REQ, Menu.MSG_NO_9_REQ], [Menu.MSG_TO_NAVE, Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI]] },
it: { menu: [[Menu.MSGSTAFF, Menu.MSGATUTTI, Menu.it.INDIETRO], [Menu.MSG_NO_7_REQ, Menu.MSG_NO_9_REQ, Menu.NESSUN_IMBARCO_7REQ], [Menu.MSGPAOLO, Menu.MSG_TO_NAVE, Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI]] },
};
const MenuSend = {
it: { menu: [[CONTA_SOLO, RICEVI_EMAIL], [Menu.it.INDIETRO]] },
it: { menu: [[CONTA_SOLO, RICEVI_EMAIL, NOME_COGNOME], [CHEDI_SE_IMBARCARTI, Menu.it.INDIETRO]] },
};
const MenuChat = {
@@ -298,6 +313,7 @@ const Sex = {
};
const Status = {
EXIT: -5,
NONE: 0,
VERIFIED: 1,
WAITFOR_USERNAME_BO: 102,
@@ -313,6 +329,8 @@ const Destin = {
SI_INVITATI_NO_7REQ_INVITATI: 5,
A_UTENTE: 6,
MSG_TO_NAVE: 7,
NESSUN_IMBARCO_7REQ: 8,
PAOLO: 9,
};
const StatusMSGALL = {
@@ -446,7 +464,7 @@ const TelegramBot = require('node-telegram-bot-api');
module.exports = {
ADMIN_IDTELEGRAM_SERVER: '12429864',
ADMIN_IDTELEGRAM_SERVER: '12429864', //Paolo
ADMIN_USER_SERVER: 'paoloar77',
ADMIN_USER_NAME_SERVER: 'Paolo',
@@ -509,69 +527,201 @@ module.exports = {
},
getMsgByTipoMsg: function (mydata, lang, user, sonosognatore) {
getMsgByTipoMsg: async function (mydata, lang, user, sonosognatore) {
if (!!mydata.msgextra) {
return mydata.msgextra;
return { body: mydata.msgextra, title: ''} ;
}
let title = '';
let msg = '';
if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) {
if (sonosognatore)
return printf(tools.gettranslate('SEND_LINK_CHAT_SOGNATORE', lang), user.name, mydata.navemediatore.riga + '.' + mydata.navemediatore.col, mydata.msgpar1);
msg = printf(tools.gettranslate('SEND_LINK_CHAT_SOGNATORE', lang), user.name, mydata.navemediatore.riga + '.' + mydata.navemediatore.col, mydata.msgpar1);
else
return printf(tools.gettranslate('SEND_LINK_CHAT_DONATORI', lang), user.name, mydata.navemediatore.riga + '.' + mydata.navemediatore.col, mydata.msgpar1);
msg = printf(tools.gettranslate('SEND_LINK_CHAT_DONATORI', lang), user.name, mydata.navemediatore.riga + '.' + mydata.navemediatore.col, mydata.msgpar1);
} else if (mydata.tipomsg === tools.TipoMsg.SEND_MSG || mydata.tipomsg === tools.TipoMsg.SEND_MSG_SINGOLO) {
let mymsg = '';
if (!!mydata.username_mitt) {
mymsg = '[' + tools.gettranslate('MSG_SEND_FROM', lang) + ' ' + mydata.username_mitt + ']:' + tools.ACAPO;
msg = '[' + tools.gettranslate('MSG_SEND_FROM', lang) + ' ' + mydata.username_mitt + ']:' + tools.ACAPO;
}
mymsg += mydata.msgpar1;
return mymsg;
msg += mydata.msgpar1;
} else if (mydata.tipomsg >= 1000) {
const ris = await MsgTemplate.getMsgByLang(user.idapp, mydata.tipomsg, lang);
msg = ris.body;
title = ris.title;
}
if (!!user) {
msg = msg.replace('{username}', user.username);
msg = msg.replace('{name}', user.name);
msg = msg.replace('{surname}', user.surname);
if (!!user.profile.link_payment)
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
if (!!user.profile.email_paypal)
msg = msg.replace('{email_paypal}', user.profile.email_paypal);
if (!!user.profile.note_payment)
msg = msg.replace('{note_payment}', user.profile.note_payment);
}
if (!!mydata.flotta) {
// SOSTITUISCI LE PAROLE CHIAVI
if (!!mydata.flotta.date_start)
msg = msg.replace('{date_start}', tools.getstrDateLong(new Date(mydata.flotta.date_start), user.lang));
if (!!mydata.flotta.date_close)
msg = msg.replace('{date_close}', tools.getstrDateLong(new Date(mydata.flotta.date_close), user.lang));
if (!!mydata.flotta.link_superchat)
msg = msg.replace('{link_superchat}', mydata.flotta.link_superchat);
if (!!mydata.flotta.tutor1)
msg = msg.replace('{tutor1}', mydata.flotta.tutor1);
if (!!mydata.flotta.tutor2)
msg = msg.replace('{tutor2}', mydata.flotta.tutor2);
if (!!mydata.flotta.tutor3)
msg = msg.replace('{tutor3}', mydata.flotta.tutor3);
if (!!mydata.flotta.tutorslo)
msg = msg.replace('{tutorslo}', mydata.flotta.tutorslo);
if (!!mydata.flotta.sognatore_nomecognome)
msg = msg.replace('{sognatore}', mydata.flotta.sognatore_nomecognome);
}
return { body: msg, title };
},
sendMsgTelegramToNave: async function (idapp, mydata) {
let nummsgtosend = 0;
let nummsgsent = 0;
let strout = '';
let flotta = mydata.flotta;
const sendemail = require('../sendemail');
try {
const arrnavi = await Nave.getusersByNave(idapp, mydata.navemediatore);
let arrnavi = null;
if (flotta) {
arrnavi = await Nave.getusersByFlotta(idapp, flotta.riga, flotta.col_prima, flotta.col_ultima);
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_A_SOGNATORE) {
arrnavi = await User.find({ idapp, username: flotta.sognatore });
}
} else {
arrnavi = await Nave.getusersByNave(idapp, mydata.navemediatore);
}
// console.log('usersmanagers', usersmanagers);
let mymsg = "";
let mymsgprimo = "";
tipomsgorig = mydata.tipomsg;
if (arrnavi) {
if (!flotta)
tools.writeManagersLog('sendMsgTelegramToNave', mydata.navemediatore.riga + '.' + mydata.navemediatore.col);
let index = 1;
if (mydata.inviareale) {
let mystrmsg = tools.getStrMsgByTipoMsg(tipomsgorig);
if (!!mystrmsg) {
tools.writeFlottaLog(idapp, mystrmsg, flotta.riga, flotta.col_prima);
}
}
for (const nave of arrnavi) {
const user = await User.findByIndOrder(idapp, nave.ind_order);
mydata.tipomsg = tipomsgorig;
let user = null;
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_A_SOGNATORE) {
user = nave;
} else {
user = await User.findByIndOrder(idapp, nave.ind_order);
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_SOLLECITO_DONATORI_NO_DONO) {
// Solo a quelli che non hanno fatto il dono
if (nave.made_gift)
user = null;
}
if ((nave.num_tess % 2) === 0) {
// MEDIATORE !
// Se l'ultimo Donatore è un Mediatore, allora NON GLI MANDO IL MESSAGGIO !
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_EFFETTUA_IL_DONO) {
user = null;
}
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_SOLLECITO_DONATORI_NO_DONO) {
user = null;
}
} else {
// DONATORE
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_A_MEDIATORI) {
user = null; // Se sto mandando msg a Mediatore, allora questo no!
}
}
}
//mydata.tipomsg = tools.TipoMsg.SEND_MSG_A_MEDIATORI;
if (!!user) {
const lang = user.lang;
const idteleg = user.profile.teleg_id;
const mymsg = this.getMsgByTipoMsg(mydata, lang, user, false);
mydata.nave = nave;
const rismsg = await this.getMsgByTipoMsg(mydata, lang, user, false);
mymsg = rismsg.body;
mytitle = rismsg.title;
if (mymsgprimo === '') {
mymsgprimo = mymsg;
}
if (!!idteleg) {
strout += '\n' + user.name + ' ' + user.surname + ':';
strout += '\n (' + index + ') ' + user.name + ' ' + user.surname + ':';
if (mydata.inviareale) {
await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg, undefined, undefined, true);
await tools.snooze(300);
strout += ' -> MSG INVIATO';
} else {
strout += ' (Pronto da Inviare)';
strout += ' -> (MSG OK)';
if (mydata.inviaemail && !!user.email) {
// user.email = 'paolo.arena77@gmail.com';
await sendemail.sendEmail_ByText(user.lang, user.email, user, idapp, {emailbody: mymsg, emailtitle: mytitle});
strout += ' -> (EMAIL OK)';
}
nummsgsent++;
} else {
strout += ' (Ok)';
nummsgtosend++;
}
if ((nummsgsent === 1) && (mydata.inviareale)) {
}
}
index++;
}
}
if (!mydata.inviareale) {
await this.sendMsgTelegramToTheManagers(idapp, 'TEST INVIO MESSAGGIO:\n' + mymsgprimo + '\n\n(Messaggi da Inviare: ' + nummsgtosend + ')');
}
if ((nummsgsent > 1) && (mydata.inviareale)) {
try {
await this.sendMsgTelegramToTheManagers(idapp, 'Inviato messaggio a tutti i Donatori della Nave ' + mydata.navemediatore.riga + '.' + mydata.navemediatore.col + '\n' + mymsg)
let msg = '';
if (!!flotta) {
msg = 'Inviato messaggio a tutta la FLOTTA DA ' + flotta.riga + '.' + flotta.col_prima + ' A ' + flotta.riga + '.' + flotta.col_ultima + ' \n' + mymsg;
} else {
msg = 'Inviato messaggio a tutti i Donatori della Nave ' + mydata.navemediatore.riga + '.' + mydata.navemediatore.col + '\n' + mymsg;
}
await this.sendMsgTelegramToTheManagers(idapp, msg)
} catch (e) {
}
}
}
}
/*
if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) {
const usersognatore = await Nave.getSognatoreByRigaColMediatore(idapp, mydata.navemediatore);
console.log('Sognatore: ', usersognatore.username);
@@ -594,6 +744,7 @@ module.exports = {
}
}
*/
if (nummsgsent > 0) {
if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) {
@@ -604,10 +755,11 @@ module.exports = {
}
}
}
return { nummsgsent, strout };
} catch (e) {
console.error(e.message);
strout = 'Error: ' + e.message + '\n' + strout;
return { nummsgsent, strout };
}
},
@@ -1137,10 +1289,14 @@ class Telegram {
await this.menumsgAll(msg)
} else if (msg.text === Menu.MSGSTAFF) {
await this.menumsgStaff(msg)
} else if (msg.text === Menu.MSGPAOLO) {
await this.menumsgPaolo(msg)
} else if (msg.text === Menu.MSG_NO_7_REQ) {
await this.menumsg_No_7_Req(msg)
} else if (msg.text === Menu.MSG_NO_9_REQ) {
await this.menumsg_No_9_Req(msg)
} else if (msg.text === Menu.NESSUN_IMBARCO_7REQ) {
await this.menumsgGenerico(msg, Destin.NESSUN_IMBARCO_7REQ);
} else if (cmd1 === Menu.MSG_TO_NAVE) {
await this.menumsg_to_Nave(msg, cmd2)
} else if (msg.text === Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI) {
@@ -1460,6 +1616,8 @@ class Telegram {
return 'TUTTI';
else if (destin === Destin.STAFF)
return 'STAFF';
else if (destin === Destin.PAOLO)
return 'PAOLO';
else if (destin === Destin.NO_7_REQ)
return 'No 7 Requisiti';
else if (destin === Destin.NO_9_REQ)
@@ -1468,6 +1626,8 @@ class Telegram {
return '2 Invitati ma NO Requisiti';
else if (destin === Destin.MSG_TO_NAVE)
return 'Nave ' + rec.extraparam;
else if (destin === Destin.NESSUN_IMBARCO_7REQ)
return 'No Imbarcati (7 Req) ';
else if (destin === Destin.A_UTENTE) {
const rec = this.getRecInMem(msg);
return rec.msgall_username_specifico
@@ -1483,6 +1643,10 @@ class Telegram {
await this.menumsgGenerico(msg, Destin.STAFF);
}
async menumsgPaolo(msg) {
await this.menumsgGenerico(msg, Destin.PAOLO);
}
async menumsg_No_7_Req(msg) {
await this.menumsgGenerico(msg, Destin.NO_7_REQ);
}
@@ -1592,7 +1756,7 @@ class Telegram {
}
getRecInMem(msg) {
return this.arrUsers.find((rec) => rec.id === msg.from.id);
return this.arrUsers.find((rec) => rec.id === this.getchatid(msg));
}
getRecInMemById(id) {
@@ -1608,7 +1772,7 @@ class Telegram {
}
deleteRecInMem(msg) {
this.arrUsers = this.arrUsers.filter((rec) => rec.id !== msg.from.id);
this.arrUsers = this.arrUsers.filter((rec) => rec.id !== this.getchatid(msg));
}
async getUser(msg, rec, conmsg) {
@@ -1776,7 +1940,15 @@ class Telegram {
tools.writeEventsLog(this.getDestinStr(msg, destin, rec) + ':\n' + texttosend);
// let chiedisino = false;
// TEST usersall = await User.getUsersTelegALL(rec.user.idapp, 'paoloar77');
for (const utente of usersall) {
let FormDaMostrare = null;
const lang = utente.lang;
if (!utente.deleted && !utente.sospeso) {
if (this.isSelMenu(msg, texttosend === 'LAVAGNA')) {
textdainviare = await this.getLavagnaByUser(utente, msg);
@@ -1791,12 +1963,16 @@ class Telegram {
invia = User.isManager(utente.perm);
} else if (destin === Destin.TUTTI) {
invia = true;
} else if (destin === Destin.PAOLO) {
invia = utente.username === 'paoloar77';
} 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.NESSUN_IMBARCO_7REQ) {
invia = await User.NessunaNavePresenteByUsername(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) {
@@ -1804,21 +1980,56 @@ class Telegram {
const numinvitatiattivi = await ListaIngresso.getnumInvitatiAttivi(this.idapp, utente.username);
invia = (numinvitati >= 2) && (numinvitatiattivi < 2);
}
// TEST invia = true;
if (invia) {
let inviaveramente = false;
if (cmd === RICEVI_EMAIL) {
preparatesto += utente.email + ', ';
} else if (cmd === NOME_COGNOME) {
preparatesto += utente.name + ' ' + utente.surname + '(' + utente.username + ')' + '\n';
} else if (cmd === CONTA_SOLO) {
// Niente
} else if (cmd === CHEDI_SE_IMBARCARTI) {
textdainviare = tools.gettranslate('VUOI_IMBARCARTI', lang);
// chiedisino = true;
// rec.msgall_status = StatusMSGALL.CONFIRM;
FormDaMostrare = this.getInlineKeyboard(lang, [
{ text: Menu[lang].SI, callback_data: InlineCmd.VOGLIO_IMBARCARMI },
{ text: Menu[lang].NO, callback_data: InlineCmd.NON_VOGLIO_IMBARCARMI },
]);
inviaveramente = true;
} else {
inviaveramente = true;
}
if (inviaveramente) {
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)
// if (chiedisino) {
// this.ChiediSINO(msg, textdainviare);
// } else {
// TEST
let telegid = utente.profile.teleg_id;
// if (process.env.PROD === "0") {
// telegid = 12429864;
// }
await this.sendMsg(telegid, textdainviare, null, FormDaMostrare);
// break;
}
await tools.snooze(300);
nummsgsent++;
}
if (!SendMsgCmd.includes(cmd)) {
if ((nummsgsent % 50) === 0) {
@@ -1834,6 +2045,10 @@ class Telegram {
let msgris = "";
if (cmd === CONTA_SOLO) {
msgris = nummsgsent + ' ' + getstr(this.getlang(msg), 'MSG_MSG_TOSENT');
} else if (cmd === NOME_COGNOME) {
msgris = nummsgsent + ' ' + 'Utenti';
await this.sendMsg(msg.chat.id, msgris);
msgris = preparatesto;
} else if (cmd === RICEVI_EMAIL) {
msgris = nummsgsent + ' ' + 'Email';
await this.sendMsg(msg.chat.id, msgris);
@@ -1870,17 +2085,28 @@ class Telegram {
|| (msg.text === Menu.LANG_FR) || (msg.text === Menu.LANG_SI) || (msg.text === Menu.LANG_PT))
}
async receiveMsg(msg) {
async setInit(msg) {
let status = this.getstatusInMemory(msg);
if (status === Status.NONE) {
await this.start(msg);
let status = this.getstatusInMemory(msg);
if (status !== Status.VERIFIED)
return
return Status.EXIT;
} else {
await this.setUser(msg)
}
return status;
}
async receiveMsg(msg) {
let status = await this.setInit(msg);
if (status === Status.EXIT) {
return
}
const rec = this.getRecInMem(msg);
status = this.getstatus(rec);
@@ -1912,6 +2138,8 @@ class Telegram {
domanda = 'Confermi di vedere a quante persone arriverebbe questo messaggio, a ' + achi + ' ?\n' + rec.msgtosent;
else if (cmd === RICEVI_EMAIL)
domanda = 'Confermi di vedere la lista delle email di ' + achi + '?';
else if (cmd === NOME_COGNOME)
domanda = 'Confermi di vedere la lista di persone ' + achi + '?';
else {
if (rec.msgall_achi === Destin.A_UTENTE)
domanda = 'Confermi d\'Iniziare una Chat messaggi con ' + achi + ' ?\n' + rec.msgtosent;
@@ -1940,7 +2168,8 @@ class Telegram {
async askVerifiedCode(msg) {
const rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
const rec = this.getRecInMem(msg);
if (!rec) {
await this.addUser(msg);
@@ -1954,9 +2183,10 @@ class Telegram {
}
async setUser(msg) {
const id = msg.from.id;
let id = this.getchatid(msg);
const user = await User.UserByIdTelegram(this.idapp, id);
let rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
let rec = this.getRecInMem(msg);
if (user && rec) {
rec.user = user;
}
@@ -1971,12 +2201,19 @@ class Telegram {
}
getchatid(msg) {
if (msg.from.is_bot)
return msg.chat.id;
else
return msg.from.id;
}
async alreadyExist(msg) {
const id = msg.from.id;
const id = this.getchatid(msg);
let rec = null;
try {
const user = await User.UserByIdTelegram(this.idapp, id);
let rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
let rec = this.getRecInMem(msg);
if (user && !rec) {
rec = this.addUser(msg);
}
@@ -1998,7 +2235,7 @@ class Telegram {
const code = 100000 + Math.round(Math.random() * 899999);
const rec = {
id: msg.from.id,
id: this.getchatid(msg),
code,
lang,
status: Status.WAITFOR_USERNAME_BO,
@@ -2060,7 +2297,7 @@ class Telegram {
}
async _inviaMsg(id, text, form, menu, msg_id, chat_id, ripr_menuPrec) {
async _inviaMsg(id, text, form, menu, msg_id, chat_id, ripr_menuPrec, opt) {
if (!text)
return 0;
@@ -2095,6 +2332,12 @@ class Telegram {
}
try {
text = text.replace(/<br>/g, "\n");
text = text.replace(/<div>/g, "");
text = text.replace(/<\/div>/g, "\n");
text = text.replace(/&nbsp;/g, " ");
if (!form) {
form = {
"parse_mode": "HTML",
@@ -2169,6 +2412,48 @@ class Telegram {
return mymenuout;
}
getInlineKeyboard(lang, arrrisp1, arrrisp2, arrrisp3) {
let mykeyb = {
parse_mode: 'HTML',
reply_markup: {
inline_keyboard: []
}
};
// text
// callback_data
// url
const arrriga1 = [];
if (!!arrrisp1) {
for (const ris of arrrisp1) {
arrriga1.push(ris);
}
}
const arrriga2 = [];
if (!!arrrisp2) {
for (const ris of arrrisp2) {
arrriga2.push(ris);
}
}
const arrriga3 = [];
if (!!arrrisp3) {
for (const ris of arrrisp3) {
arrriga3.push(ris);
}
}
if (arrriga1.length > 0)
mykeyb.reply_markup.inline_keyboard.push(arrriga1);
if (arrriga2.length > 0)
mykeyb.reply_markup.inline_keyboard.push(arrriga2);
if (arrriga3.length > 0)
mykeyb.reply_markup.inline_keyboard.push(arrriga3);
return mykeyb;
}
async ChiediSINO(msg, domanda) {
const lang = this.getlang(msg);
@@ -2246,6 +2531,15 @@ if (!tools.testing()) {
if (!!token) {
const bot = new TelegramBot(token, { polling: true });
if (url === '0') {
const ngrok = require('ngrok');
ngrok.connect(port, function onConnect(error, u) {
if (error) throw error;
url = u;
console.log(`Game tunneled at ${url}`);
});
}
arrTelegram.push({ idapp, cl: new Telegram(idapp, bot) });
bot.onText(/\/start/, (msg) => {
@@ -2290,10 +2584,52 @@ if (!tools.testing()) {
});
// Handle callback queries
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
console.log('callback_query', callbackQuery);
bot.on('callback_query', async (callbackQuery) => {
// console.log('callback_query', callbackQuery);
bot.answerCallbackQuery(callbackQuery.id, { url });
const myclTelegram = getclTelegBytoken(bot.token);
const action = callbackQuery.data;
const msg = callbackQuery.message;
const opts = {
chat_id: msg.chat.id,
message_id: msg.message_id,
};
const status = await myclTelegram.setInit(msg);
const rec = myclTelegram.getRecInMem(msg);
if (!!rec) {
if (!!rec.user) {
if (action === InlineCmd.VOGLIO_IMBARCARMI) {
// Controlla se è qualificato!
const mydata = tools.AddDate(rec.user.date_reg, 7);
const newrecingr = await ListaIngresso.addUserInListaIngresso(rec.user.idapp, rec.user.username, rec.user.aportador_solidario, rec.user.lang, true, true, mydata);
bot.editMessageText(tools.gettranslate('ADDED_TOLISTAINGRESSO', rec.user.lang), opts);
} else if (action === InlineCmd.NON_VOGLIO_IMBARCARMI) {
await User.NonVoglioImbarcarmi(rec.user.idapp, rec.user.username);
const msgadd = '[' + rec.user.username + '] ' + rec.user.name + ' ' + rec.user.surname + ' ha risposto che NON VUOLE IMBARCARSI !';
await local_sendMsgTelegramToTheManagers(rec.user.idapp, msgadd, msg, false); // Anche a STAFF
}
}
}
/*
let text;
if (action === 'edit') {
text = 'Edited Text';
}
bot.editMessageText(text, opts);
*/
// bot.answerCallbackQuery(callbackQuery.id, { url });
});
}

View File

@@ -25,6 +25,7 @@ const webpush = require('web-push');
const FILELOG = 'filelog.txt';
const FILEEVENTS = 'logevents.txt';
const FILEMANAGERS = 'logmanagers.txt';
const FILESOSTITUZIONI = 'log_sostituzioni.txt';
const FILENAVE = 'logNave.txt';
const subject = process.env.URLBASE_APP1;
const publicVapidKey = process.env.PUBLIC_VAPI_KEY;
@@ -114,6 +115,7 @@ textlang = {
'TEMPORANEA': 'TEMPORANEA',
'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>? ',
},
si: {
"Email je že bila preverjena": "Email je že bila preverjenaL'Email è già stata Verificata",
@@ -181,6 +183,7 @@ textlang = {
'TEMPORANEA': 'ZAČASNA',
'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>?',
},
es: {
"L'Email è già stata Verificata": "El correo electrónico ya ha sido verificado",
@@ -246,6 +249,7 @@ textlang = {
'TEMPORANEA': 'TEMPORAL',
'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?',
},
enUs: {
"partecipanti": "participants",
@@ -308,6 +312,7 @@ textlang = {
'TEMPORANEA': 'TEMPORARY',
'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>?',
},
fr: {
"L'Email è già stata Verificata": "Le courrier électronique a déjà été vérifié",
@@ -374,6 +379,7 @@ textlang = {
'TEMPORANEA': 'TEMPORAIRE',
'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> ? ',
},
pt: {
"L'Email è già stata Verificata": "",
@@ -440,6 +446,7 @@ textlang = {
'TEMPORANEA': 'TEMPORÁRIO',
'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>?',
},
};
@@ -449,6 +456,7 @@ module.exports = {
ACAPO: '\n',
ENABLE_CRONTAB: 'CRONTAB',
UPDATE_GRADUATORIA: 'UPDATE_GRAD',
LANGADMIN: 'it',
@@ -465,6 +473,12 @@ module.exports = {
SEND_MSG: 2,
SEND_MSG_SINGOLO: 3,
SEND_TO_ALL: 10,
SEND_MSG_EFFETTUA_IL_DONO: 1000,
SEND_MSG_SOLLECITO_DONATORI_NO_DONO: 1005,
SEND_MSG_A_MEDIATORI: 1010,
SEND_MSG_A_SOGNATORE: 1020,
SEND_MSG_A_UTENTE_SOSTITUITO: 1030,
SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE: 1040,
},
Placca: {
@@ -982,6 +996,8 @@ module.exports = {
'note': { $exists: true },
"$expr": { "$gt": [{ "$strLenCP": "$note" }, 1] }
});
if (params.filterand.includes(shared_consts.FILTER_QUALIFIED))
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_USER_NO_INVITANTE))
@@ -1010,6 +1026,11 @@ module.exports = {
filtriadded.push({
deleted: { $exists: true, $eq: true }
});
if (params.filterand.includes(shared_consts.FILTER_NAVI_NON_PRESENTI))
filtriadded.push({
navinonpresenti: { $exists: true, $eq: true },
$or: [{ subaccount: { $exists: false } }, { subaccount: { $exists: true, $eq: false } }]
});
}
@@ -1210,7 +1231,7 @@ module.exports = {
numup
};
if (idapp === tools.AYNI) {
if (idapp === this.AYNI) {
this.getRigaColByPosUp(mypos);
ris = this.getlimiti(mypos);
}
@@ -1294,6 +1315,15 @@ module.exports = {
}
},
getstrDateLongFile(mydate, lang) {
if (mydate) {
// console.log('getstrDate', mytimestamp)
return mydate.getFullYear() + '-' + this.appendLeadingZeroes(mydate.getMonth() + 1) + '-' + this.appendLeadingZeroes(mydate.getDate()) + ' (' + this.getWeekDayByLang(mydate, lang) + ')'
} else {
return '';
}
},
getlinkzoom(idconf) {
if (idconf === '')
idconf = '6668882000';
@@ -1378,12 +1408,22 @@ module.exports = {
// console.log('Saved!');
// });
// mystr = this.getstrDateTimeShort(Date.now()) + ' ' + mystr;
mystr = this.getstrDateTimeShort(new Date(), 'it') + ': ' + mystr;
const stream = fs.createWriteStream(filename, { flags: 'a' });
stream.write('\n' + mystr);
stream.end();
},
readlogfile(idapp, filename) {
try{
return fs.readFileSync(idapp + '/' + filename, 'utf8');
}catch (e) {
return '';
}
},
writelog(mystr) {
this.writelogfile(mystr, FILELOG);
},
@@ -1396,6 +1436,20 @@ module.exports = {
this.writelogfile(mystr, FILEMANAGERS);
},
writeSostituzioniLog(mystr) {
this.writelogfile(mystr, FILESOSTITUZIONI);
},
writeFlottaLog(idapp, mystr, riga, col) {
this.mkdirpath(idapp + '/');
this.writelogfile(mystr, idapp + '/' + riga + '_' + col + '.txt');
},
readFlottaLog(idapp, riga, col) {
const nomefile = riga + '_' + col + '.txt';
return this.readlogfile(idapp, nomefile);
},
writeNaveLog(mystr) {
this.writelogfile(mystr, FILENAVE);
},
@@ -1523,6 +1577,9 @@ module.exports = {
if ('username' in fieldsvalue) {
return true;
}
if ('note' in fieldsvalue) {
return true;
}
}
if (table === 'navi') {
@@ -1541,12 +1598,15 @@ module.exports = {
return true;
}
}
if (table === 'flotte') {
return true;
}
return false;
},
NotifyIfDelRecord(table) {
if ((table === 'users') || (table === 'extralist') || (table === 'listaingressos')) {
if ((table === 'users') || (table === 'extralist') || (table === 'listaingressos') || (table === 'graduatorias')) {
return true;
}
@@ -1572,5 +1632,41 @@ module.exports = {
return Math.pow(2, riga - 1);
},
getPrimoFuocoByIndCol(col) {
// let ris = Math.ceil(col - (col % 8)) + 1;
let ris = ((Math.ceil(col / 8) - 1) * 8) + 1;
if (ris <= 0)
ris = 1;
return ris
},
getPrimaColFlotta(col) {
// let ris = Math.ceil(col - (col % 8)) + 1;
let ris = ((Math.ceil(col / 64) - 1) * 64) + 1;
if (ris <= 0)
ris = 1;
return ris
},
getStrMsgByTipoMsg(tipomsg) {
let mystr = '';
if (tipomsg === this.TipoMsg.SEND_MSG_EFFETTUA_IL_DONO)
mystr = 'Inviato Messaggio per Effettuare il Dono a Tutta la Flotta';
else if (tipomsg === this.TipoMsg.SEND_MSG_SOLLECITO_DONATORI_NO_DONO)
mystr = 'Inviato Messaggio per RICORDARE di Effettuare il Dono a chi ancora non l\'ha fatto';
else if (tipomsg === this.TipoMsg.SEND_MSG_A_MEDIATORI)
mystr = 'Inviato Messaggio ai Mediatori';
else if (tipomsg === this.TipoMsg.SEND_MSG_A_SOGNATORE)
mystr = 'Inviato Messaggio al Sognatore';
else if (tipomsg === this.TipoMsg.SEND_MSG_A_UTENTE_SOSTITUITO)
mystr = 'Inviato Messaggio all\'utente Sostituito';
else if (tipomsg === this.TipoMsg.SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE)
mystr = 'Inviato Messaggio Dono Ricevuto Correttamente';
return mystr;
}
};

View File

@@ -16,6 +16,7 @@ module.exports = Object.freeze({
RIS_CODE_ERR_UNAUTHORIZED: -30,
RIS_CODE_LOGIN_ERR_GENERIC: -20,
RIS_CODE_LOGIN_ERR: -10,
RIS_CODE_LOGIN_ERR_SUBACCOUNT: -8,
RIS_CODE_OK: 1,
RIS_CODE_LOGIN_OK: 1,

View File

@@ -20,6 +20,8 @@ module.exports = {
FILTER_USER_TELEGRAM_BLOCKED: 1024,
FILTER_ATTIVI: 2048,
FILTER_NASCOSTI: 4096,
FILTER_NAVI_NON_PRESENTI: 8192,
FILTER_QUALIFIED: 16384,
Permissions: {
Admin: 1,
@@ -49,6 +51,8 @@ module.exports = {
AGGIUNGI_NUOVO_IMBARCO: 380,
CANCELLA_IMBARCO: 385,
DAMMI_PRIMO_UTENTE_LIBERO: 390,
GET_VALBYTABLE: 400,
SET_VALBYTABLE: 410,
},
fieldsUserToChange() {