From e2cdee1baaca151fd100a866911384b9ea161393 Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Thu, 2 Jul 2020 22:00:58 +0200 Subject: [PATCH] Sistemazioni... --- docs/passi.txt | 44 ++++++- src/server/models/flotta.js | 29 +++++ src/server/models/listaingresso.js | 75 ++++++++++++ src/server/models/nave.js | 15 ++- src/server/models/navepersistente.js | 17 ++- src/server/models/user.js | 68 +++++++---- src/server/router/api/actions.js | 5 +- src/server/router/dashboard_router.js | 14 ++- src/server/router/index_router.js | 166 ++++++++++++++------------ src/server/router/users_router.js | 1 + src/server/sendemail.js | 6 +- src/server/telegram/telegrambot.js | 81 +++++++++---- src/server/tools/general.js | 104 ++++++++++++---- 13 files changed, 454 insertions(+), 171 deletions(-) diff --git a/docs/passi.txt b/docs/passi.txt index 07024e9..9b4c8c8 100644 --- a/docs/passi.txt +++ b/docs/passi.txt @@ -1,18 +1,55 @@ ------------ - - L'ultimo Utente della Creazione della Nave, compare ancora il Sognatore !!! Sistemato: TESTARE SE ORA È' OK... - // ************************************************ // ++Todo: PRIORITA' ALTA: +- Togliere i Video e il Sogno. (5 requisiti) +- Cestino di ELIMINA non funziona !! + +- (Linuccia) - Natalina Malerbi + DA CONTROLLARE CHE LEI NON HA PAGATO 8.44. + QUINDI QUALCUNO HA PRESO IL SUO POSTO. + + + - 7.64 : NATALINA NON HA LA RITESSITURA !! + + +- 1403 : Kukovič + ha tutto disattivato, mentre non è vero. +- 1344: Piera La Porta + ha tutto attivo invece non ha niente... + +- SubAccount: + filtro. + +- Aggiornare le Traduzioni di Darja (ritessitura). + +- Sistemare la email che arriva ai Donatori (HTML) ! + +- Flotte: Poter scegliere quale messaggio inviare ! + +- SE CAMBIANO LE CREDENZIALI: EMAIL... o username: segnalarlo sul BOT ! + +- Alla sostituzione, mandare msg all'Invitante + +- CONTROLLARE CHE IN NAVI NON CI SIANO i num_tess e ind_order UGUALI ! + ad esempio Angela + - Record 1 -> ind_order = 51 num_tess = 1 + - Record 2 -> ind_order = 51 num_tess = 1 <--- DEV'ESSERE A 3 ! + - Puoi imbarcarti non piu di 2 volte temporanee. - Togliere Sogno e Video. +- Controllare che da errore in fase di cancellazione dell'utente, dal profilo: + Fare una pagina intermedia che dice che sei stato cancellato... + +- Controllare la data nel tragitto sembra essere sbagliata (vedi Cinzia Ortolan). + - Profili Incompleti: Poter inviare dei messaggi in automatico per ricordargli di completare ... @@ -144,18 +181,15 @@ ind_order: 852 Gerico2 Elio2 Garelli Morgana Roveta (Maelabo) --- Gerico Elio Garelli - ANDREA |-----GERICO2 852 - .update({}, {$unset: {$ind_order: 1}, {multi: true}); - //++TODO: *** FATTI *** diff --git a/src/server/models/flotta.js b/src/server/models/flotta.js index 20cfbf3..c24375f 100755 --- a/src/server/models/flotta.js +++ b/src/server/models/flotta.js @@ -78,6 +78,9 @@ const FlottaSchema = new mongoose.Schema({ email_paypal: { type: String, }, + revolut: { + type: String, + }, note_payment: { type: String, }, @@ -111,6 +114,7 @@ function getQueryProj(myfilter) { username: 1, 'profile.paymenttypes': 1, 'profile.email_paypal': 1, + 'profile.revolut': 1, 'profile.cell': 1, made_gift: 1, commento_al_sognatore: 1, @@ -317,6 +321,31 @@ FlottaSchema.statics.getFlottaByNavePersistente = async function (idapp, naveper return myflotta; }; +FlottaSchema.statics.getStrFlotta = function (flotta) { + return `Flotta ${flotta.riga}.${Math.ceil(flotta.col_prima / 8)} - ${flotta.riga}.${Math.ceil(flotta.col_ultima / 8)}: Sognatore: ${flotta.sognatore_nomecognome}`; +}; + + +FlottaSchema.statics.getFlottaByRigaColDonatore = async function (idapp, riga, col) { + const Flotta = this; + + let mypos = { + idapp, + riga, + col, + numup: 3 + }; + tools.getRigaColByPosUp(mypos); + + const myflotta = await Flotta.findOne({ idapp, riga: mypos.riga, + $and: [ + { col_prima: { $lte: col } }, + { col_ultima: { $gte: col } } ] + }); + + return myflotta; +}; + const Flotta = mongoose.model('Flotta', FlottaSchema); diff --git a/src/server/models/listaingresso.js b/src/server/models/listaingresso.js index 17baa74..489eff1 100755 --- a/src/server/models/listaingresso.js +++ b/src/server/models/listaingresso.js @@ -11,6 +11,8 @@ const { ObjectID } = require('mongodb'); const { Nave } = require('./nave'); const { Graduatoria } = require('./graduatoria'); +const actions = require('../router/api/actions'); + const shared_consts = require('../tools/shared_nodejs'); const queryclass = require('../classes/queryclass'); @@ -929,6 +931,79 @@ ListaIngressoSchema.statics.getListaTessByUsername = function (idapp, username) }; + +ListaIngressoSchema.statics.eliminaListaIngresso = async function (idapp, ind_order, req, num_tess) { + const ListaIngresso = this; + + const telegrambot = require('../telegram/telegrambot'); + + const myrec = await ListaIngresso.getIngrEUserByFilter(idapp, { + idapp, + ind_order + }); + + let filtro = { idapp, ind_order }; + + // if (!!num_tess) { + // filtro.num_tess = num_tess; + // } + + // Controlla se ci sono piu navi + const arrnavi = await Nave.find(filtro); + + const eliminaveramente = false; + + let nasc = ''; + let receliminato = false; + + let risdel = false; + if (arrnavi.length === 1) { + if (!arrnavi[0].made_gift) { + // SE NON E' STATO CONFERMATO CHE HA FATTO IL DONO! + // Solo 1 nave da cancellare, quindi cancello anche l'ingresso + let filtrocanc = { idapp, ind_order }; + if (!!num_tess) + filtrocanc.num_tess = num_tess; + + let recdel = null; + if (eliminaveramente) { + recdel = await ListaIngresso.deleteOne(filtrocanc); + } else { + nasc = '(nascosto)'; + let fieldsvalue = { + date_deleted: new Date(), + deleted: true + }; + recdel = await ListaIngresso.findOneAndUpdate(filtrocanc, { $set: fieldsvalue }, { new: false }); + } + + risdel = !!recdel; + receliminato = !!recdel; + } + } else { + // non cancellare la listaingresso (perchè con lo stesso ind_order ho piu navi ! + risdel = true; + receliminato = false; + } + + let msg = ''; + if (risdel) { + if (receliminato) { + msg = 'Eliminato RECORD in Lista Imbarco ' + nasc + ' di ' + myrec.name + ' ' + myrec.surname + ' (ind_order=' + myrec.ind_order + ', num_tess=' + myrec.num_tess + ') [Num = ' + myrec.index + `] (da ${req.user.name} ${req.user.surname} )`; + } + await actions.doOtherThingsAfterDeleted('listaingressos', myrec, false, req) + } else { + msg = 'ATTENZIONE: il RECORD non è stato Eliminato perchè gia c\'era in altra NAVE -> di ' + myrec.name + ' ' + myrec.surname + ' (ind_order=' + myrec.ind_order + ', num_tess=' + myrec.num_tess + ') [Num = ' + myrec.index + `] (da ${req.user.name} ${req.user.surname} )`; + } + + if (!!msg) { + await telegrambot.sendMsgTelegramToTheManagers(myrec.idapp, msg); + tools.writeSostituzioniLog(msg); + } + + return risdel; +}; + ListaIngressoSchema.statics.getarray = async function (idapp, filtri, myobjField) { const ListaIngresso = this; diff --git a/src/server/models/nave.js b/src/server/models/nave.js index 388236e..105c46c 100755 --- a/src/server/models/nave.js +++ b/src/server/models/nave.js @@ -445,7 +445,9 @@ function getQueryProj(myfilter) { sospeso: 1, 'profile.paymenttypes': 1, 'profile.teleg_id': 1, + 'profile.nationality': 1, 'profile.email_paypal': 1, + 'profile.revolut': 1, 'profile.link_payment': 1, 'profile.note_payment': 1, 'profile.cell': 1, @@ -1498,6 +1500,7 @@ NaveSchema.statics.getFlotta = async function (idapp, riga, col_prima, col_ultim if (!!usersognatore) { flotta.link_payment = usersognatore.profile.link_payment; flotta.email_paypal = usersognatore.profile.email_paypal; + flotta.revolut = usersognatore.profile.revolut; flotta.note_payment = usersognatore.profile.note_payment; } @@ -1505,6 +1508,8 @@ NaveSchema.statics.getFlotta = async function (idapp, riga, col_prima, col_ultim const arrnavi = await Nave.aggregate(myquery); + const arrmediatori = []; + for (const nave of arrnavi) { // Se è il mediatore, allora non includerlo nei Donatori! mypos = { @@ -1519,6 +1524,8 @@ NaveSchema.statics.getFlotta = async function (idapp, riga, col_prima, col_ultim if (!!navemediatore) { if (navemediatore.ind_order !== nave.ind_order) { arrnaviout.push(nave); + } else { + arrmediatori.push(nave); } } else { arrnaviout.push(nave); @@ -1527,7 +1534,7 @@ NaveSchema.statics.getFlotta = async function (idapp, riga, col_prima, col_ultim flotta._doc.log_attivita = tools.readFlottaLog(idapp, flotta.riga, flotta.col_prima); - return { arrdonatori: arrnaviout, flotta }; + return { arrdonatori: arrnaviout, flotta, arrmediatori }; }; @@ -1650,11 +1657,9 @@ NaveSchema.statics.checkIfMadeGift = async function (idapp, username) { const arrlistaingr = await ListaIngresso.find({ idapp, username }); for (const ingr of arrlistaingr) { - let mynave = await Nave.findOne({ idapp, ind_order: ingr.ind_order }); + let mynave = await Nave.findOne({ idapp, ind_order: ingr.ind_order, made_gift: true }); if (!!mynave) { - if (mynave.made_gift) { - return true; - } + return true; } } diff --git a/src/server/models/navepersistente.js b/src/server/models/navepersistente.js index 626fbff..f44dc2a 100755 --- a/src/server/models/navepersistente.js +++ b/src/server/models/navepersistente.js @@ -94,6 +94,7 @@ function getQueryProj(myfilter) { username: 1, 'profile.paymenttypes': 1, 'profile.email_paypal': 1, + 'profile.revolut': 1, 'profile.link_payment': 1, 'profile.note_payment': 1, 'profile.cell': 1, @@ -357,7 +358,9 @@ NavePersistenteSchema.statics.changeField = async function (idapp, flotta, field let myval = {}; if ('date_close' in fieldvalue) { - myval['date_gift_chat_open'] = fieldvalue['date_close']; + myval['date_start'] = fieldvalue['date_close']; + } else if ('date_start' in fieldvalue) { + myval['date_gift_chat_open'] = fieldvalue['date_start']; } else { myval = fieldvalue; } @@ -378,6 +381,8 @@ NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function ( const { Nave } = require('../models/nave'); const { User } = require('./user'); + const { Flotta } = require('./flotta'); + let num = 0; @@ -387,7 +392,7 @@ NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function ( indcolflottaprima = tools.getPrimaColFlotta(naveinput.col1don + 7); - console.log(num, ' -> [', naveinput.riga, '.', naveinput.col, '] indcolflottaprima=', indcolflottaprima); + console.log(num, ' -> [', naveinput.riga, '.', naveinput.col1don, '] indcolflottaprima=', indcolflottaprima); let ini = Math.ceil(indcolflottaprima / 8); let fine = ini + 7; @@ -431,8 +436,8 @@ NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function ( myflotta.msg_inviato = false; } - myflotta.date_start = navepers.date_start; - myflotta.date_close = navepers.date_gift_chat_open; + myflotta.date_start = navepers.date_gift_chat_open; + myflotta.date_close = navepers.date_start; let sognatore = await Nave.getSognatoreByRigaColMediatore(idapp, { riga: navepers.riga, col: navepers.col }); if (myflotta.sognatore_nomecognome === '') { @@ -443,10 +448,12 @@ NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function ( if (nuovo) { myflotta.email_paypal = ''; + myflotta.revolut = ''; myflotta.link_payment = ''; myflotta.note_payment = ''; if (!!sognatore) { myflotta.email_paypal = sognatore.profile.email_paypal; + myflotta.revolut = sognatore.profile.revolut; myflotta.link_payment = sognatore.profile.link_payment; myflotta.note_payment = sognatore.profile.note_payment; } @@ -455,6 +462,8 @@ NavePersistenteSchema.statics.aggiornaFlottaByNavePersistente = async function ( if (!!sognatore) { if (!myflotta.email_paypal) myflotta.email_paypal = sognatore.profile.email_paypal; + if (!myflotta.revolut) + myflotta.revolut = sognatore.profile.revolut; if (!myflotta.link_payment) myflotta.link_payment = sognatore.profile.link_payment; if (!myflotta.note_payment) diff --git a/src/server/models/user.js b/src/server/models/user.js index 7fcc583..f0fecb1 100755 --- a/src/server/models/user.js +++ b/src/server/models/user.js @@ -185,6 +185,9 @@ const UserSchema = new mongoose.Schema({ email_paypal: { type: String }, + revolut: { + type: String + }, link_payment: { type: String }, @@ -455,6 +458,7 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username) 'profile.qualified_2invitati': 1, 'profile.saw_and_accepted': 1, 'profile.email_paypal': 1, + 'profile.revolut': 1, 'profile.link_payment': 1, 'profile.note_payment': 1, 'profile.my_dream': 1, @@ -505,6 +509,7 @@ UserSchema.statics.getDownlineByUsername = async function (idapp, username, incl 'profile.qualified_2invitati': 1, 'profile.saw_and_accepted': 1, 'profile.email_paypal': 1, + 'profile.revolut': 1, 'profile.link_payment': 1, 'profile.note_payment': 1, 'profile.my_dream': 1, @@ -583,11 +588,14 @@ UserSchema.statics.getQueryQualified = function () { 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED, 'profile.saw_zoom_presentation': true, 'profile.my_dream': { $exists: true }, - 'profile.email_paypal': { $exists: true }, - 'profile.paymenttypes': { "$in": ['paypal'] }, + $or: [ + { 'profile.email_paypal': { $exists: true } }, + { 'profile.revolut': { $exists: true } }, + ], + // 'profile.paymenttypes': { "$in": ['paypal'] }, $and: [ { "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } }, - { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } } + // { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } } ], // $where: "this.profile.paymenttypes.length >= 1", }] @@ -658,7 +666,7 @@ UserSchema.statics.setUserQualified = async function (idapp, username) { 'username': username, }; - const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified': true } }, { new: false } ); + const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified': true } }, { new: false }); return !!myrec; }; @@ -674,7 +682,7 @@ UserSchema.statics.setUserQualified_2Invitati = async function (idapp, username) 'username': username, }; - const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified_2invitati': true } }, { new: false } ); + const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified_2invitati': true } }, { new: false }); return !!myrec; }; @@ -697,10 +705,18 @@ UserSchema.statics.getnumPaymentOk = function (idapp) { return User.count({ idapp, - $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], - 'profile.paymenttypes': { "$in": ['paypal'] }, - $where: "this.profile.paymenttypes.length >= 1", - 'profile.email_paypal': { $exists: true }, + $and: [ + { + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }], + 'profile.paymenttypes': { "$in": ['paypal'] }, + }, + { + $or: [ + { 'profile.email_paypal': { $exists: true } }, + { 'profile.revolut': { $exists: true } }, + ] + } + ] }); }; @@ -1132,6 +1148,7 @@ UserSchema.statics.getRecByIndOrder = async function (idapp, ind_order) { surname: 1, 'profile.teleg_id': 1, 'profile.email_paypal': 1, + 'profile.revolut': 1, 'profile.link_payment': 1, 'profile.note_payment': 1, 'profile.paymenttypes': 1, @@ -1285,6 +1302,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.revolut', 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 }, @@ -2187,26 +2205,26 @@ UserSchema.statics.DbOp = async function (idapp, mydata) { return { num }; - } else if (mydata.dbop === 'creaLista') { + /*} else if (mydata.dbop === 'creaLista') { - await ListaIngresso.deleteMany({ idapp, added: false }); + await ListaIngresso.deleteMany({ idapp, added: false }); - arrusers = await User.find({ - 'idapp': idapp, - $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] - }).sort({ date_added: 1 }); - let num = 0; + arrusers = await User.find({ + 'idapp': idapp, + $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] + }).sort({ date_added: 1 }); + let num = 0; - num += await addUtentiInLista(idapp, 1, arrusers); - num += await addUtentiInLista(idapp, 2, arrusers); - num += await addUtentiInLista(idapp, 3, arrusers); - num += await addUtentiInLista(idapp, 4, arrusers); - num += await addUtentiInLista(idapp, 5, arrusers); - // num += await addUtentiInLista(idapp, 3); - // num += await addUtentiInLista(idapp, 4); - - return { num }; + num += await addUtentiInLista(idapp, 1, arrusers); + num += await addUtentiInLista(idapp, 2, arrusers); + num += await addUtentiInLista(idapp, 3, arrusers); + num += await addUtentiInLista(idapp, 4, arrusers); + num += await addUtentiInLista(idapp, 5, arrusers); + // num += await addUtentiInLista(idapp, 3); + // num += await addUtentiInLista(idapp, 4); + return { num }; + */ } } catch (e) { console.error(e.message); diff --git a/src/server/router/api/actions.js b/src/server/router/api/actions.js index 7f0a430..822a8b7 100755 --- a/src/server/router/api/actions.js +++ b/src/server/router/api/actions.js @@ -16,6 +16,9 @@ module.exports = { doOtherThingsAfterDeleted: async function (tablename, rec, notifBot, req) { try { let ris = null; + + const { ListaIngresso } = require('../../models/listaingresso'); + if (tablename === 'users') { await ListaIngresso.deleteUserInListaIngresso(rec.idapp, rec.username); @@ -42,7 +45,7 @@ module.exports = { ris = await Graduatoria.deleteOne({ idListaIngresso: ObjectID(rec._id) }); if (!!ris) { - 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} )` ; + let msg = 'Eliminato dalla Graduatoria 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); } diff --git a/src/server/router/dashboard_router.js b/src/server/router/dashboard_router.js index 70f61ef..4749990 100755 --- a/src/server/router/dashboard_router.js +++ b/src/server/router/dashboard_router.js @@ -102,7 +102,7 @@ router.post('/msgnave', authenticate, async (req, res) => { // 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); + ris = await telegrambot.sendMsgTelegramToNave(idapp, mydata, res); if (ris) res.send({ code: server_constants.RIS_CODE_OK, ris }); @@ -123,7 +123,7 @@ router.post('/msgflotta', authenticate, async (req, res) => { try { let ris = null; - ris = await telegrambot.sendMsgTelegramToNave(idapp, mydata); + ris = await telegrambot.sendMsgTelegramToNave(idapp, mydata, res); if (ris) res.send({ code: server_constants.RIS_CODE_OK, ris }); @@ -190,8 +190,10 @@ 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); + if (!!nave._doc.rec) { + 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); @@ -236,12 +238,14 @@ router.post('/getflotta', authenticate, async (req, res) => { const col_prima = req.body.col_prima; const col_ultima = req.body.col_ultima; + // const ris2 = await NavePersistente.aggiornaFlottaByNavePersistente(idapp, {riga, col1don: col_prima }); + 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 }); + res.send({ code: server_constants.RIS_CODE_OK, flotta: ris.flotta, arrdonatori: ris.arrdonatori, arrmediatori: ris.arrmediatori }); else res.status(400).send(e); diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index 8bc5a4f..2bd7edf 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -389,6 +389,7 @@ router.patch('/chval', authenticate, async (req, res) => { const mytable = getTableByTableName(mydata.table); const fieldsvalue = mydata.fieldsvalue; + const unset = mydata.unset; // tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue); @@ -416,6 +417,39 @@ router.patch('/chval', authenticate, async (req, res) => { let index = 0; + let recoldnave = null; + + let myuser = null; + let mydatamsg = {}; + + let flotta = null; + let strflotta = ''; + + if (mydata.table === 'navi') { + if (!!id) { + recoldnave = await mytable.findOne({ _id: ObjectID(id) }); + + let mypos = { + idapp, + riga: recoldnave.riga, + col: recoldnave.col, + numup: 3 + }; + tools.getRigaColByPosUp(mypos); + mydatamsg = { + navemediatore: { riga: mypos.riga, col: mypos.col }, + }; + + if (!!fieldsvalue.riga) { + flotta = await Flotta.getFlottaByRigaColDonatore(idapp, fieldsvalue.riga, fieldsvalue.col); + if (!!flotta) { + strflotta = Flotta.getStrFlotta(flotta); + } + myuser = await User.findByIndOrder(idapp, recoldnave.ind_order); + } + } + } + await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }).then(async (rec) => { // tools.mylogshow(' REC TO MODIFY: ', rec); if (!rec) { @@ -423,24 +457,14 @@ router.patch('/chval', authenticate, async (req, res) => { } 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 }, - }; + mydatamsg.tipomsg = tools.TipoMsg.SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE; const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg, myuser.lang, myuser, false); addmsg = rismsg.body; } @@ -448,6 +472,29 @@ router.patch('/chval', authenticate, async (req, res) => { await mytable.findByIdAndUpdate(id, { $set: { received_gift: true } }); } + + if (!!unset) { + const risunset = await mytable.findByIdAndUpdate(id, { $unset: unset }); + if (!!risunset) { + if ('date_made_gift' in unset) { + addtext = strflotta + ` E' stato annullato l'invio del dono di ${myuser.name} ${myuser.surname} (${myuser.username}) da parte di ${req.user.name} ${req.user.surname} - [Posiz: ${fieldsvalue.riga}.${fieldsvalue.col}]`; + telegrambot.sendMsgTelegramToTheManagers(idapp, addtext, false); + tools.writeFlottaLog(idapp, addtext, flotta.riga, flotta.col_prima); + + if (!!recoldnave) { + if (!!recoldnave.date_made_gift) { + // Se l'utente aveva confermato il Dono, allora gli mando un msg che non è stato ricevuto ... + mydatamsg.tipomsg = tools.TipoMsg.SEND_MSG_DONO_NON_RICEVUTO; + const rismsg = await telegrambot.getMsgByTipoMsg(mydatamsg, myuser.lang, myuser, false); + let mymsg = rismsg.body; + if (!!mymsg) { + await telegrambot.sendMsgTelegram(idapp, myuser.username, mymsg); + } + } + } + } + } + } } // SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE @@ -459,6 +506,9 @@ router.patch('/chval', authenticate, async (req, res) => { await telegrambot.sendMsgTelegram(idapp, mydata.notifBot.un, addmsg); addtext = '[Msg Inviato a ' + mydata.notifBot.un + ']:' + '\n' + mydata.notifBot.txt; telegrambot.sendMsgTelegramToTheManagers(idapp, addtext, true); + + if (!!flotta) + tools.writeFlottaLog(idapp, addtext, flotta.riga, flotta.col_prima); } if (mydata.table === 'users') { @@ -679,6 +729,7 @@ 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 dall'ultima Nave Temporanea miaarrnavi = await Nave.getArrPosizioniByUsername(idapp, username); @@ -704,48 +755,16 @@ router.patch('/callfunz', authenticate, async (req, res) => { if (!!myusernuovo) { if (!!mianavedasost && mianavedasost.ind_order >= 0) { - // Metti campo 'delete': true su ListaIngresso - olduseringresso = await ListaIngresso.findById(mianavedasost.idListaIngresso); - if (!!olduseringresso) { - let fieldsvalue = { - date_deleted: new Date(), - deleted: true - }; - const risul = await ListaIngresso.findByIdAndUpdate(mianavedasost.idListaIngresso, { $set: fieldsvalue }, { new: false }); - if (!!risul) { - const myrecuser = await ListaIngresso.getIngrEUserByFilter(idapp, { - idapp, - username: username_da_sostituire, - _id: ObjectID(mianavedasost.idListaIngresso) - }); + // ELIMINO LA LISTAINGRESSO CHE STO SOSTITUENDO (SOLO SE NON VIENE USATA DA ALTRA NAVE!) + let eliminatoingr = await ListaIngresso.eliminaListaIngresso(idapp, mianavedasost.ind_order, req, mianavedasost.num_tess); - if (!!myrecuser) { - const risdel = await ListaIngresso.deleteOne({ _id: olduseringresso.id }); - - if (!!risdel) { - await actions.doOtherThingsAfterDeleted('listaingressos', myrecuser, false, req) - } - } - } + if (!eliminatoingr){ + return res.send({ code: server_constants.RIS_CODE_ERR, msg: 'La Sostituzione non può avvenire ! Contattare Paolo. (ind_order=' + mianavedasost.ind_order + ')' }); } } } if (!!myuservecchio) { - // Se ha gia delle altre navi, non cancellarlo! - if (!await Nave.checkIfMadeGift(idapp, myuservecchio.username)) { - - if (mydata.data.deleteUser && !!mianavedasost && mianavedasost.ind_order > 0) { - // Metti Deleted allo User - fieldsvalue = { - deleted: true, - date_deleted: new Date(), - }; - await User.findByIdAndUpdate(myuservecchio.id, { $set: fieldsvalue }); - 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 = { @@ -766,6 +785,20 @@ router.patch('/callfunz', authenticate, async (req, res) => { } } + // Se ha gia delle altre navi, non cancellarlo! + if (!await Nave.checkIfMadeGift(idapp, myuservecchio.username)) { + + if (mydata.data.deleteUser && !!mianavedasost && mianavedasost.ind_order > 0) { + // Metti Deleted allo User + fieldsvalue = { + deleted: true, + date_deleted: new Date(), + }; + + await User.findByIdAndUpdate(myuservecchio.id, { $set: fieldsvalue }); + await telegrambot.sendMsgTelegramToTheManagers(idapp, `L\'utente ${myuservecchio.name} ${myuservecchio.surname} (${myuservecchio.username}) è stato cancellato (nascosto) perchè sostituito (da ${req.user.name} ${req.user.surname} )`); + } + } } @@ -791,12 +824,11 @@ router.patch('/callfunz', authenticate, async (req, res) => { } // Togliolo dalla Graduatoria! - const mygrad = await Graduatoria.findOneAndUpdate({ + await Graduatoria.findOneAndUpdate({ idapp, idListaIngresso: myingr._id }, { $set: { ind_order: -1 } }, { new: false }); - // Aggiorna la Nave con il Nuovo fieldsvalue = { ind_order @@ -805,9 +837,9 @@ router.patch('/callfunz', authenticate, async (req, res) => { const dachi = req.user.name + ' ' + req.user.surname; return await Nave.findByIdAndUpdate(mianavedasost.id, { $set: fieldsvalue }) - .then(async (rec) => { + .then(async (nave) => { // tools.mylogshow(' REC TO MODIFY: ', rec); - if (!rec) { + if (!nave) { return res.status(404).send(); } else { @@ -850,10 +882,11 @@ router.patch('/callfunz', authenticate, async (req, res) => { 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 + ']'; + const msgsost = '[NAVE ' + navepersistente.riga + '.' + navepersistente.col + '] Sostituito ' + myuservecchio.username + ' (' + myuservecchio.name + ' ' + myuservecchio.surname + ') ' + ' con -> ' + myusernuovo.username + ' (' + myusernuovo.name + ' ' + myusernuovo.surname + '' + + ') [Posiz. ' + nave.riga + '.' + nave.col + ' ind_order=' + nave.ind_order + '] ' + ' [da ' + dachi + ']'; tools.writeSostituzioniLog(msgsost); tools.writeFlottaLog(idapp, msgsost, mydatamsg.flotta.riga, mydatamsg.flotta.col_prima); - await telegrambot.sendMsgTelegramToTheManagers(idapp, msgsost); + await telegrambot.sendMsgTelegramToTheManagers(idapp, msgsost, false); // const nomecognomeprima = myuser.name + ' ' + myuser.surname + '(' + myuser.username + ')'; // const nomecognomenuovo = await User.getNameSurnameByUsername(idapp,); @@ -894,28 +927,11 @@ router.patch('/callfunz', authenticate, async (req, res) => { if (!!myrec) { 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 }); - 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 - } + const risdel = await ListaIngresso.eliminaListaIngresso(idapp, mydata.ind_order, req, mydata.data.num_tess); if (risdel) { - return await actions.doOtherThingsAfterDeleted('listaingressos', myrec, false, req) - .then((ris) => { - - if (!!ris) { - - // tools.mylog('DELETED Others things ...'); - return res.send({ code: server_constants.RIS_CODE_OK, msg: '' }); - } - }); + return res.send({ code: server_constants.RIS_CODE_OK, msg: '' }); } } @@ -981,7 +997,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => { notifBot = tools.NotifyIfDelRecord(tablename); let myrec = null; - if (!User.isAdmin(req.user.perm) || !User.isManager(req.user.perm)) { + if (!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) { if (tablename === 'users') { let fieldsvalue = { diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index a0dae7a..64708bd 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -136,6 +136,7 @@ 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.revolut = recorig.profile.revolut; user.profile.link_payment = recorig.profile.link_payment; user.profile.note_payment = recorig.profile.note_payment; user.profile.paymenttypes = recorig.profile.paymenttypes; diff --git a/src/server/sendemail.js b/src/server/sendemail.js index 209d64b..230223f 100755 --- a/src/server/sendemail.js +++ b/src/server/sendemail.js @@ -325,9 +325,11 @@ module.exports = { mylocalsconf.dataemail.emailbody = rec.emailbody; mylocalsconf.dataemail.emailtitle = rec.emailtitle; - const replyto = tools.getreplyToEmailByIdApp(idapp); + if (!!mylocalsconf.dataemail.emailtitle && !!mylocalsconf.dataemail.emailbody) { + const replyto = tools.getreplyToEmailByIdApp(idapp); - return this.sendEmail_base('standard', emailto, mylocalsconf, replyto); + return this.sendEmail_base('standard', emailto, mylocalsconf, replyto); + } // Send Email also to the Admin // this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf); diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js index c196e75..4d621c4 100755 --- a/src/server/telegram/telegrambot.js +++ b/src/server/telegram/telegrambot.js @@ -17,6 +17,7 @@ const { MsgTemplate } = require('../models/msg_template'); const emoji = require('node-emoji'); +const { Flotta } = require('../models/flotta'); const i18n = require("i18n"); @@ -557,18 +558,23 @@ module.exports = { msg = msg.replace('{surname}', user.surname); if (!!user.profile.link_payment) msg = msg.replace('{link_paypalme}', user.profile.link_payment); + if (!!user.profile.revolut) + msg = msg.replace('{revolut}', user.profile.revolut); 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); } + // const cl = getclTelegByidapp(user.idapp); + msg = msg.replace('{link_chathelp}', tools.HELP_CHAT); + 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)); + msg = msg.replace('{date_start}', tools.getstrDateLongTot(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)); + msg = msg.replace('{date_close}', tools.getstrDateLongTot(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) @@ -581,12 +587,14 @@ module.exports = { msg = msg.replace('{tutorslo}', mydata.flotta.tutorslo); if (!!mydata.flotta.sognatore_nomecognome) msg = msg.replace('{sognatore}', mydata.flotta.sognatore_nomecognome); + if (!!mydata.flotta.sognatore_nomecognome) + msg = msg.replace('{flotta}', mydata.flotta.riga + '.' + Math.ceil(mydata.flotta.col_prima / 8) + ' - ' + mydata.flotta.riga + '.' + Math.ceil(mydata.flotta.col_ultima / 8)); } return { body: msg, title }; }, - sendMsgTelegramToNave: async function (idapp, mydata) { + sendMsgTelegramToNave: async function (idapp, mydata, res) { let nummsgtosend = 0; let nummsgsent = 0; let strout = ''; @@ -596,7 +604,9 @@ module.exports = { try { let arrnavi = null; + let strflotta = ''; if (flotta) { + strflotta = Flotta.getStrFlotta(flotta); arrnavi = await Nave.getusersByFlotta(idapp, flotta.riga, flotta.col_prima, flotta.col_ultima); if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_A_SOGNATORE) { @@ -673,7 +683,8 @@ module.exports = { mytitle = rismsg.title; if (mymsgprimo === '') { - mymsgprimo = mymsg; + if (lang === 'it') + mymsgprimo = mymsg; } if (!!idteleg) { @@ -701,14 +712,18 @@ module.exports = { } if (!mydata.inviareale) { - await this.sendMsgTelegramToTheManagers(idapp, 'TEST INVIO MESSAGGIO:\n' + mymsgprimo + '\n\n(Messaggi da Inviare: ' + nummsgtosend + ')'); + await this.sendMsgTelegram(idapp, res.req.user.username, 'TEST INVIO MESSAGGIO:\n' + mymsgprimo + '\n\n(Messaggi da Inviare: ' + nummsgtosend + ')'); } if ((nummsgsent > 1) && (mydata.inviareale)) { try { 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; + if (!!mydata.tipomsg) { + msg = 'Flotta ' + strflotta + '): ' + tools.getStrMsgByTipoMsg(mydata.tipomsg) + '\n' + mymsg ; + } else { + 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; } @@ -1114,7 +1129,7 @@ class Telegram { } else if (MsgBot.PRINCIPE_AZZURRO.find((rec) => testo.indexOf(rec) > -1)) { risp = 'Chissà... Forse si!\nAnche se meglio averne un\'altro di scorta, nel caso il Principe non sia disponibile.'; } else if (MsgBot.AIUTO.find((rec) => testo.indexOf(rec) > -1)) { - risp = 'Clicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !'; + risp = 'Clicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + tools.HELP_CHAT + '\n\nI miei colleghi umani ti aiuteranno a risolvere !'; } else if (MsgBot.SPOSAMI.find((rec) => testo.indexOf(rec) > -1)) { risp = 'No Grazie! Sono per la Libertà a Vita! ' + emo.JOY + '\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE; } else if (MsgBot.CHE_TEMPO_FA.find((rec) => testo.indexOf(rec) > -1)) { @@ -1524,7 +1539,7 @@ class Telegram { let mystr = ''; if (rec.user) { mystr += printf(tools.get__('INFO_LINK_DA_CONDIVIDERE', this.getlang(msg)), tools.getHostByIdApp(this.idapp) + '/signup/' + rec.user.username); - mystr += tools.ACAPO + tools.ACAPO + printf(tools.get__('INFO_LINK_ZOOM', this.getlang(msg)), tools.getlinkzoom('')); + mystr += tools.ACAPO + tools.ACAPO + printf(tools.get__('INFO_LINK_ZOOM', this.getlang(msg)), tools.getlinkzoom(null)); await this.sendMsg(msg.chat.id, mystr); } } @@ -1566,16 +1581,19 @@ class Telegram { iniziata = (nextzoom._id.toString() === evento._id.toString()); + let lang = this.getlang(msg); + if (iniziata) { - mystr += emo.CHECK_VERDE + ' ' + tools.get__('ZOOM_INIZIATO', this.getlang(msg)) + ' ' + emo.CHECK_VERDE + '\n'; + mystr += emo.CHECK_VERDE + ' ' + tools.get__('ZOOM_INIZIATO', lang) + ' ' + emo.CHECK_VERDE + '\n'; } - mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start, this.getlang(msg))} ${emo.EYES}`; - mystr += `\n${evento.title}\n(${evento.note})\n\n`; + mystr += tools.getflagtelegrambyLang(evento.lang) + ` ${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start, this.getlang(msg))} ${emo.EYES}`; + mystr += `\n${evento.title}\n(${evento.note})`; + mystr += `\n${tools.getlinkzoom(evento)}\n\n`; if (nextzoom) { if (iniziata) { mystr += emo.FIRE + tools.get__('CLICCA_ENTRA', this.getlang(msg)) + ' ' + emo.FIRE + '\n'; - mystr += tools.getlinkzoom(evento.id_conf_zoom) + '\n'; + mystr += tools.getlinkzoom(evento) + '\n'; mystr += '\n'; //mystr += pwd + '\n\n'; } @@ -1587,7 +1605,7 @@ class Telegram { if (!nextzoom && index > 1) { mystr += "✨✨✨✨✨✨✨✨✨✨✨✨\n" + - tools.get__('CLICCA_PER_ZOOM', this.getlang(msg)) + ':\n' + tools.getlinkzoom(listazoom[0].id_conf_zoom) + '\n' + "✨✨✨✨✨✨✨✨✨✨✨✨\n"; + tools.get__('CLICCA_PER_ZOOM', this.getlang(msg)) + '\n' + "✨✨✨✨✨✨✨✨✨✨✨✨\n"; } return mystr @@ -1694,7 +1712,7 @@ class Telegram { } else if (qualelink === 'biblio') { return 'https://t.me/joinchat/AAAAAFMDe8b5lB1X7vOYng'; } else if (qualelink === 'help') { - return 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw'; + return tools.HELP_CHAT; } else if (qualelink === 'faq') { return 'https://ayni.gifteconomy.app/faq'; } else if (qualelink === 'empower') { @@ -1997,8 +2015,8 @@ class Telegram { // 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 }, + { text: Menu[lang].SI, callback_data: { action: InlineCmd.VOGLIO_IMBARCARMI, username: utente.username } }, + { text: Menu[lang].NO, callback_data: { action: InlineCmd.NON_VOGLIO_IMBARCARMI, username: utente.username } }, ]); inviaveramente = true; } else { @@ -2301,6 +2319,10 @@ class Telegram { if (!text) return 0; + if (process.env.LOCALE === "1") { + id = '12429864'; + } + if (!!msg_id) { return this.modificaMsg(chat_id, msg_id, text); } @@ -2335,6 +2357,12 @@ class Telegram { text = text.replace(/
/g, "\n"); text = text.replace(/
/g, ""); + text = text.replace(//g, ""); + text = text.replace(//g, ""); + text = text.replace(/

/g, ""); text = text.replace(/<\/div>/g, "\n"); text = text.replace(/ /g, " "); @@ -2589,7 +2617,7 @@ if (!tools.testing()) { const myclTelegram = getclTelegBytoken(bot.token); - const action = callbackQuery.data; + const data = callbackQuery.data; const msg = callbackQuery.message; const opts = { chat_id: msg.chat.id, @@ -2599,22 +2627,23 @@ if (!tools.testing()) { const status = await myclTelegram.setInit(msg); const rec = myclTelegram.getRecInMem(msg); + const user = await User.getUserShortDataByUsername(idapp, data.username); if (!!rec) { - if (!!rec.user) { - if (action === InlineCmd.VOGLIO_IMBARCARMI) { + if (!!user) { + if (data.action === InlineCmd.VOGLIO_IMBARCARMI) { // Controlla se è qualificato! - const mydata = tools.AddDate(rec.user.date_reg, 7); + const mydata = tools.AddDate(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); + const newrecingr = await ListaIngresso.addUserInListaIngresso(user.idapp, user.username, user.aportador_solidario, user.lang, true, true, mydata); - bot.editMessageText(tools.gettranslate('ADDED_TOLISTAINGRESSO', rec.user.lang), opts); + bot.editMessageText(tools.gettranslate('ADDED_TOLISTAINGRESSO', user.lang), opts); - } else if (action === InlineCmd.NON_VOGLIO_IMBARCARMI) { - await User.NonVoglioImbarcarmi(rec.user.idapp, rec.user.username); + } else if (data.action === InlineCmd.NON_VOGLIO_IMBARCARMI) { + await User.NonVoglioImbarcarmi(user.idapp, user.username); - const msgadd = '[' + rec.user.username + '] ' + rec.user.name + ' ' + rec.user.surname + ' ha risposto che NON VUOLE IMBARCARSI !'; + const msgadd = '[' + user.username + '] ' + user.name + ' ' + user.surname + ' ha risposto che NON VUOLE IMBARCARSI !'; - await local_sendMsgTelegramToTheManagers(rec.user.idapp, msgadd, msg, false); // Anche a STAFF + await local_sendMsgTelegramToTheManagers(user.idapp, msgadd, msg, false); // Anche a STAFF } } } diff --git a/src/server/tools/general.js b/src/server/tools/general.js index 8652394..0697fbd 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -82,11 +82,11 @@ textlang = { 'LINEE_GUIDA': 'Accettato le Linee Guida', 'VIDEO_INTRO': 'Visto il Video di AYNI', 'SCRITTO_SOGNO': 'Hai scritto il tuo Sogno', - 'PAYMENTS': 'Modalità di Pagamento (Obbligatorio Paypal)', + 'PAYMENTS': 'Modalità di Pagamento', 'INVITATI': 'persone registrate che hai invitato', 'INVITATI_ATTIVI': 'Invitati con i 7 Requisiti', 'NONREG': 'Invitati non Registrati', - 'CLICCA_PER_ZOOM': 'AL GIORNO E ORA INDICATA, PER ENTRARE NELLA VIDEO-CONFERENZA, CLICCA QUI', + 'CLICCA_PER_ZOOM': 'AL GIORNO E ORA INDICATA, PER ENTRARE NELLA VIDEO-CONFERENZA, CLICCA SUL LINK INDICATO', 'CLICCA_ENTRA': 'CLICCA QUI PER ENTRARE !', 'ZOOM_INIZIATO': 'QUESTA CONFERENZA E\' INIZIATA!', 'SCEGLI_VOCE': 'scegli una voce:', @@ -107,9 +107,9 @@ textlang = { 'NAVE COMPLETATA': 'NAVE COMPLETATA', 'Doni Effettuati': 'Doni Effettuati', 'Tutor che affianchèra il Mediatore': 'Tutor che affianchèra il Mediatore', - 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Apertura GIFT CHAT\n%s Chiusura GIFT CHAT\nNota Bene: Hai tempo 4 giorni dall\'apertura per entrare in Chat ed effettuare il tuo Dono, dopodichè effettueremo la sostituzione.', + 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Apertura GIFT CHAT\n%s Chiusura GIFT CHAT\nNota Bene: Hai tempo 3 giorni dall\'apertura per entrare in Chat ed effettuare il tuo Dono, dopodichè effettueremo la sostituzione.', 'Giorno di Apertura GIFT CHAT': 'Giorno di Apertura GIFT CHAT', - 'Giorno in cui Inviare il DONO': 'Hai 4 giorni di tempo per inviare il tuo dono.\nGiorno di Chiusura', + 'Giorno in cui Inviare il DONO': 'Hai 3 giorni di tempo per inviare il tuo dono.\nGiorno di Chiusura', 'SPOSTATO': 'Sei stato Spostato in una Nuova Nave !', 'Note': 'Note', 'TEMPORANEA': 'TEMPORANEA', @@ -153,7 +153,7 @@ textlang = { 'LINEE_GUIDA': 'Sprejemam pogoje poslovanja', 'VIDEO_INTRO': 'Pogledal sem video AYNI', 'SCRITTO_SOGNO': 'Sem zapisal Sanje', - 'PAYMENTS': 'Načini Plačila (Obvezen Paypal)', + 'PAYMENTS': 'Načini Plačila', 'INVITATI': 'registrirane osebe, ki si povabil', 'INVITATI_ATTIVI': 'Povabljenci s 7 Zahtevami', 'NONREG': 'Neregistrirani povabljenci', @@ -177,7 +177,7 @@ textlang = { 'NAVE COMPLETATA': 'LADJE DOSTAVLJEN', 'Doni Effettuati': 'Darila narejena', 'Tutor che affianchèra il Mediatore': 'Tutor, ki bo podpiral Mediatorja', - 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Apertura GIFT CHAT\n%s Zapiranje DARILNEGA KLEPETA\nBodi pozoren: Časa imaš 4 dni od odprtja za vstop v Klepet- ladjico in izpeljati svoje Vplačilo, po tem času bomo izvedli zamenjavo', + 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Apertura GIFT CHAT\n%s Zapiranje DARILNEGA KLEPETA\nBodi pozoren: Časa imaš 3 dni od odprtja za vstop v Klepet- ladjico in izpeljati svoje Vplačilo, po tem času bomo izvedli zamenjavo', 'SPOSTATO': 'Prestavljen si v Novo Ladjico !', 'Note': 'Opombe', 'TEMPORANEA': 'ZAČASNA', @@ -219,7 +219,7 @@ textlang = { 'LINEE_GUIDA': 'Directrices aceptadas', 'VIDEO_INTRO': 'Ver el video de AYNI', 'SCRITTO_SOGNO': 'Escribiste tu sueño', - 'PAYMENTS': 'Métodos de pago (Paypal obligatorio)', + 'PAYMENTS': 'Métodos de pago', 'INVITATI': 'las personas registradas que usted invitó', 'INVITATI_ATTIVI': 'Invitado con los 7 requisitos', 'NONREG': 'Invitados no registrados', @@ -243,7 +243,7 @@ textlang = { 'NAVE COMPLETATA': 'NAVE COMPLETADA', 'Doni Effettuati': 'Regalos Realizados', 'Tutor che affianchèra il Mediatore': 'Tutor de apoyo al Donante', - 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Apertura del CHAT DE REGALOS\n%s Cierre del CHAT DE REGALOS\nNota: Tienes 4 días desde la apertura para entrar en el Chat y hacer tu Regalo, después de lo cual haremos el reemplazo', + 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Apertura del CHAT DE REGALOS\n%s Cierre del CHAT DE REGALOS\nNota: Tienes 3 días desde la apertura para entrar en el Chat y hacer tu Regalo, después de lo cual haremos el reemplazo', 'SPOSTATO': 'Has sido trasladado a una nueva nave !', 'Note': 'Notas', 'TEMPORANEA': 'TEMPORAL', @@ -282,7 +282,7 @@ textlang = { 'LINEE_GUIDA': 'Guidelines Accepted', 'VIDEO_INTRO': 'Seen the AYNI Video', 'SCRITTO_SOGNO': 'You wrote your Dream', - 'PAYMENTS': 'Methods of Payment (Mandatory Paypal)', + 'PAYMENTS': 'Methods of Payment', 'INVITATI': 'registered people you invited', 'INVITATI_ATTIVI': 'Guests with the 7 Requirements', 'NONREG': 'Non-registered Guests', @@ -306,7 +306,7 @@ textlang = { 'NAVE COMPLETATA': 'SHIP COMPLETED', 'Doni Effettuati': 'Gifts Made', 'Tutor che affianchèra il Mediatore': 'Tutor supporting the Mediator', - 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Opening GIFT CHAT\n%s Closing GIFT CHAT\nNote: You have 4 days from the opening to enter the Chat and make your Gift, after which we will make the replacement.', + 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Opening GIFT CHAT\n%s Closing GIFT CHAT\nNote: You have 3 days from the opening to enter the Chat and make your Gift, after which we will make the replacement.', 'SPOSTATO': 'You\'ve been moved to a New Ship !', 'Note': 'Note', 'TEMPORANEA': 'TEMPORARY', @@ -349,7 +349,7 @@ textlang = { 'LINEE_GUIDA': 'Lignes directrices acceptées', 'VIDEO_INTRO': 'Voir la vidéo AYNI', 'SCRITTO_SOGNO': 'Vous avez écrit votre rêve', - 'PAYMENTS': 'Modes de paiement (Paypal obligatoire)', + 'PAYMENTS': 'Modes de paiement', 'INVITATI': 'personnes inscrites que vous avez invitées', 'INVITATI_ATTIVI': 'Invité avec les 7 exigences', 'NONREG': 'Invités non enregistrés', @@ -373,7 +373,7 @@ textlang = { 'NAVE COMPLETATA': 'NAVIRE COMPLÉTÉ', 'Doni Effettuati': 'Don effectués', 'Tutor che affianchèra il Mediatore': 'Le tuteur qui soutient le Mediateur', - 'APERTURA_CHIUSURA_GIFT_CHAT': '%s : Chat d\'ouverture\n%s Clôture du GIFT CHAT\nNote: Vous avez 4 jours à partir de l\'ouverture pour entrer dans le Chat et faire votre Cadeau, après quoi nous ferons le remplacement', + 'APERTURA_CHIUSURA_GIFT_CHAT': '%s : Chat d\'ouverture\n%s Clôture du GIFT CHAT\nNote: Vous avez 3 jours à partir de l\'ouverture pour entrer dans le Chat et faire votre Cadeau, après quoi nous ferons le remplacement', 'SPOSTATO': 'Vous avez été transféré sur un nouveau navire !', 'Note': 'Notes', 'TEMPORANEA': 'TEMPORAIRE', @@ -416,7 +416,7 @@ textlang = { 'LINEE_GUIDA': 'Directrizes Aceites', 'VIDEO_INTRO': 'Ver o vídeo do AYNI', 'SCRITTO_SOGNO': 'Você escreveu o seu sonho', - 'PAYMENTS': 'Formas de pagamento (Obrigatório Paypal)', + 'PAYMENTS': 'Formas de pagamento', 'INVITATI': 'pessoas registadas que convidou', 'INVITATI_ATTIVI': 'Convidado com os 7 Requisitos', 'NONREG': 'Convidados não registados', @@ -440,7 +440,7 @@ textlang = { 'NAVE COMPLETATA': 'NAVIO COMPLETADO', 'Doni Effettuati': 'Regalo Feitos', 'Tutor che affianchèra il Mediatore': 'Tutor que apoia o Mediator', - 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Abertura do GIFT CHAT\n%s Fechamento GIFT CHAT\nNota: Você tem 4 dias desde a abertura para entrar no Chat e fazer o seu Presente, depois do qual faremos o substituição.', + 'APERTURA_CHIUSURA_GIFT_CHAT': '%s: Abertura do GIFT CHAT\n%s Fechamento GIFT CHAT\nNota: Você tem 3 dias desde a abertura para entrar no Chat e fazer o seu Presente, depois do qual faremos o substituição.', 'SPOSTATO': 'Você foi transferido para um novo navio !', 'Note': 'Notas', 'TEMPORANEA': 'TEMPORÁRIO', @@ -463,6 +463,10 @@ module.exports = { AYNI: '7', SIP: '9', + HELP_CHAT: 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw', + TYPECONF_ZOOM: 'zoom', + TYPECONF_JITSI: 'jitsi', + APORTADOR_NONE: '------', TYPE_PROJECT: 1, @@ -479,6 +483,7 @@ module.exports = { SEND_MSG_A_SOGNATORE: 1020, SEND_MSG_A_UTENTE_SOSTITUITO: 1030, SEND_MSG_DONO_RICEVUTO_CORRETTAMENTE: 1040, + SEND_MSG_DONO_NON_RICEVUTO: 1050, }, Placca: { @@ -1258,7 +1263,7 @@ module.exports = { return n }, - getWeekDayByLang(date, lang) { + getWeekDayByLangByNumCar(date, lang, num) { if (!lang) lang = 'it'; @@ -1272,9 +1277,21 @@ module.exports = { pt: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'], de: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'], si: ['Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'četrtek', 'Petek', 'Sobota'], - } + }; - return isNaN(dayOfWeek) ? '' : myday[lang][dayOfWeek].substring(0, 3) + if (num > 0) { + return isNaN(dayOfWeek) ? '' : myday[lang][dayOfWeek].substring(0, num) + } else { + return isNaN(dayOfWeek) ? '' : myday[lang][dayOfWeek] + } + }, + + getWeekDayByLang(date, lang) { + return this.getWeekDayByLangByNumCar(date, lang, 3) + }, + + getWeekDayByLangTot(date, lang) { + return this.getWeekDayByLangByNumCar(date, lang, 0) }, getWeekDay(date) { @@ -1315,6 +1332,15 @@ module.exports = { } }, + getstrDateLongTot(mydate, lang) { + if (mydate) { + // console.log('getstrDate', mytimestamp) + return this.getWeekDayByLangTot(mydate, lang) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1) + '/' + mydate.getFullYear(); + } else { + return ''; + } + }, + getstrDateLongFile(mydate, lang) { if (mydate) { // console.log('getstrDate', mytimestamp) @@ -1324,10 +1350,27 @@ module.exports = { } }, - getlinkzoom(idconf) { - if (idconf === '') - idconf = '6668882000'; - return 'https://zoom.us/j/' + idconf + getlinkzoom(rec) { + if (rec === null) { + rec = { + typeconf: this.TYPECONF_ZOOM, + id_conf_zoom: '', + } + } + let typeconf = rec.typeconf; + if (typeconf === '') + typeconf = this.TYPECONF_ZOOM; + + let mylink = 'https://zoom.us/j/'; + if (typeconf === this.TYPECONF_JITSI) + mylink = 'https://meet.jit.si/'; + + if (rec.id_conf_zoom === '') { + rec.id_conf_zoom = '6668882000'; + } + + return mylink + rec.id_conf_zoom + }, getmd5(mystr) { @@ -1417,9 +1460,9 @@ module.exports = { readlogfile(idapp, filename) { - try{ + try { return fs.readFileSync(idapp + '/' + filename, 'utf8'); - }catch (e) { + } catch (e) { return ''; } }, @@ -1666,6 +1709,21 @@ module.exports = { mystr = 'Inviato Messaggio Dono Ricevuto Correttamente'; return mystr; + }, + + getflagtelegrambyLang(lang) { + if (lang === 'it') + return '🇮🇹'; + else if (lang === 'si') + return '🇸🇮'; + else if (lang === 'es') + return '🇪🇸'; + else if (lang === 'enUs') + return '🇬🇧'; + else if (lang === 'uk') + return '🇬🇧'; + else if (lang === 'fr') + return '🇫🇷'; }