2021-10-05 15:39:44 +02:00
const os = require ( 'os' ) ;
2018-12-24 20:31:02 +01:00
2019-12-27 12:41:39 +01:00
const fs = require ( 'fs' ) ;
2021-02-18 12:19:35 +01:00
const path = require ( 'path' ) ;
2019-10-05 20:01:56 +02:00
require ( '../config/config' ) ;
2019-02-14 19:01:41 +01:00
require ( '../models/subscribers' ) ;
2022-01-14 23:54:33 +01:00
const printf = require ( 'util' ) . format ;
2021-04-30 01:31:12 +02:00
const Site = require ( '../models/site' ) ;
2019-12-04 02:03:44 +01:00
const CryptoJS = require ( 'crypto-js' ) ;
2020-01-20 01:48:25 +01:00
const Url = require ( 'url-parse' ) ;
2019-02-14 19:01:41 +01:00
2021-10-05 15:39:44 +02:00
const { ObjectID } = require ( 'mongodb' ) ;
2019-10-21 20:38:10 +02:00
2020-02-07 22:08:46 +01:00
const shared _consts = require ( './shared_nodejs' ) ;
2020-02-02 04:06:32 +01:00
2021-10-05 15:39:44 +02:00
const mongoose = require ( 'mongoose' ) . set ( 'debug' , false ) ;
2019-02-14 19:01:41 +01:00
const Subscription = mongoose . model ( 'subscribers' ) ;
2019-11-21 00:18:40 +01:00
const server _constants = require ( './server_constants' ) ;
2019-02-27 02:59:02 +01:00
2022-03-01 23:50:58 +01:00
const download = require ( 'image-downloader' ) ;
2022-02-28 17:20:47 +01:00
2019-02-12 12:06:25 +01:00
// SETTINGS WebPush Configuration
const webpush = require ( 'web-push' ) ;
2020-02-19 16:09:16 +01:00
const FILELOG = 'filelog.txt' ;
const FILEEVENTS = 'logevents.txt' ;
2020-03-10 21:44:14 +01:00
const FILEMANAGERS = 'logmanagers.txt' ;
2022-02-27 16:56:02 +01:00
const FILEERRLOGIN = 'errlogin.txt' ;
2020-06-08 13:31:05 +02:00
const FILESOSTITUZIONI = 'log_sostituzioni.txt' ;
2020-07-13 23:35:05 +02:00
const FILEIP _TO _BAN = 'log_iptoban.txt' ;
2020-03-10 21:44:14 +01:00
const FILENAVE = 'logNave.txt' ;
2021-09-22 01:13:41 +02:00
const subject = process . env . VAPI _KEY _SUBJECT ;
2019-02-12 12:06:25 +01:00
const publicVapidKey = process . env . PUBLIC _VAPI _KEY ;
const privateVapidKey = process . env . PRIVATE _VAPI _KEY ;
2019-02-14 19:01:41 +01:00
2020-03-21 10:28:26 +01:00
const FIELDS _REGEX = [ 'username' , 'name' , 'surname' ] ;
2020-03-10 21:44:14 +01:00
2020-01-03 01:52:49 +01:00
// Code goes here
const keySize = 256 ;
const ivSize = 128 ;
const iterations = 100 ;
2021-10-05 15:39:44 +02:00
if ( ! ! process . env . GCM _API _KEY && process . env . GCM _API _KEY !== '' ) {
2019-02-14 19:01:41 +01:00
webpush . setGCMAPIKey ( process . env . GCM _API _KEY ) ;
2021-04-30 01:31:12 +02:00
webpush . setVapidDetails ( subject , publicVapidKey , privateVapidKey ) ;
}
2019-04-06 21:02:39 +02:00
// console.log('setVapidDetails... config...');
2019-02-14 19:01:41 +01:00
2020-01-20 01:48:25 +01:00
// To Translate!
2021-04-30 01:31:12 +02:00
const textlang = {
2020-01-20 01:48:25 +01:00
it : {
2021-10-05 15:39:44 +02:00
'L\'Email è già stata Verificata' : 'L\'Email è già stata Verificata' ,
'Nuova Registrazione' : 'Nuova Registrazione' ,
'Effettuata una Nuova Registrazione' : 'Effettuata una Nuova Registrazione' ,
'partecipanti' : 'partecipanti all\'Evento' ,
'partecipanti a Pranzo' : 'partecipanti a Pranzo' ,
'partecipanti a Cena' : 'partecipanti a Cena' ,
'partecipanti a Cena Condivisa' : 'partecipanti a Cena Condivisa' ,
2021-12-23 14:13:40 +01:00
'TESTO_ASSISTENZA' : '<strong><a href="%s">👉 Per entrare nel Sito</a></strong>\n\n' +
'👉 <strong><a href="https://freeplanet.app/requestresetpwd">Hai dimenticato la password?</a></strong>\n\n' ,
2022-02-21 13:12:27 +01:00
'BENVENUTO' : 'Benvenut@' ,
2021-10-05 15:39:44 +02:00
'TUE_NAVI' : 'Ecco le tue Navi programmate' ,
2021-12-23 14:13:40 +01:00
'HAI_I_7_REQUISITI' : 'PRIMI PASSI OK!\nHai i Primi Requisiti per Entrare nella Lista !' ,
'NON_HAI_I_7_REQUISITI' : 'Attenzione!\nAncora non hai i 7 Requisiti per Entrare nella Lista !' ,
2020-03-10 21:44:14 +01:00
'INFO_LA_MIA_LAVAGNA' : '✨ Lista dei Passi: ✨ \n' ,
2021-12-23 14:13:40 +01:00
'INFO_LAVAGNA_SITO_COMPLETARE' : 'Per completare tutti i requisiti vai sul sito:\n%s\n👉🏻 <a href="%s">Entra nella tua Lavagna</a>.\n' ,
'INFO_LAVAGNA_SITO' : 'Per vedere in dettaglio lo <strong>STATO</strong>, sul sito \n 👉🏻 <a href="%s">Entra nella tua Lavagna</a>.\n' ,
'INFO_LINK_DA_CONDIVIDERE' : 'Link da condividere ai tuoi invitati per farli registrare al sito:\n\n%s' ,
2020-04-24 10:29:25 +02:00
'INFO_LINK_ZOOM' : 'Link da condividere per partecipare allo Zoom (Conferenza OnLine):\n%s' ,
2020-05-04 19:34:41 +02:00
'ZOOM_CONFERENCE' : 'Ecco il programma delle Conferenze (Zoom) aperti a TUTTI:' ,
2021-10-05 15:39:44 +02:00
'NON_VERIF' : 'Non Verificata' ,
'VERIF' : 'Verificata' ,
'EMAIL' : 'Email' ,
2021-12-23 14:13:40 +01:00
'BOT' : 'BOT' ,
'EMAIL_NON_VERIF' : 'Email Non Verificata\nleggi la tua casella email e trova **"Confermare la Registrazione"**\ne clicca sul bottone **"Verifica Registrazione"**' ,
2021-10-05 15:39:44 +02:00
'TELEGRAM_NOT_CONNECTED' : 'Telegram non associato al tuo account!' ,
2020-01-20 01:48:25 +01:00
'NESSUN_INVITATO' : 'Non hai invitato nessuno' ,
'ZOOM_PARTECIPATO' : 'Partecipazione ad almeno 1 Conferenza (Zoom)' ,
2020-02-07 22:08:46 +01:00
'LINEE_GUIDA' : 'Accettato le Linee Guida' ,
2021-12-23 14:13:40 +01:00
'VIDEO_INTRO' : 'Visto il Video' ,
2020-01-20 01:48:25 +01:00
'SCRITTO_SOGNO' : 'Hai scritto il tuo Sogno' ,
2020-07-02 22:00:58 +02:00
'PAYMENTS' : 'Modalità di Pagamento' ,
2020-01-20 01:48:25 +01:00
'INVITATI' : 'persone registrate che hai invitato' ,
2020-02-19 16:09:16 +01:00
'INVITATI_ATTIVI' : 'Invitati con i 7 Requisiti' ,
2020-02-02 04:06:32 +01:00
'NONREG' : 'Invitati non Registrati' ,
2020-07-02 22:00:58 +02:00
'CLICCA_PER_ZOOM' : 'AL GIORNO E ORA INDICATA, PER ENTRARE NELLA VIDEO-CONFERENZA, CLICCA SUL LINK INDICATO' ,
2020-02-19 16:09:16 +01:00
'CLICCA_ENTRA' : 'CLICCA QUI PER ENTRARE !' ,
'ZOOM_INIZIATO' : 'QUESTA CONFERENZA E\' INIZIATA!' ,
'SCEGLI_VOCE' : 'scegli una voce:' ,
'INVITATI_LISTA' : 'I Tuoi Invitati (in verde con almeno i primi 7 Requisiti)' ,
2020-03-10 21:44:14 +01:00
'CIAO' : 'Ciao' ,
2020-05-11 22:43:14 +02:00
'ADDED_TOLISTAINGRESSO' : '<strong>Complimenti! 🎊</strong>\nSei stato aggiunto alla <strong>Lista D\'Imbarco</strong> !\nNei prossimi giorni riceverai un messaggio qui quando la tua Nave sarà pronta a partire.\nRicorda che per salire di graduatoria, puoi condividere il Movimento con i tuoi amici ❤️.' ,
'REGALATO_INVITANTE' : 'da fare.... 😍🎊 Hai ricevuto in Regalo un Invitato {invitato} da parte di {mittente} !' ,
2020-03-10 21:44:14 +01:00
'NO_PROG' : 'Attualmente non sei ancora dentro alla Lista d\'Imbarco!' ,
2020-05-10 21:07:51 +02:00
'SEND_LINK_CHAT_DONATORI' : 'Ciao %s!\nLa tua NAVE sta finalmente Salpando!\nEntra nella Gift Chat della nave {%s} cliccando qui: %s' ,
'SEND_LINK_CHAT_SOGNATORE' : 'Ciao %s!\nOggi Diventi Sognatore !!! 🎊🎊🎊 Entra nella Gift Chat della nave {%s} cliccando qui: %s' ,
'ENTRA_GIFT_CHAT' : 'Entra nella Gift Chat' ,
'DATA_PART_NAVE' : 'data di Partenza della Nave:' ,
2020-03-31 20:34:24 +02:00
'SOGNATORE' : 'SOGNATORE' ,
2020-05-13 01:32:27 +02:00
'INTERMEDIO' : 'Intermedio' ,
2020-03-31 20:34:24 +02:00
'MEDIATORE' : 'MEDIATORE' ,
'DONATORI' : 'DONATORI' ,
'RITESSITURA' : 'RITESSITURA' ,
'NAVE COMPLETATA' : 'NAVE COMPLETATA' ,
'Doni Effettuati' : 'Doni Effettuati' ,
'Tutor che affianchèra il Mediatore' : 'Tutor che affianchèra il Mediatore' ,
2020-07-02 22:00:58 +02:00
'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.' ,
2020-03-31 20:34:24 +02:00
'Giorno di Apertura GIFT CHAT' : 'Giorno di Apertura GIFT CHAT' ,
2020-07-02 22:00:58 +02:00
'Giorno in cui Inviare il DONO' : 'Hai 3 giorni di tempo per inviare il tuo dono.\nGiorno di Chiusura' ,
2020-05-10 21:07:51 +02:00
'SPOSTATO' : 'Sei stato Spostato in una Nuova Nave !' ,
2020-03-31 20:34:24 +02:00
'Note' : 'Note' ,
'TEMPORANEA' : 'TEMPORANEA' ,
'NAVE' : 'NAVE' ,
2020-04-07 14:34:29 +02:00
'MSG_SEND_FROM' : 'Msg Inviato da' ,
2020-09-04 00:06:49 +02:00
'ZOOM_CONFERMATO' : 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!' ,
2022-03-11 12:38:01 +01:00
'RICHIESTA_AMICIZIA' : '🌈 Richiesta d\'Amicizia da parte di %s' ,
2022-03-30 22:51:03 +02:00
'ACCETTATO_SUL_GRUPPO' : '✅ Sei stato accettato da %s a far parte del Gruppo %s' ,
'ACCETTATO_NOTIFICA_ADMINS' : '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)' ,
2022-02-05 23:28:15 +01:00
'RICHIESTA_GRUPPO' : 'Richiesta di entrare nel Gruppo %s da parte di %s' ,
'RICHIESTA_BLOCCO_GRUPPO' : 'Richiesta di bloccare il Gruppo %s da parte di %s' ,
2020-03-31 20:34:24 +02:00
} ,
2022-01-14 23:54:33 +01:00
si : { } ,
2020-01-20 01:48:25 +01:00
es : {
2021-10-05 15:39:44 +02:00
'L\'Email è già stata Verificata' : 'El correo electrónico ya ha sido verificado' ,
'Nuova Registrazione' : 'Nuevo Registro' ,
'Effettuata una Nuova Registrazione' : 'Se ha realizado un nuevo registro' ,
'partecipanti' : 'participantes' ,
'partecipanti a Pranzo' : 'partecipanti a Pranzo' ,
'partecipanti a Cena' : 'partecipanti a Cena' ,
2021-12-23 14:13:40 +01:00
'TESTO_ASSISTENZA' : 'Para entrar en el sitio:\n%s\n\n' +
'¿Olvidó su contraseña para acceder al sitio?\nhttps://freeplanet.app/requestresetpwd\n\n' ,
2021-10-05 15:39:44 +02:00
'BENVENUTO' : 'Bienvenido' ,
'TUE_NAVI' : 'Aquí están sus naves programadas' ,
2020-03-31 20:34:24 +02:00
'HAI_I_7_REQUISITI' : '¡LOS PRIMEROS PASOS ESTÁN BIEN!\nTiene los primeros 7 requisitos para entrar en la lista de embarque!' ,
'NON_HAI_I_7_REQUISITI' : '¡Atención!\nTodavía no tienes los 7 requisitos para entrar en la lista de embarque!' ,
2021-12-23 14:13:40 +01:00
'HAI_I_9_REQUISITI' : '¡FELICITACIONES!\n¡Has completado los 9 pasos de la Guía! Gracias por ayudar a expandirse!' ,
2020-03-31 20:34:24 +02:00
'NON_HAI_I_9_REQUISITI' : 'Recuerda que puedes ayudar a que el Movimiento crezca y se expanda compartiendo nuestro viaje con todos.!' ,
'INFO_LA_MIA_LAVAGNA' : '✨ Lista de pasos: ✨ \n' ,
2020-05-11 22:43:14 +02:00
'INFO_LAVAGNA_SITO_COMPLETARE' : 'Para completar todos los requisitos vaya al sitio:\n%s\nPara ver el estado de su nave y sus invitados,👉🏻 <a href="%s">Pizarra</a>.\n' ,
2021-12-23 14:13:40 +01:00
'INFO_LAVAGNA_SITO' : 'Para ver en detalle el estado de su nave, en el sitio web, haga clic en las 3 líneas de la parte superior izquierda y vaya a "Pizarra"..\n' ,
'INFO_LINK_DA_CONDIVIDERE' : 'Enlaces para compartir con sus invitados para que se registren en el sitio web:\n\n%s' ,
2020-04-24 10:29:25 +02:00
'INFO_LINK_ZOOM' : 'Enlaces para compartir para participar en el Zoom (Conferencia en línea):\n%s' ,
2020-03-31 20:34:24 +02:00
'ZOOM_CONFERENCE' : 'Aquí puedes encontrar las fechas de programación en el Zoom:' ,
2021-10-05 15:39:44 +02:00
'NON_VERIF' : 'No verificado' ,
'VERIF' : 'Verificado' ,
'EMAIL' : 'Email' ,
2021-12-23 14:13:40 +01:00
'BOT' : 'BOT' ,
'EMAIL_NON_VERIF' : 'Correo electrónico no verificado\nlea su buzón y encuentre **"Confirmar Registro "** <marca>y haga clic en el botón **"Verificar Registro "**.' ,
2021-10-05 15:39:44 +02:00
'TELEGRAM_NOT_CONNECTED' : 'Telegram no asociado a su cuenta!' ,
2020-03-31 20:34:24 +02:00
'NESSUN_INVITATO' : 'No invitaste a nadie' ,
'ZOOM_PARTECIPATO' : 'Participación en al menos 1 Conferencia (Zoom)' ,
'LINEE_GUIDA' : 'Directrices aceptadas' ,
2021-12-23 14:13:40 +01:00
'VIDEO_INTRO' : 'Ver el video' ,
2020-03-31 20:34:24 +02:00
'SCRITTO_SOGNO' : 'Escribiste tu sueño' ,
2020-07-02 22:00:58 +02:00
'PAYMENTS' : 'Métodos de pago' ,
2020-03-31 20:34:24 +02:00
'INVITATI' : 'las personas registradas que usted invitó' ,
'INVITATI_ATTIVI' : 'Invitado con los 7 requisitos' ,
'NONREG' : 'Invitados no registrados' ,
'CLICCA_PER_ZOOM' : 'AL DÍA Y HORA INDICADOS, PARA ENTRAR EN LA VIDEOCONFERENCIA, PULSE AQUÍ' ,
'CLICCA_ENTRA' : 'HAGA CLIC AQUÍ PARA ENTRAR !' ,
'ZOOM_INIZIATO' : 'ESTA CONFERENCIA HA COMENZADO!' ,
'SCEGLI_VOCE' : 'elegir una voz:' ,
'INVITATI_LISTA' : 'Sus invitados (en verde con al menos los 7 primeros requisitos)' ,
2020-03-10 21:44:14 +01:00
'CIAO' : 'Hola' ,
'ADDED_TOLISTAINGRESSO' : 'Has sido añadido a la lista de personas que entrarán en Lista de embarque!' ,
2020-03-31 20:34:24 +02:00
'NO_PROG' : 'Actualmente no está en la lista de embarque.!' ,
'SEND_LINK_CHAT_DONATORI' : 'Hola %s!\n¡Tu barco por fin está navegando!\nEntra en el Gift Chat haciendo clic aquí: %s' ,
2020-05-10 21:07:51 +02:00
'SEND_LINK_CHAT_SOGNATORE' : '¡Hola!\n¡Hoy te conviertes en un soñador! 🎊🎊🎊 Entre en el Chat de Regalos de la nave {%s} haciendo clic aquí: %s' ,
'ENTRA_GIFT_CHAT' : 'Entre en el Chat de Regalos' ,
'DATA_PART_NAVE' : 'fecha de salida de la nave:' ,
2020-03-31 20:34:24 +02:00
'SOGNATORE' : 'SOÑADOR' ,
2020-05-13 01:32:27 +02:00
'INTERMEDIO' : 'Intermedio' ,
2020-03-31 20:34:24 +02:00
'MEDIATORE' : 'MEDIATOR' ,
'DONATORI' : 'DONANTES' ,
'RITESSITURA' : 'RETEJIDO' ,
'NAVE COMPLETATA' : 'NAVE COMPLETADA' ,
'Doni Effettuati' : 'Regalos Realizados' ,
'Tutor che affianchèra il Mediatore' : 'Tutor de apoyo al Donante' ,
2020-07-02 22:00:58 +02:00
'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' ,
2020-05-10 21:07:51 +02:00
'SPOSTATO' : 'Has sido trasladado a una nueva nave !' ,
2020-03-31 20:34:24 +02:00
'Note' : 'Notas' ,
'TEMPORANEA' : 'TEMPORAL' ,
'NAVE' : 'NAVE' ,
2020-04-07 14:34:29 +02:00
'MSG_SEND_FROM' : 'Mensaje enviado por' ,
2020-09-04 00:06:49 +02:00
'ZOOM_CONFERMATO' : '¡Se ha confirmado que ha visto la Video Conferencia de Bienvenida!' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_AMICIZIA' : 'Richiesta d\'Amicizia da parte di %s' ,
'ACCETTATO_SUL_GRUPPO' : 'Sei stato accettato da %s a far parte del Gruppo %s' ,
2022-03-30 22:51:03 +02:00
'ACCETTATO_NOTIFICA_ADMINS' : 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_GRUPPO' : 'Richiesta di entrare nel Gruppo %s da parte di %s' ,
'RICHIESTA_BLOCCO_GRUPPO' : 'Richiesta di bloccare il Gruppo %s da parte di %s' ,
2020-01-20 01:48:25 +01:00
} ,
2020-03-31 20:34:24 +02:00
enUs : {
2021-10-05 15:39:44 +02:00
'partecipanti' : 'participants' ,
'partecipanti a Pranzo' : 'partecipanti a Pranzo' ,
'partecipanti a Cena' : 'partecipanti a Cena' ,
2021-12-23 14:13:40 +01:00
'TESTO_ASSISTENZA' : 'To enter the Site:\n%s\n\nForgot your password to access the site?\n' +
'https://freeplanet.app/requestresetpwd\nChat AYNI BOT (this one):\nhttps://t.me/notevoleaynibot\n\n' ,
2021-10-05 15:39:44 +02:00
'BENVENUTO' : 'Welcome' ,
'TUE_NAVI' : 'Here are your programmed ships' ,
2020-03-31 20:34:24 +02:00
'HAI_I_7_REQUISITI' : 'FIRST STEPS OK!\nYou have the First 7 Requirements to Enter the Boarding List!' ,
'NON_HAI_I_7_REQUISITI' : 'Attention!\nYou still do not have the 7 requirements to enter the boarding list!' ,
'INFO_LA_MIA_LAVAGNA' : '✨ Step List: ✨ \n' ,
2020-05-11 22:43:14 +02:00
'INFO_LAVAGNA_SITO_COMPLETARE' : 'To complete all the requirements go to the site:%s\nTo see the status of your Ship and your guests\n👉🏻 <a href="%s">Dashboard</a>\n' ,
2021-12-23 14:13:40 +01:00
'INFO_LAVAGNA_SITO' : 'To see in detail the status of your ship, on the website, click on the 3 lines at the top left and go to "Blackboard".\n' ,
'INFO_LINK_DA_CONDIVIDERE' : 'Links to share with your guests to have them register on website:\n\n%s' ,
2020-04-24 10:29:25 +02:00
'INFO_LINK_ZOOM' : 'Links to share to participate in Zoom (Online Conference):\n%s' ,
2020-03-31 20:34:24 +02:00
'ZOOM_CONFERENCE' : 'Here you can find the Zoom Conference Planning:' ,
2021-10-05 15:39:44 +02:00
'NON_VERIF' : 'Not Verified' ,
'VERIF' : 'Verified' ,
'EMAIL' : 'Email' ,
2021-12-23 14:13:40 +01:00
'BOT' : 'BOT' ,
'EMAIL_NON_VERIF' : 'Email Not Verified\nread your mailbox and find **"Confirm Registration "**<br>and click on the button **"Verify Registration "**.' ,
2021-10-05 15:39:44 +02:00
'TELEGRAM_NOT_CONNECTED' : 'Telegram not associated with your account!' ,
2020-03-31 20:34:24 +02:00
'NESSUN_INVITATO' : 'You didn\'t invite anyone' ,
'ZOOM_PARTECIPATO' : 'Participation in at least 1 Conference (Zoom)' ,
'LINEE_GUIDA' : 'Guidelines Accepted' ,
2021-12-23 14:13:40 +01:00
'VIDEO_INTRO' : 'Seen the Video' ,
2020-03-31 20:34:24 +02:00
'SCRITTO_SOGNO' : 'You wrote your Dream' ,
2020-07-02 22:00:58 +02:00
'PAYMENTS' : 'Methods of Payment' ,
2020-03-31 20:34:24 +02:00
'INVITATI' : 'registered people you invited' ,
'INVITATI_ATTIVI' : 'Guests with the 7 Requirements' ,
'NONREG' : 'Non-registered Guests' ,
'CLICCA_PER_ZOOM' : 'TO THE DAY AND TIME INDICATED, TO ENTER THE VIDEO-CONFERENCE, CLICK HERE' ,
'CLICCA_ENTRA' : 'CLICK HERE TO ENTER !' ,
'ZOOM_INIZIATO' : 'THIS CONFERENCE HAS BEGUN!' ,
'SCEGLI_VOCE' : 'choose a menu item:' ,
'INVITATI_LISTA' : 'Your Guests (in green with at least the first 7 requirements)' ,
'CIAO' : 'Hi' ,
'ADDED_TOLISTAINGRESSO' : 'You have been added to the List of people who will enter the Boarding List!' ,
'NO_PROG' : 'You are not currently on the boarding list.!' ,
'SEND_LINK_CHAT_DONATORI' : 'Hi %s!\nYour ship is finally sailing!\nEnter the Gift Chat by clicking here: %s' ,
2020-05-10 21:07:51 +02:00
'SEND_LINK_CHAT_SOGNATORE' : 'Hello %s!\nToday you become a Dreamer! 🎊🎊🎊 Enter the ship\'s Gift Chat {%s} by clicking here: %s' ,
'ENTRA_GIFT_CHAT' : 'Enter the ship\'s Gift Chat' ,
'DATA_PART_NAVE' : 'date of departure of the ship:' ,
2020-03-31 20:34:24 +02:00
'SOGNATORE' : 'DREAMER' ,
2020-05-13 01:32:27 +02:00
'INTERMEDIO' : 'Intermediate' ,
2020-03-31 20:34:24 +02:00
'MEDIATORE' : 'MEDIATOR' ,
'DONATORI' : 'DONOR' ,
'RITESSITURA' : 'RE-ENTER' ,
'NAVE COMPLETATA' : 'SHIP COMPLETED' ,
'Doni Effettuati' : 'Gifts Made' ,
'Tutor che affianchèra il Mediatore' : 'Tutor supporting the Mediator' ,
2020-07-02 22:00:58 +02:00
'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.' ,
2020-05-10 21:07:51 +02:00
'SPOSTATO' : 'You\'ve been moved to a New Ship !' ,
2020-03-31 20:34:24 +02:00
'Note' : 'Note' ,
'TEMPORANEA' : 'TEMPORARY' ,
'NAVE' : 'SHIP' ,
2020-04-07 14:34:29 +02:00
'MSG_SEND_FROM' : 'Msg sent by' ,
2020-09-04 00:06:49 +02:00
'ZOOM_CONFERMATO' : 'You have been confirmed to have seen the Welcome Video Conference!' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_AMICIZIA' : 'Richiesta d\'Amicizia da parte di %s' ,
'ACCETTATO_SUL_GRUPPO' : 'Sei stato accettato da %s a far parte del Gruppo %s' ,
2022-03-30 22:51:03 +02:00
'ACCETTATO_NOTIFICA_ADMINS' : 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_GRUPPO' : 'Richiesta di entrare nel Gruppo %s da parte di %s' ,
'RICHIESTA_BLOCCO_GRUPPO' : 'Richiesta di bloccare il Gruppo %s da parte di %s' ,
2020-03-31 20:34:24 +02:00
} ,
fr : {
2021-10-05 15:39:44 +02:00
'L\'Email è già stata Verificata' : 'Le courrier électronique a déjà été vérifié' ,
'Nuova Registrazione' : 'Nouvelle inscription' ,
'Effettuata una Nuova Registrazione' : 'Un nouvel enregistrement a été effectué' ,
'partecipanti' : 'participants' ,
'partecipanti a Pranzo' : 'partecipanti a Pranzo' ,
'partecipanti a Cena' : 'partecipanti a Cena' ,
2021-12-23 14:13:40 +01:00
'TESTO_ASSISTENZA' : 'Pour entrer sur le site:\n%s\n\n' +
'Vous avez oublié votre mot de passe pour accéder au site ?\nhttps://ayni.gifteconomy.app/requestresetpwd\n\n' ,
2021-10-05 15:39:44 +02:00
'BENVENUTO' : 'Bienvenue' ,
'TUE_NAVI' : 'Voici vos navires programmés' ,
2020-03-31 20:34:24 +02:00
'HAI_I_7_REQUISITI' : 'PREMIÈRES ÉTAPES OK!\nvous avez les 7 premiers Requis pour Entrer dans la liste d\'embarquement!' ,
'NON_HAI_I_7_REQUISITI' : '\'Attention!\nVous ne remplissez pas encore les 7 conditions pour figurer sur la liste d\'embarquement!' ,
2021-12-23 14:13:40 +01:00
'HAI_I_9_REQUISITI' : 'FÉLICITATIONS!\n!Vous avez franchi les 9 étapes de la conduite ! Merci d\'avoir aidé à se développer!' ,
2020-03-31 20:34:24 +02:00
'NON_HAI_I_9_REQUISITI' : 'N\'oubliez pas que vous pouvez aider le Mouvement à grandir et à se développer en partageant notre voyage avec tout le monde.!' ,
'INFO_LA_MIA_LAVAGNA' : '✨ Liste des étapes: ✨ \n' ,
2020-05-11 22:43:14 +02:00
'INFO_LAVAGNA_SITO_COMPLETARE' : 'Pour remplir toutes les conditions, rendez-vous sur le site:\n%s\nPour voir le statut de votre navire et de vos invités\n 👉🏻 <a href="%s">Tableau</a>.\n' ,
2021-12-23 14:13:40 +01:00
'INFO_LAVAGNA_SITO' : 'Pour voir en détail le statut de votre navire, sur le site, cliquez sur les 3 lignes en haut à gauche et allez sur "Tableau".\n' ,
'INFO_LINK_DA_CONDIVIDERE' : 'Liens à partager avec vos invités pour qu\'ils s\'inscrivent sur le site web:\n\n%s' ,
2020-04-24 10:29:25 +02:00
'INFO_LINK_ZOOM' : 'Liens à partager pour participer à Zoom (Conférence en ligne):\n%s' ,
2020-03-31 20:34:24 +02:00
'ZOOM_CONFERENCE' : 'Vous trouverez ici les dates de programmation sur Zoom:' ,
2021-10-05 15:39:44 +02:00
'NON_VERIF' : 'Non vérifié' ,
'VERIF' : 'Vérifié' ,
'EMAIL' : 'Courriel' ,
2021-12-23 14:13:40 +01:00
'BOT' : 'BOT' ,
'EMAIL_NON_VERIF' : 'Courriel non vérifié\nlisez votre boîte aux lettres et trouvez **"Confirmer l\'inscription "**<br>et cliquez sur le bouton **"Vérifier l\'inscription "**.' ,
2021-10-05 15:39:44 +02:00
'TELEGRAM_NOT_CONNECTED' : 'Télégramme non associé à votre compte!' ,
2020-03-31 20:34:24 +02:00
'NESSUN_INVITATO' : 'Vous n\'avez invité personne' ,
'ZOOM_PARTECIPATO' : 'Participation à au moins 1 conférence (Zoom)' ,
'LINEE_GUIDA' : 'Lignes directrices acceptées' ,
2021-12-23 14:13:40 +01:00
'VIDEO_INTRO' : 'Voir la vidéo' ,
2020-03-31 20:34:24 +02:00
'SCRITTO_SOGNO' : 'Vous avez écrit votre rêve' ,
2020-07-02 22:00:58 +02:00
'PAYMENTS' : 'Modes de paiement' ,
2020-03-31 20:34:24 +02:00
'INVITATI' : 'personnes inscrites que vous avez invitées' ,
'INVITATI_ATTIVI' : 'Invité avec les 7 exigences' ,
'NONREG' : 'Invités non enregistrés' ,
'CLICCA_PER_ZOOM' : 'AU JOUR ET À L\'HEURE INDIQUÉS, POUR ENTRER DANS LA VIDÉOCONFÉRENCE, CLIQUEZ ICI' ,
'CLICCA_ENTRA' : 'CLIQUEZ ICI POUR ENTRER !' ,
'ZOOM_INIZIATO' : 'CETTE CONFÉRENCE A COMMENCÉ!' ,
'SCEGLI_VOCE' : 'choisir une voix:' ,
'INVITATI_LISTA' : 'Vos invités (en vert avec au moins les 7 premières exigences)' ,
'CIAO' : 'Salut' ,
'ADDED_TOLISTAINGRESSO' : 'Vous avez été ajouté à la liste d\'embarquement !' ,
'NO_PROG' : 'Vous n\'êtes pas encore sur la liste d\'embarquement.!' ,
'SEND_LINK_CHAT_DONATORI' : 'Salut %s!\nVotre SHIP prend enfin la mer.!\nEntrez dans le Chat Cadeau en cliquant ici: %s' ,
2020-05-10 21:07:51 +02:00
'SEND_LINK_CHAT_SOGNATORE' : 'Bonjour %s !\nAujourd\'hui, vous devenez un Rêveur ! 🎊🎊🎊 Entrez dans le chat des cadeaux du navire {%s} en cliquant ici : %s' ,
'ENTRA_GIFT_CHAT' : 'Entrez dans le chat des cadeaux' ,
'DATA_PART_NAVE' : 'la date de départ du navire:' ,
2020-03-31 20:34:24 +02:00
'SOGNATORE' : 'Rêveur' ,
2020-05-13 01:32:27 +02:00
'INTERMEDIO' : 'Intermediaire' ,
2020-03-31 20:34:24 +02:00
'MEDIATORE' : 'Médiateur' ,
'DONATORI' : 'DONATEUR' ,
'RITESSITURA' : 'RETESSITURA' ,
'NAVE COMPLETATA' : 'NAVIRE COMPLÉTÉ' ,
'Doni Effettuati' : 'Don effectués' ,
'Tutor che affianchèra il Mediatore' : 'Le tuteur qui soutient le Mediateur' ,
2020-07-02 22:00:58 +02:00
'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' ,
2020-05-10 21:07:51 +02:00
'SPOSTATO' : 'Vous avez été transféré sur un nouveau navire !' ,
2020-03-31 20:34:24 +02:00
'Note' : 'Notes' ,
'TEMPORANEA' : 'TEMPORAIRE' ,
'NAVE' : 'NAVIRE' ,
2020-04-07 14:34:29 +02:00
'MSG_SEND_FROM' : 'Message envoyé par' ,
2020-09-04 00:06:49 +02:00
'ZOOM_CONFERMATO' : 'Vous avez été confirmé comme ayant vu la vidéoconférence de bienvenue !' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_AMICIZIA' : 'Richiesta d\'Amicizia da parte di %s' ,
'ACCETTATO_SUL_GRUPPO' : 'Sei stato accettato da %s a far parte del Gruppo %s' ,
2022-03-30 22:51:03 +02:00
'ACCETTATO_NOTIFICA_ADMINS' : 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_GRUPPO' : 'Richiesta di entrare nel Gruppo %s da parte di %s' ,
'RICHIESTA_BLOCCO_GRUPPO' : 'Richiesta di bloccare il Gruppo %s da parte di %s' ,
2020-03-31 20:34:24 +02:00
} ,
pt : {
2021-10-05 15:39:44 +02:00
'L\'Email è già stata Verificata' : '' ,
'Nuova Registrazione' : 'Novo Registo' ,
'Effettuata una Nuova Registrazione' : 'Foi efectuado um novo registo' ,
'partecipanti' : 'participantes' ,
'partecipanti a Pranzo' : 'partecipanti a Pranzo' ,
'partecipanti a Cena' : 'partecipanti a Cena' ,
2021-12-23 14:13:40 +01:00
'TESTO_ASSISTENZA' : 'Para entrar no site:\n%s\n\n' +
'Esqueceu sua senha para acessar o site?\nhttps://freeplanet.app/requestresetpwd\n\n' ,
2021-10-05 15:39:44 +02:00
'BENVENUTO' : 'Bem-vindo' ,
'TUE_NAVI' : 'Aqui estão os seus navios programados' ,
2020-05-04 19:34:41 +02:00
'HAI_I_7_REQUISITI' : 'PRIMEIROS PASSOS OK!\nVocê tem os 7 primeiros requisitos para entrar na lista de embarque!' ,
'NON_HAI_I_7_REQUISITI' : 'Atenção!\nVocê ainda não tem os 7 requisitos para entrar na lista de embarque!' ,
'INFO_LA_MIA_LAVAGNA' : '✨ Lista de etapas: ✨ \n' ,
2020-05-11 22:43:14 +02:00
'INFO_LAVAGNA_SITO_COMPLETARE' : 'Para completar todos os requisitos ir para o sitio:\n%s\nPara ver o estado do seu navio e dos seus convidados:\n 👉🏻 <a href="%s">Entre no seu Tablero</a>.\n' ,
2021-12-23 14:13:40 +01:00
'INFO_LAVAGNA_SITO' : 'Para ver em detalhe o estado do seu navio, no site, clique nas 3 linhas no canto superior esquerdo e vá para "DashBoard"..\n' ,
'INFO_LINK_DA_CONDIVIDERE' : 'Links para partilhar com os seus convidados para que se registem no website:\n\n%s' ,
2020-05-04 19:34:41 +02:00
'INFO_LINK_ZOOM' : 'Links para partilhar para participar na Zoom (Conferência Online):\n%s' ,
'ZOOM_CONFERENCE' : 'Aqui está o programa das Conferências (Zoom) aberto a TODOS:' ,
2021-10-05 15:39:44 +02:00
'NON_VERIF' : 'Não verificado' ,
'VERIF' : 'Verificado' ,
'EMAIL' : 'Email' ,
2021-12-23 14:13:40 +01:00
'BOT' : 'BOT' ,
'EMAIL_NON_VERIF' : 'Email Não verificado\nleia a sua caixa de correio e encontre **"Confirmar o registo"**<br>e clique no botão **"Verificação do registo"**' ,
2021-10-05 15:39:44 +02:00
'TELEGRAM_NOT_CONNECTED' : 'Telegrama não associado à sua conta!' ,
2020-05-04 19:34:41 +02:00
'NESSUN_INVITATO' : 'Você não convidou ninguém' ,
'ZOOM_PARTECIPATO' : 'Participação em pelo menos 1 Conferência (Zoom)' ,
'LINEE_GUIDA' : 'Directrizes Aceites' ,
2021-12-23 14:13:40 +01:00
'VIDEO_INTRO' : 'Ver o vídeo' ,
2020-05-04 19:34:41 +02:00
'SCRITTO_SOGNO' : 'Você escreveu o seu sonho' ,
2020-07-02 22:00:58 +02:00
'PAYMENTS' : 'Formas de pagamento' ,
2020-05-04 19:34:41 +02:00
'INVITATI' : 'pessoas registadas que convidou' ,
'INVITATI_ATTIVI' : 'Convidado com os 7 Requisitos' ,
'NONREG' : 'Convidados não registados' ,
'CLICCA_PER_ZOOM' : 'PARA O DIA E HORA INDICADOS, PARA ENTRAR NA VÍDEO-CONFERÊNCIA, CLIQUE AQUI' ,
'CLICCA_ENTRA' : 'CLIQUE AQUI PARA ENTRAR !' ,
'ZOOM_INIZIATO' : 'ESTA CONFERÊNCIA JÁ COMEÇOU!' ,
'SCEGLI_VOCE' : 'escolha uma voz:' ,
'INVITATI_LISTA' : 'Os seus convidados (em verde com, pelo menos, os 7 primeiros requisitos)' ,
'CIAO' : 'Olá' ,
'ADDED_TOLISTAINGRESSO' : 'Foi acrescentado à Lista de Embarque !' ,
'NO_PROG' : 'Actualmente, ainda não consta da lista de embarque.!' ,
'SEND_LINK_CHAT_DONATORI' : 'Olà %s!\nO seu SHIP está finalmente a zarpar.!\nEntre no Gift Chat, clicando aqui: %s' ,
2020-05-10 21:07:51 +02:00
'SEND_LINK_CHAT_SOGNATORE' : 'Olá %s!\nHoje você se torna um sonhador! 🎊🎊🎊 Entre no Gift Chat do navio {%s} clicando aqui: %s' ,
'ENTRA_GIFT_CHAT' : 'Entre no Gift Chat do navio' ,
'DATA_PART_NAVE' : 'data de partida do navio:' ,
2020-03-31 20:34:24 +02:00
'SOGNATORE' : 'SONHEIROS' ,
2020-05-13 01:32:27 +02:00
'INTERMEDIO' : 'Intermediar' ,
2020-03-31 20:34:24 +02:00
'MEDIATORE' : 'MEDIATOR' ,
'DONATORI' : 'DONATORES' ,
'RITESSITURA' : 'ENTRE EM' ,
'NAVE COMPLETATA' : 'NAVIO COMPLETADO' ,
'Doni Effettuati' : 'Regalo Feitos' ,
'Tutor che affianchèra il Mediatore' : 'Tutor que apoia o Mediator' ,
2020-07-02 22:00:58 +02:00
'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.' ,
2020-05-10 21:07:51 +02:00
'SPOSTATO' : 'Você foi transferido para um novo navio !' ,
2020-03-31 20:34:24 +02:00
'Note' : 'Notas' ,
'TEMPORANEA' : 'TEMPORÁRIO' ,
'NAVE' : 'NAVE' ,
2020-04-07 14:34:29 +02:00
'MSG_SEND_FROM' : 'Mensagem enviada por' ,
2020-09-04 00:06:49 +02:00
'ZOOM_CONFERMATO' : 'Foi-lhe confirmado que assistiu à Conferência de Vídeo de Boas-vindas!' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_AMICIZIA' : 'Richiesta d\'Amicizia da parte di %s' ,
'ACCETTATO_SUL_GRUPPO' : 'Sei stato accettato da %s a far parte del Gruppo %s' ,
2022-03-30 22:51:03 +02:00
'ACCETTATO_NOTIFICA_ADMINS' : 'l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)' ,
2022-03-06 00:48:33 +01:00
'RICHIESTA_GRUPPO' : 'Richiesta di entrare nel Gruppo %s da parte di %s' ,
'RICHIESTA_BLOCCO_GRUPPO' : 'Richiesta di bloccare il Gruppo %s da parte di %s' ,
2020-03-31 20:34:24 +02:00
} ,
2020-01-20 01:48:25 +01:00
} ;
2018-12-24 20:31:02 +01:00
module . exports = {
2021-04-30 01:31:12 +02:00
MYAPPS : [ ] ,
2019-10-28 16:01:28 +01:00
INITDB _FIRSTIME : true ,
2020-02-19 16:09:16 +01:00
ACAPO : '\n' ,
2019-10-28 16:01:28 +01:00
2020-05-19 00:18:13 +02:00
ENABLE _CRONTAB : 'CRONTAB' ,
2020-06-08 13:31:05 +02:00
UPDATE _GRADUATORIA : 'UPDATE_GRAD' ,
2020-05-19 00:18:13 +02:00
2020-01-03 01:52:49 +01:00
LANGADMIN : 'it' ,
2021-12-23 14:13:40 +01:00
FREEPLANET : '1' ,
2020-02-19 16:09:16 +01:00
AYNI : '7' ,
2021-02-24 04:48:31 +01:00
CNM : '10' ,
2022-01-07 01:18:01 +01:00
PDNM : '12' ,
2022-03-02 20:18:29 +01:00
RISO : '13' ,
2020-02-19 16:09:16 +01:00
2021-12-23 14:13:40 +01:00
HELP _CHAT : '' ,
2020-07-02 22:00:58 +02:00
TYPECONF _ZOOM : 'zoom' ,
TYPECONF _JITSI : 'jitsi' ,
2020-01-13 23:52:51 +01:00
APORTADOR _NONE : '------' ,
2022-01-16 23:21:03 +01:00
SEP : '|' ,
2019-04-07 21:24:27 +02:00
TYPE _PROJECT : 1 ,
TYPE _TODO : 2 ,
2020-03-10 21:44:14 +01:00
TipoMsg : {
SEND _LINK _CHAT _DONATORI : 1 ,
2020-03-25 09:25:31 +01:00
SEND _MSG : 2 ,
SEND _MSG _SINGOLO : 3 ,
2020-04-24 10:29:25 +02:00
SEND _TO _ALL : 10 ,
2020-06-08 13:31:05 +02:00
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 ,
2020-07-02 22:00:58 +02:00
SEND _MSG _DONO _NON _RICEVUTO : 1050 ,
2020-03-10 21:44:14 +01:00
} ,
2022-01-03 21:53:50 +01:00
Perm : {
PERM _NONE : 0 ,
PERM _FRIEND : 1 ,
PERM _ALL : 10 ,
} ,
2020-03-10 21:44:14 +01:00
Placca : {
DONATORI : 1 ,
TUTTI : 2 ,
2020-05-11 22:43:14 +02:00
STR _SOGNATORE : '<strong>Sognatore</strong>' ,
STR _MEDIATORE : '<strong>Mediatore</strong>' ,
STR _MEDIATORI : '<strong>Mediatori</strong>' ,
STR _DONATORI : '<strong>Donatori</strong>' ,
2020-03-10 21:44:14 +01:00
SOGNATORE : 'E1 🌈 ' ,
MEDIATORE : 'A1 💦 ' ,
SONOFUOCO : 0 ,
SONOACQUA : 3 ,
2020-03-21 10:28:26 +01:00
SONOTERRA : 2 ,
SONOARIA : 1 ,
2020-03-10 21:44:14 +01:00
} ,
2019-11-05 23:53:39 +01:00
FieldType : {
boolean : 1 ,
date : 2 ,
string : 4 ,
binary : 8 ,
html : 16 ,
select : 32 ,
number : 64 ,
typeinrec : 128 ,
2019-11-12 21:34:03 +01:00
multiselect : 256 ,
2019-12-04 02:03:44 +01:00
password : 512 ,
2019-12-27 12:41:39 +01:00
listimages : 1024 ,
2020-04-07 14:34:29 +02:00
exact : 2048 ,
2021-02-18 12:19:35 +01:00
image : 3000 ,
nationality : 4096 ,
intcode : 5000 ,
multioption : 6000 ,
onlydate : 7000 ,
2021-10-05 15:39:44 +02:00
hours : 8000 ,
2021-12-23 14:13:40 +01:00
crypted : 9000 ,
2019-11-05 23:53:39 +01:00
} ,
2019-04-07 21:24:27 +02:00
MAX _PHASES : 5 ,
2019-04-06 21:02:39 +02:00
FIRST _PROJ : '__PROJECTS' ,
EXECUTE _CALCPROJ : true ,
2019-10-13 20:44:05 +02:00
2020-01-20 01:48:25 +01:00
gettranslate ( text , lang ) {
try {
2021-10-05 15:39:44 +02:00
return textlang [ lang ] [ text ] ;
2020-01-21 01:37:15 +01:00
} catch ( e ) {
2021-10-05 15:39:44 +02:00
return textlang [ 'it' ] [ text ] ;
2020-01-20 01:48:25 +01:00
}
} ,
2020-03-31 20:34:24 +02:00
getlangbyres ( res ) {
// ++Todo: res estrarre la lingua
let lang = '' ;
try {
2021-10-05 15:39:44 +02:00
lang = res . lang ;
2020-03-31 20:34:24 +02:00
} catch ( e ) {
}
if ( ! lang ) {
lang = 'it' ;
}
2021-10-05 15:39:44 +02:00
return lang ;
2020-03-31 20:34:24 +02:00
} ,
get _ _ ( text , lang ) {
2020-01-20 01:48:25 +01:00
try {
2021-10-05 15:39:44 +02:00
return textlang [ lang ] [ text ] ;
2020-01-21 01:37:15 +01:00
} catch ( e ) {
2021-10-05 15:39:44 +02:00
return textlang [ 'it' ] [ text ] ;
2020-01-20 01:48:25 +01:00
}
} ,
getres _ _ ( text , res ) {
2020-04-07 14:34:29 +02:00
let lang = this . getlangbyres ( res ) ;
2020-01-20 01:48:25 +01:00
try {
2021-10-05 15:39:44 +02:00
return textlang [ lang ] [ text ] ;
2020-01-21 01:37:15 +01:00
} catch ( e ) {
2021-10-05 15:39:44 +02:00
return textlang [ 'it' ] [ text ] ;
2020-01-20 01:48:25 +01:00
}
} ,
2021-10-05 15:39:44 +02:00
getHostname : function ( ) {
return os . hostname ( ) ;
2019-02-07 00:52:48 +01:00
} ,
2021-10-05 15:39:44 +02:00
testing : function ( ) {
return ( process . env . TESTING _ON === '1' ) ;
2019-02-07 00:52:48 +01:00
} ,
2021-10-05 15:39:44 +02:00
mylog : function ( ... args ) {
2019-02-07 00:52:48 +01:00
if ( ! this . testing ( ) )
2021-10-05 15:39:44 +02:00
console . log ( args ) ;
2019-02-07 00:52:48 +01:00
} ,
2021-10-05 15:39:44 +02:00
mylogoff : function ( ... args ) {
2019-02-11 02:59:05 +01:00
// doing nothing
} ,
2021-10-05 15:39:44 +02:00
mylogshow : function ( ... args ) {
console . log ( args ) ;
} ,
mylogserr : function ( ... args ) {
console . error ( args ) ;
} ,
allfieldSendMsg : function ( ) {
return [
'userId' ,
'source' ,
'dest' ,
'message' ,
'datemsg' ,
'read' ,
'deleted' ,
'origin' ,
'idapp' ,
'status' ,
'options' ] ;
} ,
allfieldTodo : function ( ) {
return [
'userId' ,
'pos' ,
'category' ,
'descr' ,
'note' ,
'priority' ,
'statustodo' ,
'assignedToUsers' ,
'created_at' ,
'groupId' ,
'modify_at' ,
'completed_at' ,
'expiring_at' ,
'enableExpiring' ,
'progress' ,
'modified' ,
'phase' ,
'assigned_to_userId' ,
'assignedToUsers' ,
'hoursplanned' ,
'hoursworked' ,
'start_date' ,
'themecolor' ,
'themebgcolor' ] ;
} ,
allfieldMyEvent : function ( ) {
return [ 'userId' ] ;
} ,
allfieldTodoWithId : function ( ) {
return [ '_id' , ... this . allfieldTodo ( ) ] ;
2019-02-12 12:06:25 +01:00
} ,
2019-03-28 12:58:58 +01:00
// #TODO Projects++ Add fields ...
2021-10-05 15:39:44 +02:00
allfieldProject : function ( ) {
return [
'idapp' ,
'userId' ,
'respUsername' ,
'viceRespUsername' ,
'pos' ,
'typeproj' ,
'id_main_project' ,
'id_parent' ,
'descr' ,
'longdescr' ,
'groupId' ,
'hoursplanned' ,
'hoursleft' ,
'themecolor' ,
'themebgcolor' ,
'hoursworked' ,
'priority' ,
'statusproj' ,
'created_at' ,
'modify_at' ,
'completed_at' ,
'expiring_at' ,
'enableExpiring' ,
'progressCalc' ,
'modified' ,
'live_url' ,
'test_url' ,
'begin_development' ,
'begin_test' ,
'totalphases' ,
'actualphase' ,
'hoursweeky_plannedtowork' ,
'endwork_estimate'
,
'privacyread' ,
'privacywrite' ,
'tipovisu' ,
'view' ] ;
} ,
allfieldBooking : function ( ) {
return [
'idapp' ,
'userId' ,
'id_bookedevent' ,
'numpeople' ,
'numpeopleLunch' ,
'numpeopleDinner' ,
'numpeopleDinnerShared' ,
'msgbooking' ,
'modified' ,
'infoevent' ,
'datebooked' ,
'booked' ] ;
} ,
allfieldBookingChange : function ( ) {
return [
'numpeople' ,
'numpeopleLunch' ,
'numpeopleDinner' ,
'numpeopleDinnerShared' ,
'msgbooking' ,
'modified' ,
'infoevent' ,
'datebooked' ,
'booked' ] ;
} ,
allfieldProjectWithId : function ( ) {
return [ '_id' , ... this . allfieldProject ( ) ] ;
2019-03-28 12:58:58 +01:00
} ,
jsonCopy ( src ) {
2021-10-05 15:39:44 +02:00
return JSON . parse ( JSON . stringify ( src ) ) ;
2019-03-28 12:58:58 +01:00
} ,
2019-10-21 20:38:10 +02:00
CloneRecordToNew ( src ) {
const myrec = Object . assign ( { } , src ) ;
delete myrec . _doc [ '_id' ] ;
myrec . _id = new ObjectID ( ) ;
2021-10-05 15:39:44 +02:00
return myrec . _doc ;
2019-10-21 20:38:10 +02:00
} ,
2021-10-05 15:39:44 +02:00
sendBackNotif : function ( subscription , payload ) {
2019-02-12 12:06:25 +01:00
2022-02-09 19:48:39 +01:00
// console.log('sendBackNotif:', subscription, payload);
2021-10-05 15:39:44 +02:00
const pushOptions = {
vapidDetails : {
subject : process . env . VAPI _KEY _SUBJECT ,
privateKey : process . env . PRIVATE _VAPI _KEY ,
publicKey : process . env . PUBLIC _VAPI _KEY ,
} ,
TTL : payload . ttl ,
2022-01-14 23:54:33 +01:00
headers : { } ,
2021-10-05 15:39:44 +02:00
} ;
2019-02-12 12:06:25 +01:00
// Pass object into sendNotification
2022-01-14 23:54:33 +01:00
return webpush . sendNotification ( subscription , JSON . stringify ( payload ) ,
pushOptions ) .
2021-10-05 15:39:44 +02:00
catch ( err => {
if ( err . statusCode === 410 ) {
// Gone: is not valid anymore (Expired probably!), so I have to delete from my db
return Subscription . findOneAndRemove ( { _id : subscription . _id } ) ;
} else {
console . log ( 'Subscription is no longer valid: ' , err ) ;
}
} ) .
then ( ris => {
// console.log('ris', ris)
} ) .
catch ( err => {
console . error ( err ) ;
} ) ;
2019-02-14 19:01:41 +01:00
} ,
2022-03-06 00:48:33 +01:00
sendNotificationToUser : function ( userId , title , content , openUrl , openUrl2 , tag , actions ) {
2019-02-14 19:01:41 +01:00
let payload = {
2020-04-24 10:29:25 +02:00
actions ,
2019-02-14 19:01:41 +01:00
title : title ,
2020-04-24 10:29:25 +02:00
content ,
2019-02-14 19:01:41 +01:00
url : openUrl ,
2020-04-24 10:29:25 +02:00
url2 : openUrl2 ,
2019-02-14 19:01:41 +01:00
tag ,
// ttl: req.body.ttl,
// icon: req.body.icon,
// image: req.body.image,
// badge: req.body.badge,
// tag: req.body.tag
} ;
2021-10-05 15:39:44 +02:00
return Subscription . find ( { userId } , ( err , subscriptions ) => {
2019-02-14 19:01:41 +01:00
if ( err ) {
console . error ( ` Error occurred while getting subscriptions ` ) ;
2020-04-10 13:02:33 +02:00
// res.status(500).json({
// error: 'Technical error occurred'
// });
//++ Rimuovi questo record !?
2019-02-14 19:01:41 +01:00
return false ;
} else {
2020-01-20 01:48:25 +01:00
let conta = 0 ;
2019-02-14 19:01:41 +01:00
let parallelSubscriptionCalls = subscriptions . map ( ( subscription ) => {
2020-01-20 01:48:25 +01:00
const trovati = subscriptions . length ;
2019-02-14 19:01:41 +01:00
return new Promise ( ( resolve , reject ) => {
const pushSubscription = {
endpoint : subscription . endpoint ,
keys : {
p256dh : subscription . keys . p256dh ,
2021-10-05 15:39:44 +02:00
auth : subscription . keys . auth ,
} ,
2019-02-14 19:01:41 +01:00
} ;
conta ++ ;
const parse = require ( 'url-parse' ) ;
const parsedUrl = parse ( subscription . endpoint ) ;
const audience = parsedUrl . protocol + '//' + parsedUrl . hostname ;
const vapidHeaders = webpush . getVapidHeaders (
2021-10-05 15:39:44 +02:00
audience ,
process . env . VAPI _KEY _SUBJECT ,
process . env . PUBLIC _VAPI _KEY ,
process . env . PRIVATE _VAPI _KEY ,
'aes128gcm' ,
2019-02-14 19:01:41 +01:00
) ;
const pushOptions = {
vapidDetails : {
2021-09-22 01:13:41 +02:00
subject : process . env . VAPI _KEY _SUBJECT ,
2019-02-14 19:01:41 +01:00
privateKey : process . env . PRIVATE _VAPI _KEY ,
publicKey : process . env . PUBLIC _VAPI _KEY ,
} ,
TTL : payload . ttl ,
2021-10-05 15:39:44 +02:00
headers : vapidHeaders ,
2019-02-14 19:01:41 +01:00
} ;
2021-10-05 15:39:44 +02:00
console . log ( '************ INVIO WEBPUSH.SENDNOTIFICATION N° ' ,
conta , '/' , trovati , 'A' , subscription . browser ) ;
2019-02-14 19:01:41 +01:00
const pushPayload = JSON . stringify ( payload ) ;
webpush . sendNotification (
2021-10-05 15:39:44 +02:00
pushSubscription ,
pushPayload ,
pushOptions ,
2019-02-14 19:01:41 +01:00
) . then ( ( value ) => {
2021-09-28 23:46:14 +02:00
// console.log('Invio Push', value);
2019-02-14 19:01:41 +01:00
resolve ( {
status : true ,
endpoint : subscription . endpoint ,
2021-10-05 15:39:44 +02:00
data : value ,
2019-02-14 19:01:41 +01:00
} ) ;
2022-02-22 18:27:59 +01:00
} ) . catch ( async ( err ) => {
2021-10-05 15:39:44 +02:00
console . error ( 'err Push' , err . body ) ;
2022-02-22 18:27:59 +01:00
// Cancella dal DB la notifica Push, visto che da errore! (sarà scaduto)
2022-02-24 19:13:20 +01:00
const ris = await Subscription . deleteOne ( { _id : subscription . _id } ) ;
2022-02-22 18:27:59 +01:00
2019-02-14 19:01:41 +01:00
reject ( {
status : false ,
endpoint : subscription . endpoint ,
2021-10-05 15:39:44 +02:00
data : err ,
2019-02-14 19:01:41 +01:00
} ) ;
} ) ;
} ) . catch ( error => {
2022-03-08 01:01:20 +01:00
console . log ( 'ERROR: sendNotificationToUser' , error . data . body ? error . data . body : error ) ;
2019-02-14 19:01:41 +01:00
} ) ;
} ) ;
// q.allSettled(parallelSubscriptionCalls).then((pushResults) => {
// console.info(pushResults);
// });
// res.json({
// data: 'Push triggered'
// });
return true ;
}
} ) ;
2019-02-12 12:06:25 +01:00
2019-02-27 02:59:02 +01:00
} ,
2022-01-14 23:54:33 +01:00
2022-03-11 12:38:01 +01:00
sendNotificationByUsername : async function ( idapp , username , cmd , telegram , usernameOrig ) {
2022-01-14 23:54:33 +01:00
var { User } = require ( '../models/user' ) ;
2022-03-11 12:38:01 +01:00
const telegrambot = require ( '../telegram/telegrambot' ) ;
const user = await User . findOne ( { idapp , username } , { _id : 1 , username : 1 , lang : 1 } ) . lean ( ) ;
2022-01-14 23:54:33 +01:00
if ( ! user )
return ;
let userId = user . _id ;
let lang = user . lang ;
2022-03-11 12:38:01 +01:00
let sendnotif = true ;
2022-01-14 23:54:33 +01:00
let title = this . getNomeAppByIdApp ( idapp ) ;
let descr = '' ;
let openUrl = '/' ;
let tag = '' ;
let actions = [ ] ;
if ( cmd ) {
if ( cmd === shared _consts . FRIENDSCMD . REQFRIEND ) {
2022-02-14 15:38:34 +01:00
descr = printf ( this . get _ _ ( 'RICHIESTA_AMICIZIA' , lang ) , usernameOrig ) ;
openUrl = '/my/' + usernameOrig ;
2022-01-14 23:54:33 +01:00
tag = 'reqfriends' ;
2022-03-11 12:38:01 +01:00
const userrecDest = await User . getUserShortDataByUsername ( idapp , usernameOrig ) ;
if ( userrecDest ) {
sendnotif = false ; // non lo rimandare 2 volte !
telegrambot . askConfirmationUserFriend ( idapp , shared _consts . CallFunz . RICHIESTA _AMICIZIA , userrecDest , username , usernameOrig ) ;
}
2022-01-14 23:54:33 +01:00
}
}
if ( userId ) {
2022-02-08 23:14:08 +01:00
this . sendNotificationToUser ( userId , title , descr , openUrl , '' , tag ,
actions ) ;
2022-01-14 23:54:33 +01:00
}
2022-03-11 12:38:01 +01:00
if ( telegram && sendnotif ) {
2022-01-14 23:54:33 +01:00
const idtelegram = await User . TelegIdByUsername ( idapp , username ) ;
await telegrambot . sendMsgTelegramByIdTelegram ( idapp , idtelegram , descr ) ;
}
} ,
2022-03-06 00:48:33 +01:00
sendNotifAndMsgTelegram : async function ( idapp , userId , objmsg , telegram , msgextrateleg ) {
if ( userId ) {
this . sendNotificationToUser ( userId , objmsg . title , objmsg . descr , objmsg . openUrl , '' , objmsg . tag , objmsg . actions ) ;
}
if ( telegram ) {
var { User } = require ( '../models/user' ) ;
const telegrambot = require ( '../telegram/telegrambot' ) ;
const idtelegram = await User . TelegIdById ( idapp , userId ) ;
const msgteleg = objmsg . descr + ( msgextrateleg ? '\n' + msgextrateleg : '' )
await telegrambot . sendMsgTelegramByIdTelegram ( idapp , idtelegram , msgteleg ) ;
}
} ,
2022-03-30 22:51:03 +02:00
sendNotificationByGroupname : async function ( idapp , usernameOrig , groupname , cmd , telegram , username _action ) {
2022-02-03 00:33:15 +01:00
var { User } = require ( '../models/user' ) ;
var { MyGroup } = require ( '../models/mygroup' ) ;
2022-03-06 00:48:33 +01:00
const telegrambot = require ( '../telegram/telegrambot' ) ;
2022-02-08 23:14:08 +01:00
const group = await MyGroup . findOne ( { idapp , groupname } ,
{ _id : 1 , admins : 1 } ) ;
2022-02-03 00:33:15 +01:00
if ( ! group )
return ;
// Send msg to Admins
const arrusernameAdmins = group . admins ;
2022-03-06 00:48:33 +01:00
const myuser = await User . findOne ( { idapp , username : usernameOrig } ) . lean ( ) ;
let struserinfomsg = this . getUserInfoMsg ( idapp , myuser ) ;
let objmsg = {
title : this . getNomeAppByIdApp ( idapp ) ,
descr : '' ,
openUrl : '/' ,
tag : '' ,
actions : [ ] ,
} ;
for ( const singleadmin of arrusernameAdmins ) {
2022-02-05 23:28:15 +01:00
try {
2022-03-06 00:48:33 +01:00
if ( singleadmin . username ) {
const user = await User . findOne ( { idapp , username : singleadmin . username } ,
2022-02-05 23:28:15 +01:00
{ _id : 1 , lang : 1 } ) ;
if ( user ) {
let userId = user . _id ;
let lang = user . lang ;
2022-03-06 00:48:33 +01:00
let sendnotif = true ;
2022-02-05 23:28:15 +01:00
if ( cmd ) {
2022-03-06 00:48:33 +01:00
if ( cmd === shared _consts . GROUPSCMD . SETGROUP ) {
2022-03-30 22:51:03 +02:00
objmsg . descr = printf ( this . get _ _ ( 'ACCETTATO_NOTIFICA_ADMINS' , lang ) , usernameOrig , groupname , username _action ) ;
2022-03-06 00:48:33 +01:00
objmsg . openUrl = '/grp/' + groupname ;
objmsg . tag = 'addgroups' ;
} else if ( cmd === shared _consts . GROUPSCMD . REQGROUP ) {
objmsg . descr = printf ( this . get _ _ ( 'RICHIESTA_GRUPPO' , lang ) , groupname ,
singleadmin . username ) ;
objmsg . openUrl = '/grp/' + groupname ;
objmsg . tag = 'reqgroups' ;
sendnotif = false ; // non lo rimandare 2 volte !
2022-03-08 01:01:20 +01:00
telegrambot . askConfirmationUser ( idapp , shared _consts . CallFunz . RICHIESTA _GRUPPO , myuser , singleadmin . username , groupname , group . _id ) ;
2022-03-06 00:48:33 +01:00
2022-02-05 23:28:15 +01:00
} else if ( cmd === shared _consts . GROUPSCMD . BLOCK _USER ) {
2022-03-06 00:48:33 +01:00
objmsg . descr = printf ( this . get _ _ ( 'RICHIESTA_BLOCCO_GRUPPO' , lang ) ,
groupname , singleadmin . username ) ;
objmsg . openUrl = '/grp/' + groupname ;
objmsg . tag = 'blockgroups' ;
2022-02-05 23:28:15 +01:00
}
}
2022-03-06 00:48:33 +01:00
if ( sendnotif && objmsg . descr ) {
await this . sendNotifAndMsgTelegram ( idapp , userId , objmsg , telegram , struserinfomsg ) ;
2022-02-05 23:28:15 +01:00
}
2022-03-06 00:48:33 +01:00
2022-02-05 23:28:15 +01:00
}
2022-02-03 00:33:15 +01:00
}
2022-02-08 23:14:08 +01:00
} catch ( e ) {
2022-02-05 23:28:15 +01:00
console . error ( 'sendNotificationByGroupname' , e ) ;
2022-02-03 00:33:15 +01:00
}
}
2022-03-06 00:48:33 +01:00
if ( cmd === shared _consts . GROUPSCMD . SETGROUP ) {
const reclang = await User . getRecLangAndIdByUsername ( idapp , usernameOrig ) ;
2022-03-30 22:51:03 +02:00
objmsg . descr = printf ( this . get _ _ ( 'ACCETTATO_SUL_GRUPPO' , reclang . lang ) , username _action , groupname ) ;
2022-03-06 00:48:33 +01:00
objmsg . openUrl = '/grp/' + groupname ;
objmsg . tag = 'addgroups' ;
// Send to User:
await this . sendNotifAndMsgTelegram ( idapp , reclang . _id , objmsg , telegram ) ;
}
2022-02-03 00:33:15 +01:00
} ,
2019-02-27 02:59:02 +01:00
// **********************
// SORT WITH PREV_ID
// **********************
2021-02-03 01:33:30 +01:00
/ * m a p S o r t : f u n c t i o n ( l i n k e d L i s t ) {
2019-04-20 13:59:07 +02:00
let sortedList = [ ] ;
let remainingList = [ ] ;
2019-02-27 02:59:02 +01:00
var map = new Map ( ) ;
var currentId = null ;
// console.log('linkedList', linkedList);
// index the linked list by previous_item_id
for ( var i = 0 ; i < linkedList . length ; i ++ ) {
var item = linkedList [ i ] ;
if ( item . id _prev === server _constants . LIST _START ) {
// first item
2021-02-03 01:33:30 +01:00
currentId = item . _id . toString ( ) ;
2019-02-27 02:59:02 +01:00
// console.log('currentId', currentId);
sortedList . push ( item ) ;
} else {
2021-02-03 01:33:30 +01:00
map . set ( item . id _prev . toString ( ) , i ) ;
2019-02-27 02:59:02 +01:00
}
}
2019-04-20 13:59:07 +02:00
let conta = 0 ;
while ( conta < linkedList . length ) {
2019-02-27 02:59:02 +01:00
// get the item with a previous item ID referencing the current item
var nextItem = linkedList [ map . get ( currentId ) ] ;
2019-04-13 03:04:49 +02:00
if ( nextItem === undefined ) {
2019-04-20 13:59:07 +02:00
} else {
sortedList . push ( nextItem ) ;
2021-02-03 01:33:30 +01:00
currentId = nextItem . _id . toString ( ) ;
2019-04-13 03:04:49 +02:00
}
2019-04-20 13:59:07 +02:00
conta ++ ;
2019-02-27 02:59:02 +01:00
}
2019-04-20 13:59:07 +02:00
if ( linkedList . length > sortedList . length ) {
// If are not in the list, I'll put at the bottom of the list
2019-04-22 01:43:58 +02:00
// console.log('ATTENZIONE !!! ', sortedList.length, linkedList.length);
2019-04-20 13:59:07 +02:00
for ( const itemlinked of linkedList ) {
const elemtrov = sortedList . find ( ( item ) => item . _id === itemlinked . _id ) ;
if ( elemtrov === undefined ) {
sortedList . push ( itemlinked ) ;
}
}
2019-04-13 03:04:49 +02:00
}
2019-02-27 02:59:02 +01:00
// console.log('DOPO sortedList', sortedList);
return sortedList ;
2019-10-05 20:01:56 +02:00
} ,
2021-02-03 01:33:30 +01:00
* /
2021-03-17 02:24:11 +01:00
sendNotifToAdmin ( title , msg , tag = '' ) {
2021-10-05 15:39:44 +02:00
const { User } = require ( '../models/user' ) ;
2021-02-03 01:33:30 +01:00
2021-04-30 01:31:12 +02:00
// console.log('nomeapp 1: ' , this.getNomeAppByIdApp(1));
// console.log('nomeapp 2: ' , this.getNomeAppByIdApp(2));
2021-03-17 02:24:11 +01:00
2021-10-05 15:39:44 +02:00
User . find ( { username : 'paoloar77' , idapp : '1' } ) . then ( ( arrusers ) => {
2021-03-17 02:24:11 +01:00
if ( arrusers !== null ) {
for ( const user of arrusers ) {
2021-10-05 15:39:44 +02:00
this . sendNotificationToUser ( user . _id , title , msg , '/' , '' , tag , [ ] ) .
then ( ris => {
if ( ris ) {
} else {
// already sent the error on calling sendNotificationToUser
}
} ) ;
2021-03-17 02:24:11 +01:00
}
}
} ) ;
} ,
2019-10-05 20:01:56 +02:00
2019-11-05 23:53:39 +01:00
checkUserOk ( userpassed , userauth , res ) {
2019-10-05 20:01:56 +02:00
this . mylog ( 'checkUserOk' , userpassed , userauth ) ;
if ( String ( userpassed ) !== String ( userauth ) ) {
// I'm trying to write something not mine!
2019-11-05 23:53:39 +01:00
this . mylog ( 'userId = ' , userpassed , 'req.user._id' , userauth ) ;
2021-10-05 15:39:44 +02:00
return {
exit : true ,
ret : res . status ( 404 ) .
send ( { code : server _constants . RIS _CODE _TODO _CREATING _NOTMYUSER } ) ,
} ;
2019-10-05 20:01:56 +02:00
} else {
2021-10-05 15:39:44 +02:00
return { exit : false , ret : false } ;
2019-10-05 20:01:56 +02:00
}
} ,
convertHTMLtoText ( myhtml ) {
let msg = myhtml ;
msg = msg . replace ( '"' , '"' ) ;
msg = msg . replace ( '>' , '>' ) ;
msg = msg . replace ( '<' , '<' ) ;
msg = msg . replace ( '&' , '&' ) ;
msg = msg . replace ( '<br>' , '\n' ) ;
2021-10-05 15:39:44 +02:00
return msg ;
2019-10-05 20:01:56 +02:00
} ,
2019-11-06 22:29:29 +01:00
convertTexttoHtml ( myhtml ) {
// let msg = myhtml;
// msg = msg.replace('\n', '<br>');
// return msg
return myhtml ;
} ,
2019-10-05 20:01:56 +02:00
removeSpecialCharForEmail ( myhtml ) {
let msg = myhtml ;
msg = msg . replace ( /"/g , '\'' ) ;
2021-10-05 15:39:44 +02:00
return msg ;
2019-10-05 20:01:56 +02:00
} ,
2021-10-05 15:39:44 +02:00
getNomeAppByIdApp : function ( idapp ) {
2019-10-05 20:01:56 +02:00
2019-10-16 15:28:49 +02:00
const myapp =
2021-10-05 15:39:44 +02:00
this . getApps ( ) . find ( item => item . idapp === idapp ) ;
2019-10-05 20:01:56 +02:00
if ( myapp )
2022-01-07 01:18:01 +01:00
return ( ( process . env . NODE _ENV === 'test' ) ? 'Test: ' : '' ) + myapp . name ;
2019-10-05 20:01:56 +02:00
else
return '' ;
} ,
2022-05-04 00:26:12 +02:00
getLinkRegByIdAppAndMsgStrutt : function ( idapp , msg ) {
let myapp = this . getHostByIdApp ( idapp ) ;
if ( myapp ) {
myapp += '/' + msg . from . username + '/' + msg . from . id ;
}
return myapp ;
} ,
2021-10-05 15:39:44 +02:00
getHostByIdApp : function ( idapp ) {
2019-10-16 15:28:49 +02:00
2022-02-27 16:56:02 +01:00
const myapp = this . getApps ( ) . find ( item => item . idapp === idapp ) ;
2019-10-16 15:28:49 +02:00
if ( myapp ) {
2022-01-14 23:54:33 +01:00
let siteport = ( myapp . portapp && myapp . portapp !== '0' ) ? ( ':' +
myapp . portapp ) : '' ;
2022-01-07 01:18:01 +01:00
if ( process . env . NODE _ENV === 'test' )
return myapp . host _test + siteport ;
else
return myapp . host + siteport ;
2019-10-16 15:28:49 +02:00
} else
return '' ;
} ,
2022-03-06 00:48:33 +01:00
getLinkUserProfile : function ( idapp , username ) {
2022-03-02 20:18:29 +01:00
return tools . getHostByIdApp ( idapp ) + '/my/' + username ;
} ,
2022-03-06 00:48:33 +01:00
getLinkEditUserProfile : function ( idapp ) {
2022-03-02 20:18:29 +01:00
return tools . getHostByIdApp ( idapp ) + '/editprofile' ;
} ,
2022-02-27 16:56:02 +01:00
getConfSiteOptionEnabledByIdApp : function ( idapp , option ) {
const myapp = this . getApps ( ) . find ( item => item . idapp === idapp ) ;
if ( myapp ) {
if ( myapp . hasOwnProperty ( 'confsite' ) ) {
if ( myapp . confsite . hasOwnProperty ( 'options' ) ) {
return this . isBitActive ( myapp . confsite . options , option ) ;
}
}
}
return false ;
} ,
getConfParamSiteByIdApp : function ( idapp , field ) {
const myapp = this . getApps ( ) . find ( item => item . idapp === idapp ) ;
if ( myapp ) {
if ( myapp . hasOwnProperty ( 'confsite' ) ) {
if ( myapp . confsite . hasOwnProperty ( field ) ) {
return myapp . confsite [ field ] ;
}
}
}
return false ;
} ,
2021-10-05 15:39:44 +02:00
isAbilitaNave : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( item => item . idapp === idapp ) ;
2020-03-10 21:44:14 +01:00
return myapp . abilitanave ;
} ,
2022-03-01 23:50:58 +01:00
getdirByIdApp : function ( idapp , dirmain = false ) {
2019-12-27 12:41:39 +01:00
2022-03-01 23:50:58 +01:00
let mypath = '' ;
2019-12-27 12:41:39 +01:00
const myapp =
2021-10-05 15:39:44 +02:00
this . getApps ( ) . find ( item => item . idapp === idapp ) ;
2019-12-27 12:41:39 +01:00
if ( myapp ) {
2022-01-07 01:18:01 +01:00
if ( process . env . NODE _ENV === 'test' )
2022-03-01 23:50:58 +01:00
mypath = ( myapp ) ? myapp . dir _test : '' ;
2022-01-07 01:18:01 +01:00
else
2022-03-01 23:50:58 +01:00
mypath = ( myapp ) ? myapp . dir : '' ;
if ( dirmain ) {
2022-03-02 20:18:29 +01:00
if ( ! this . sulServer ( ) ) {
2022-03-01 23:50:58 +01:00
mypath += '/public' ;
}
}
}
return mypath ;
2019-12-27 12:41:39 +01:00
} ,
2021-10-05 15:39:44 +02:00
getAdminEmailByIdApp : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
2019-10-05 20:01:56 +02:00
if ( myapp )
return myapp . adminemail ;
else
return '' ;
} ,
2021-10-05 15:39:44 +02:00
getreplyToEmailByIdApp : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
2019-10-16 15:28:49 +02:00
if ( myapp )
return myapp . replyTo ;
else
return '' ;
} ,
2021-10-05 15:39:44 +02:00
getpathregByIdApp : function ( idapp , lang ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
2021-09-22 01:13:41 +02:00
if ( myapp ) {
const addstr = myapp . pathreg _add ? myapp . pathreg _add : '' ;
return 'registration' + addstr + '/' + lang ;
} else {
return 'registration' + '/' + lang ;
}
2020-02-07 22:08:46 +01:00
} ,
2022-01-07 01:18:01 +01:00
getAskToVerifyReg : function ( idapp ) {
2022-05-04 00:26:12 +02:00
return this . getConfSiteOptionEnabledByIdApp ( idapp , shared _consts . ConfSite . Need _Aportador _On _DataReg _To _Verify _Reg ) ;
2022-01-07 01:18:01 +01:00
} ,
2019-10-16 15:28:49 +02:00
isManagAndAdminDifferent ( idapp ) {
2019-10-20 01:21:54 +02:00
const manag = this . getManagerEmailByIdApp ( idapp ) ;
return ( manag !== this . getAdminEmailByIdApp ( idapp ) ) && ( manag !== '' ) ;
2019-10-16 15:28:49 +02:00
} ,
2021-10-05 15:39:44 +02:00
getManagerEmailByIdApp : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
2019-10-16 15:28:49 +02:00
if ( myapp )
2021-04-30 01:31:12 +02:00
return ! ! myapp . manageremail ? myapp . manageremail : '' ;
2019-10-16 15:28:49 +02:00
else
return '' ;
} ,
2021-10-05 15:39:44 +02:00
getEmailByIdApp : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
2021-10-05 15:39:44 +02:00
return ( myapp ) ? myapp . email _from : '' ;
2020-01-03 01:52:49 +01:00
} ,
2021-10-05 15:39:44 +02:00
getPwdByIdApp : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
2021-10-05 15:39:44 +02:00
return ( myapp ) ? this . decryptdata ( myapp . email _pwd ) : '' ;
2020-01-03 01:52:49 +01:00
} ,
2021-10-05 15:39:44 +02:00
getTelegramBotNameByIdApp : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
2022-01-07 01:18:01 +01:00
if ( process . env . NODE _ENV === 'test' )
return ( myapp ) ? myapp . telegram _bot _name _test : '' ;
else
return ( myapp ) ? myapp . telegram _bot _name : '' ;
2020-01-03 01:52:49 +01:00
} ,
2022-02-25 17:24:31 +01:00
getTelegramSupportChat : function ( idapp ) {
try {
const myapp = this . getApps ( ) . find ( ( item ) => item . idapp === idapp ) ;
return ( myapp && myapp . telegram _support _chat )
? myapp . telegram _support _chat
: '' ;
2022-03-01 23:50:58 +01:00
} catch ( e ) {
2022-02-25 17:24:31 +01:00
return '' ;
}
} ,
2021-10-05 15:39:44 +02:00
getTelegramKeyByIdApp : function ( idapp ) {
2021-04-30 01:31:12 +02:00
const myarr = this . getApps ( ) ;
const myapp = myarr . find ( ( item ) => item . idapp === idapp ) ;
2022-01-07 01:18:01 +01:00
if ( process . env . NODE _ENV === 'test' )
return ( myapp ) ? myapp . telegram _key _test : '' ;
else
return ( myapp ) ? myapp . telegram _key : '' ;
2020-01-03 01:52:49 +01:00
} ,
2021-12-21 01:27:45 +01:00
getLookup : function ( params , num , pass _proj ) {
2022-01-14 23:54:33 +01:00
const query = [ ] ;
2021-12-21 01:27:45 +01:00
if ( ! params )
return ;
let mylkLF = params . lk _LF ;
if ( params . af _objId _tab ) {
2022-01-14 23:54:33 +01:00
const myobj = { } ;
2021-12-21 01:27:45 +01:00
myobj [ 'myId' + num ] = { '$toObjectId' : '$' + params . lk _LF } ;
query . push (
{ '$addFields' : myobj } ,
) ;
mylkLF = 'myId' + num ;
} else {
}
if ( params . lk _tab ) {
2022-01-14 23:54:33 +01:00
let proj = params . lk _proj ;
2021-12-21 01:27:45 +01:00
if ( ! ! pass _proj ) {
2022-01-14 23:54:33 +01:00
proj = pass _proj ;
2021-12-21 01:27:45 +01:00
}
query . push (
{
$lookup : {
from : params . lk _tab ,
localField : mylkLF , // field in my collection
foreignField : params . lk _FF , // field in the 'from' collection
as : params . lk _as ,
} ,
} ,
{
$replaceRoot : {
newRoot : {
$mergeObjects : [
{
$arrayElemAt : [
'$' + params . lk _as , 0 ] ,
} , '$$ROOT' ] ,
} ,
} ,
} ,
{ $project : proj } ,
) ;
}
return query ;
} ,
2022-02-12 02:20:07 +01:00
getFilterParam : function ( filter , fieldsearch ) {
let myregexp = { } ;
myregexp = new RegExp ( filter . trim ( ) . replace ( ' ' , '|' ) , 'ig' ) ;
let query = [ ] ;
const myfilters = [ ] ;
2022-02-24 19:13:20 +01:00
for ( const rec of fieldsearch ) {
2022-02-12 02:20:07 +01:00
let data = { } ;
if ( rec . type === this . FieldType . exact ) {
data [ rec . field ] = filter . trim ( ) ;
} else if ( rec . type === this . FieldType . string ) {
data [ rec . field ] = myregexp ;
} else if ( ( rec . type === this . FieldType . number ) ||
( rec . type === this . FieldType . hours ) ) {
data [ rec . field ] = parseFloat ( filter . trim ( ) ) ;
}
if ( data )
myfilters . push ( data ) ;
}
if ( myfilters . length > 0 ) {
query = [
{ $match : { $or : myfilters } } ,
] ;
}
return query ;
} ,
2021-12-11 00:25:54 +01:00
getQueryTable : function ( idapp , params ) {
2019-02-07 00:52:48 +01:00
2019-10-20 01:21:54 +02:00
if ( typeof params . startRow !== 'number' ) {
2021-10-05 15:39:44 +02:00
throw new Error ( 'startRow must be number' ) ;
2019-10-20 01:21:54 +02:00
} else if ( typeof params . endRow !== 'number' ) {
2021-10-05 15:39:44 +02:00
throw new Error ( 'endRow must be number' ) ;
2019-10-20 01:21:54 +02:00
}
2022-01-07 01:18:01 +01:00
let newvers = ! ! params . lookup1 ;
2021-12-21 01:27:45 +01:00
2019-10-28 16:01:28 +01:00
let query = [ ] ;
2021-12-21 01:27:45 +01:00
2019-10-28 16:01:28 +01:00
if ( params . filter && params . fieldsearch ) {
2022-02-12 02:20:07 +01:00
const querytemp = this . getFilterParam ( params . filter , params . fieldsearch ) ;
2022-02-24 19:13:20 +01:00
if ( querytemp ) {
query = [ ... query , ... querytemp ] ;
2022-02-12 02:20:07 +01:00
}
2019-10-28 16:01:28 +01:00
}
2020-02-02 04:06:32 +01:00
let filtriadded = [ ] ;
// if (params.table === 'extralist') {
// if (params.filterand.includes(shared_consts.FILTER_EXTRALIST_DELETED))
// filtriadded.push({ deleted: true });
// else
// filtriadded.push({ deleted: { $exists: false } });
// }
if ( params . filterand ) {
2021-10-05 15:39:44 +02:00
if ( params . filterand . includes (
shared _consts . FILTER _EXTRALIST _NOT _REGISTERED ) )
filtriadded . push ( { registered : false } ) ;
2020-02-02 04:06:32 +01:00
2021-10-05 15:39:44 +02:00
if ( params . filterand . includes (
shared _consts . FILTER _EXTRALIST _NOT _CONTACTED ) ) {
filtriadded . push ( { contacted : { $exists : false } } ) ;
2020-02-02 04:06:32 +01:00
}
if ( params . filterand . includes ( shared _consts . FILTER _EXTRALIST _WITH _NOTE ) )
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
'note' : { $exists : true } ,
'$expr' : { '$gt' : [ { '$strLenCP' : '$note' } , 1 ] } ,
2020-02-02 04:06:32 +01:00
} ) ;
2020-06-08 13:31:05 +02:00
if ( params . filterand . includes ( shared _consts . FILTER _QUALIFIED ) )
2021-10-05 15:39:44 +02:00
filtriadded . push ( { 'profile.qualified' : true } ) ;
2020-02-02 04:06:32 +01:00
if ( params . filterand . includes ( shared _consts . FILTER _USER _NO _ZOOM ) )
2021-10-05 15:39:44 +02:00
filtriadded . push ( { 'profile.saw_zoom_presentation' : false } ) ;
2020-09-04 00:06:49 +02:00
if ( params . filterand . includes ( shared _consts . FILTER _ASK _ZOOM _VISTO ) )
2021-10-05 15:39:44 +02:00
filtriadded . push ( { 'profile.ask_zoom_partecipato' : false } ) ;
2020-02-02 04:06:32 +01:00
if ( params . filterand . includes ( shared _consts . FILTER _USER _NO _INVITANTE ) )
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
aportador _solidario : { $exists : false } ,
2020-02-02 04:06:32 +01:00
} ) ;
if ( params . filterand . includes ( shared _consts . FILTER _USER _NO _TELEGRAM _ID ) )
2021-10-05 15:39:44 +02:00
filtriadded . push ( { 'profile.teleg_id' : { $lt : 1 } } ) ;
2022-03-08 01:01:20 +01:00
if ( params . filterand . includes ( shared _consts . FILTER _USER _SI _TELEGRAM _ID ) )
filtriadded . push ( { 'profile.teleg_id' : { $gt : 1 } } ) ;
2021-10-05 15:39:44 +02:00
if ( params . filterand . includes (
shared _consts . FILTER _USER _CODICE _AUTH _TELEGRAM ) )
filtriadded . push ( { 'profile.teleg_checkcode' : { $gt : 1 } } ) ;
2022-01-14 23:54:33 +01:00
if ( params . filterand . includes (
shared _consts . FILTER _USER _NO _EMAIL _VERIFICATA ) )
2021-10-05 15:39:44 +02:00
filtriadded . push ( { verified _email : false } ) ;
2022-03-08 01:01:20 +01:00
if ( params . filterand . includes ( shared _consts . FILTER _USER _NO _VERIFIED _APORTADOR ) )
2021-12-29 18:26:08 +01:00
filtriadded . push ( {
2022-03-10 23:19:56 +01:00
verified _by _aportador : { $exists : false } ,
2022-03-08 01:01:20 +01:00
} ) ;
if ( params . filterand . includes ( shared _consts . FILTER _USER _WITHOUT _USERNAME _TELEGRAM ) )
filtriadded . push ( {
$or : [
{ 'profile.username_telegram' : { $exists : false } } ,
{ 'profile.username_telegram' : { $exists : true , $eq : '' } } ] ,
2021-12-29 18:26:08 +01:00
} ) ;
2020-02-02 04:06:32 +01:00
if ( params . filterand . includes ( shared _consts . FILTER _USER _NO _DREAM ) )
filtriadded . push ( {
'profile.my_dream' : {
2021-10-05 15:39:44 +02:00
$exists : false ,
} ,
2020-02-02 04:06:32 +01:00
} ) ;
2020-02-19 16:09:16 +01:00
if ( params . filterand . includes ( shared _consts . FILTER _USER _TELEGRAM _BLOCKED ) )
2021-10-05 15:39:44 +02:00
filtriadded . push ( { 'profile.teleg_id_old' : { $gt : 1 } } ) ;
2020-05-19 00:18:13 +02:00
if ( params . filterand . includes ( shared _consts . FILTER _ATTIVI ) )
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
$or : [
{ deleted : { $exists : false } } ,
{ deleted : { $exists : true , $eq : false } } ] ,
2020-05-19 00:18:13 +02:00
} ) ;
2021-02-11 02:20:35 +01:00
// Hours
if ( params . filterand . includes ( shared _consts . FILTER _HOURS _ALL ) )
filtriadded . push (
2021-10-05 15:39:44 +02:00
{
idapp ,
todoId : params . codeId ,
$or : [
{ deleted : { $exists : false } } ,
{ deleted : { $exists : true , $eq : false } } ] ,
} ,
2021-02-11 02:20:35 +01:00
) ;
else if ( params . filterand . includes ( shared _consts . FILTER _HOURS _MYLIST ) )
filtriadded . push (
2021-10-05 15:39:44 +02:00
{
idapp ,
userId : params . userId ,
todoId : params . codeId ,
$or : [
{ deleted : { $exists : false } } ,
{ deleted : { $exists : true , $eq : false } } ] ,
} ,
2021-02-11 02:20:35 +01:00
) ;
2020-05-19 00:18:13 +02:00
if ( params . filterand . includes ( shared _consts . FILTER _NASCOSTI ) )
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
deleted : { $exists : true , $eq : true } ,
2020-05-19 00:18:13 +02:00
} ) ;
2020-06-08 13:31:05 +02:00
if ( params . filterand . includes ( shared _consts . FILTER _NAVI _NON _PRESENTI ) )
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
navinonpresenti : { $exists : true , $eq : true } ,
$or : [
{ subaccount : { $exists : false } } ,
{ subaccount : { $exists : true , $eq : false } } ] ,
2020-06-08 13:31:05 +02:00
} ) ;
2020-02-02 04:06:32 +01:00
2021-06-04 10:07:57 +02:00
// Iscritti Conacreis
if ( params . filterand . includes ( shared _consts . FILTER _MISSING _PAYMENT ) )
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
$or : [
{ ha _pagato : { $exists : false } } ,
{ ha _pagato : { $exists : true , $lt : 1 } } ] ,
2021-06-04 10:07:57 +02:00
} ) ;
2021-10-05 15:39:44 +02:00
if ( params . filterand . includes (
shared _consts . FILTER _TO _MAKE _MEMBERSHIP _CARD ) )
2021-06-04 10:07:57 +02:00
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
$or : [
{ codiceConacreis : { $exists : false } } ,
{ codiceConacreis : { $exists : true , $eq : '' } } ] ,
2021-06-04 10:07:57 +02:00
} ) ;
if ( params . filterand . includes ( shared _consts . FILTER _MEMBERSHIP _CARD _OK ) )
filtriadded . push ( {
2021-10-05 15:39:44 +02:00
codiceConacreis : { $exists : true } ,
'$expr' : { '$gt' : [ { '$strLenCP' : '$codiceConacreis' } , 0 ] } ,
2021-06-04 10:07:57 +02:00
} ) ;
2020-02-02 04:06:32 +01:00
}
2021-12-11 00:25:54 +01:00
if ( params . filtercustom ) {
2022-01-03 21:53:50 +01:00
for ( const myfilter of params . filtercustom ) {
2022-01-14 23:54:33 +01:00
if ( myfilter [ 'userId' ] ) {
myfilter [ 'userId' ] = ObjectID ( myfilter [ 'userId' ] ) ;
2022-01-03 21:53:50 +01:00
}
2022-02-08 23:14:08 +01:00
if ( myfilter [ '_idOBJ' ] ) {
filtriadded . push ( { _id : ObjectID ( myfilter [ '_idOBJ' ] ) } ) ;
2022-02-24 19:13:20 +01:00
} else if ( myfilter [ 'dateTimeStart' ] ) {
const gte = myfilter [ 'dateTimeStart' ] . $gte ;
const lte = myfilter [ 'dateTimeStart' ] . $lte ;
let condition = {
dateTimeStart : {
$gte : new Date ( gte ) ,
$lte : new Date ( lte ) ,
} ,
} ;
filtriadded . push ( condition ) ;
2022-02-08 23:14:08 +01:00
} else {
filtriadded . push ( myfilter ) ;
}
2022-01-03 21:53:50 +01:00
}
2021-12-11 00:25:54 +01:00
}
if ( params . filtersearch ) {
filtriadded . push ( ... params . filtersearch ) ;
}
2022-01-12 00:38:47 +01:00
if ( params . options ) {
2022-01-14 23:54:33 +01:00
if ( this . isBitActive ( params . options ,
shared _consts . OPTIONS _SEARCH _ONLY _FULL _WORDS ) ) {
2022-01-12 00:38:47 +01:00
}
}
2022-01-07 01:18:01 +01:00
if ( filtriadded ) {
if ( filtriadded . length > 0 )
query . push ( { $match : { $and : filtriadded } } ) ;
}
2020-02-02 04:06:32 +01:00
2019-10-28 16:01:28 +01:00
if ( idapp > 0 ) {
2021-10-05 15:39:44 +02:00
query . push ( { $match : { idapp } } ) ;
2019-10-28 16:01:28 +01:00
}
// console.log('QUERYMATCH', query[0].$match.or);
// console.log('filter', params.filter);
2019-02-15 01:38:01 +01:00
2019-10-20 01:21:54 +02:00
if ( params . sortBy ) {
// maybe we want to sort by blog title or something
2021-10-05 15:39:44 +02:00
const mysort = { $sort : params . sortBy } ;
2019-10-20 01:21:54 +02:00
// console.log('sortBy', params.sortBy);
// console.table(mysort);
2021-10-05 15:39:44 +02:00
query . push ( mysort ) ;
2019-10-20 01:21:54 +02:00
}
2020-01-30 01:19:25 +01:00
let numrowend = params . endRow - params . startRow ;
if ( numrowend < 0 )
numrowend = 1 ;
2022-02-08 23:14:08 +01:00
if ( params . querytype === shared _consts . QUERYTYPE _MYGROUP ) {
// query.push({'$addFields': {'myid': {'$toObjectId': params.myid}}});
/ * q u e r y . p u s h ( {
$match : {
$and : [
{ idapp } ,
{ '_id' : '$myid' } ,
] ,
} ,
} ) ;
* /
query . push ( {
$match : {
$expr : {
2022-02-25 19:21:04 +01:00
$eq : [ '$_id' , params . myid ] ,
2022-02-08 23:14:08 +01:00
} ,
} ,
} ) ;
query . push ( { $project : { req _users : 1 } } ) ;
const qa1 = this . getLookup (
{
lk _tab : 'users' ,
lk _LF : 'req_users.username' ,
lk _FF : 'username' ,
lk _as : 'user' ,
} , 0 , {
'user.idapp' : 1 ,
'user.username' : 1 ,
'user.profile.img' : 1 ,
'user.profile.qualifica' : 1 ,
} ) ;
if ( qa1 ) query = [ ... query , ... qa1 ] ;
query . push ( { $unwind : '$user' } ) ;
query . push ( {
$match : {
$and : [
{ 'user.idapp' : idapp } ,
] ,
} ,
} ) ;
query . push ( {
$replaceRoot : {
newRoot : '$user' ,
} ,
} ,
) ;
}
2021-12-21 01:27:45 +01:00
if ( newvers ) {
// NUOVA VERSIONE
let proj = params . lookup2 ? params . lookup2 . lk _proj : null ;
2022-02-08 23:14:08 +01:00
if ( params . proj0 ) {
query . push ( { $project : params . proj0 } ) ;
}
if ( params . unwind0 ) {
query . push ( { $unwind : params . unwind0 } ) ;
}
2021-12-21 01:27:45 +01:00
const q1 = this . getLookup ( params . lookup1 , 1 , proj ) ;
2022-01-14 23:54:33 +01:00
if ( q1 ) query = [ ... query , ... q1 ] ;
2021-12-21 01:27:45 +01:00
2022-02-08 23:14:08 +01:00
if ( params . unwind1 ) {
query . push ( { $unwind : params . unwind1 } ) ;
}
2021-12-21 01:27:45 +01:00
const q2 = this . getLookup ( params . lookup2 , 2 , proj ) ;
if ( q2 ) query = [ ... query , ... q2 ] ;
const q3 = this . getLookup ( params . lookup3 , 3 , proj ) ;
if ( q3 ) query = [ ... query , ... q3 ] ;
2021-12-31 01:44:28 +01:00
const q4 = this . getLookup ( params . lookup4 , 4 , proj ) ;
if ( q4 ) query = [ ... query , ... q4 ] ;
2022-01-20 00:39:06 +01:00
const q5 = this . getLookup ( params . lookup5 , 5 , proj ) ;
if ( q5 ) query = [ ... query , ... q5 ] ;
2022-01-07 01:18:01 +01:00
if ( params . filtersearch2 ) {
if ( params . filtersearch2 . length > 0 ) {
query . push ( { $match : { $and : params . filtersearch2 } } ) ;
}
2021-12-21 01:27:45 +01:00
}
2022-01-24 23:49:02 +01:00
if ( params . filtersearch3or ) {
if ( params . filtersearch3or . length > 0 ) {
query . push ( { $match : { $or : params . filtersearch3or } } ) ;
}
}
2021-12-21 01:27:45 +01:00
2022-02-25 12:01:34 +01:00
if ( params . filtersearch3and ) {
if ( params . filtersearch3and . length > 0 ) {
query . push ( { $match : { $and : params . filtersearch3and } } ) ;
}
}
2022-02-12 02:20:07 +01:00
if ( params . filter && params . fieldsearch _last ) {
2022-02-24 19:13:20 +01:00
const querytemp = this . getFilterParam ( params . filter ,
params . fieldsearch _last ) ;
if ( querytemp ) {
query = [ ... query , ... querytemp ] ;
2022-02-12 02:20:07 +01:00
}
}
2021-12-21 01:27:45 +01:00
} else {
// VECCHIA VERSIONE
const q1 = this . getLookup ( params , 1 ) ;
2022-01-14 23:54:33 +01:00
if ( q1 ) query = [ ... query , ... q1 ] ;
2021-02-11 02:20:35 +01:00
}
2019-10-20 01:21:54 +02:00
query . push (
2021-10-05 15:39:44 +02:00
{
$group : {
_id : null ,
// get a count of every result that matches until now
count : { $sum : 1 } ,
// keep our results for the next operation
results : { $push : '$$ROOT' } ,
} ,
} ,
// and finally trim the results to within the range given by start/endRow
{
$project : {
count : 1 ,
rows : { $slice : [ '$results' , params . startRow , numrowend ] } ,
} ,
} ,
2019-10-20 01:21:54 +02:00
) ;
2019-10-28 16:01:28 +01:00
2019-12-31 00:44:53 +01:00
// console.log('query', query);
2019-10-28 16:01:28 +01:00
return query ;
2019-10-20 01:21:54 +02:00
} ,
2021-02-24 04:48:31 +01:00
async executeQueryTable ( mythistable , idapp , params ) {
2019-10-20 01:21:54 +02:00
let query = this . getQueryTable ( idapp , params ) ;
2021-12-11 00:25:54 +01:00
try {
2021-12-21 01:27:45 +01:00
// console.log('query', query);
2021-12-11 00:25:54 +01:00
const [ ris ] = await mythistable . aggregate ( query ) ;
2021-02-24 04:48:31 +01:00
2021-12-11 00:25:54 +01:00
if ( ris ) {
// console.table(ris.rows);
// console.log('ROW ', ris.count);
return ( { count : ris . count , rows : ris . rows } ) ;
} else {
return ( { count : 0 , rows : [ ] } ) ;
}
} catch ( e ) {
console . log ( 'error' , e ) ;
2021-02-24 04:48:31 +01:00
}
2019-10-20 01:21:54 +02:00
2019-10-27 00:37:10 +02:00
} ,
2020-01-13 23:52:51 +01:00
async DuplicateAllRecords ( mythistable , idapporig , idappdest ) {
console . log ( mythistable . name ) ;
const numrec = await mythistable . findAllIdApp ( idappdest ) . then ( ( arrrec ) => {
if ( arrrec && arrrec . length > 1 ) {
return arrrec . length ; // Has Already set
} else {
return 0 ;
}
} ) ;
// Before check if exist more than 1 record in the destination,
// if Yes don't copy
if ( numrec <= 0 ) {
2022-02-12 22:12:49 +01:00
return mythistable . findAllIdApp ( idapporig ) . then ( async ( arrrec ) => {
2020-01-13 23:52:51 +01:00
let num = 0 ;
for ( let ind = 0 ; ind < arrrec . length ; ind ++ ) {
let newrec = new mythistable ( arrrec [ ind ] . _doc ) ;
newrec . _id = new ObjectID ( ) ;
newrec . idapp = idappdest ;
2022-02-12 22:12:49 +01:00
try {
await newrec . save ( ( err , rec ) => {
if ( rec ) {
num ++ ;
}
2020-01-13 23:52:51 +01:00
2022-02-12 22:12:49 +01:00
} ) ;
2022-02-24 19:13:20 +01:00
} catch ( e ) {
2022-02-12 22:12:49 +01:00
console . error ( 'e' , e ) ;
}
2020-01-13 23:52:51 +01:00
}
return num ;
} ) ;
}
} ,
2019-10-27 00:37:10 +02:00
isBitActive ( bit , whattofind ) {
2021-10-05 15:39:44 +02:00
return ( ( bit & whattofind ) === whattofind ) ;
2019-10-27 00:37:10 +02:00
} ,
2022-03-02 20:18:29 +01:00
isBitAttivoESelez ( bit , whattofind , loSono ) {
const abil = this . isBitActive ( bit , whattofind ) ;
return ( ( abil && loSono ) || ! abil ) ;
} ,
2019-10-27 00:37:10 +02:00
SetBit ( myval , bit ) {
myval = myval & bit ;
2021-10-05 15:39:44 +02:00
return myval ;
2019-11-05 23:53:39 +01:00
} ,
2019-10-27 00:37:10 +02:00
2020-02-19 16:09:16 +01:00
async snooze ( ms ) {
2019-11-21 00:18:40 +01:00
return new Promise ( resolve => setTimeout ( resolve , ms ) ) ;
} ,
IncDateNow ( secs ) {
let mydate = new Date ( new Date ( ) . getTime ( ) + secs ) ;
// console.log('mydate', mydate);
2021-10-05 15:39:44 +02:00
return mydate ;
2019-12-04 02:03:44 +01:00
} ,
2020-07-13 23:35:05 +02:00
isdiffSecDateLess ( mydatediffstr , secs ) {
let mydate = new Date ( ) ;
// console.log('mydate', mydate);
let mydata2 = new Date ( mydatediffstr ) ;
let ris = ( ( mydate . getTime ( ) - mydata2 . getTime ( ) ) / 1000 ) ;
return ( ris < secs ) ;
} ,
2020-03-21 10:28:26 +01:00
AddDate ( mydate , days ) {
let date = new Date ( mydate ) ;
date . setTime ( date . getTime ( ) + days * 86400000 ) ;
return date ;
} ,
2020-05-10 21:07:51 +02:00
isMonToSat ( ) {
const dayOfWeek = new Date ( new Date ( ) ) . getDay ( ) ;
2021-10-05 15:39:44 +02:00
return dayOfWeek >= 1 && dayOfWeek <= 6 ;
2020-05-10 21:07:51 +02:00
} ,
2020-09-04 00:06:49 +02:00
isMonToFri ( ) {
const dayOfWeek = new Date ( new Date ( ) ) . getDay ( ) ;
2021-10-05 15:39:44 +02:00
return dayOfWeek >= 1 && dayOfWeek <= 5 ;
2020-09-04 00:06:49 +02:00
} ,
2020-05-10 21:07:51 +02:00
// var startTime = '15:10:10';
// var endTime = '22:30:00';
isBetweenTwoTime ( startTime , endTime ) {
currentDate = new Date ( ) ;
startDate = new Date ( currentDate . getTime ( ) ) ;
2021-10-05 15:39:44 +02:00
startDate . setHours ( startTime . split ( ':' ) [ 0 ] ) ;
startDate . setMinutes ( startTime . split ( ':' ) [ 1 ] ) ;
startDate . setSeconds ( startTime . split ( ':' ) [ 2 ] ) ;
2020-05-10 21:07:51 +02:00
endDate = new Date ( currentDate . getTime ( ) ) ;
2021-10-05 15:39:44 +02:00
endDate . setHours ( endTime . split ( ':' ) [ 0 ] ) ;
endDate . setMinutes ( endTime . split ( ':' ) [ 1 ] ) ;
endDate . setSeconds ( endTime . split ( ':' ) [ 2 ] ) ;
2020-05-10 21:07:51 +02:00
valid = startDate < currentDate && endDate > currentDate ;
return valid ;
} ,
getlimiti ( mypos ) {
if ( mypos . col < 0 ) {
mypos . col = 0 ;
}
if ( mypos . riga < 0 ) {
mypos . riga = 0 ;
mypos . col = 0 ;
}
return mypos ;
} ,
2020-03-21 10:28:26 +01:00
getRigaColByPosUp ( mypos ) {
2020-03-25 18:26:51 +01:00
if ( mypos . numup > 0 ) {
mypos . riga = mypos . riga - mypos . numup ;
mypos . col = Math . ceil ( mypos . col / ( Math . pow ( 2 , mypos . numup ) ) ) ;
}
if ( mypos . numup < 0 ) {
mypos . riga = mypos . riga - mypos . numup ;
mypos . col = Math . ceil ( mypos . col * ( Math . pow ( 2 , - mypos . numup ) ) ) ;
}
2020-05-04 19:34:41 +02:00
if ( mypos . riga < 1 ) {
mypos . riga = 1 ;
}
if ( mypos . col < 1 ) {
mypos . col = 1 ;
}
2020-03-21 10:28:26 +01:00
} ,
2020-05-10 21:07:51 +02:00
getRigaColGenerica ( idapp , riga , col , numup ) {
mypos = {
idapp ,
riga ,
col ,
2021-10-05 15:39:44 +02:00
numup ,
2020-05-10 21:07:51 +02:00
} ;
2020-06-08 13:31:05 +02:00
if ( idapp === this . AYNI ) {
2020-05-10 21:07:51 +02:00
this . getRigaColByPosUp ( mypos ) ;
ris = this . getlimiti ( mypos ) ;
}
return ris ;
} ,
getRigaColSognatoreByDonatore ( idapp , riga , col ) {
return this . getRigaColGenerica ( idapp , riga , col , 6 ) ;
} ,
getRigaColMediatoreByFuoco ( idapp , riga , col ) {
return this . getRigaColGenerica ( idapp , riga , col , 3 ) ;
} ,
getRigaColSognatoreByMediatore ( idapp , riga , col ) {
return this . getRigaColGenerica ( idapp , riga , col , 3 ) ;
} ,
2020-01-21 01:37:15 +01:00
appendLeadingZeroes ( n ) {
if ( n <= 9 ) {
2021-10-05 15:39:44 +02:00
return '0' + n ;
2020-01-21 01:37:15 +01:00
}
2021-10-05 15:39:44 +02:00
return n ;
2020-01-21 01:37:15 +01:00
} ,
2020-07-02 22:00:58 +02:00
getWeekDayByLangByNumCar ( date , lang , num ) {
2020-05-04 19:34:41 +02:00
if ( ! lang )
lang = 'it' ;
const dayOfWeek = new Date ( date ) . getDay ( ) ;
const myday = {
2021-10-05 15:39:44 +02:00
it : [
'Domenica' ,
'Lunedì' ,
'Martedì' ,
'Mercoledì' ,
'Giovedì' ,
'Venerdì' ,
'Sabato' ] ,
enUs : [
'Sunday' ,
'Monday' ,
'Tuesday' ,
'Wednesday' ,
'Thursday' ,
'Friday' ,
'Saturday' ] ,
fr : [
'Dimanche' ,
'Lundi' ,
'Mardi' ,
'Mercredi' ,
'Jeudi' ,
'Vendredi' ,
'Samedi' ] ,
es : [
'Domingo' ,
'Lunes' ,
'Martes' ,
'Miércoles' ,
'Jueves' ,
'iernes' ,
'Sábado' ] ,
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' ] ,
2020-07-02 22:00:58 +02:00
} ;
if ( num > 0 ) {
2021-10-05 15:39:44 +02:00
return isNaN ( dayOfWeek ) ? '' : myday [ lang ] [ dayOfWeek ] . substring ( 0 , num ) ;
2020-07-02 22:00:58 +02:00
} else {
2021-10-05 15:39:44 +02:00
return isNaN ( dayOfWeek ) ? '' : myday [ lang ] [ dayOfWeek ] ;
2020-05-04 19:34:41 +02:00
}
2020-07-02 22:00:58 +02:00
} ,
2021-02-24 04:48:31 +01:00
isSunday ( mydate ) {
2021-10-05 15:39:44 +02:00
const dayOfWeek = new Date ( mydate ) . getDay ( ) ;
return dayOfWeek === 0 ;
2021-02-24 04:48:31 +01:00
} ,
isMonday ( mydate ) {
2021-10-05 15:39:44 +02:00
const dayOfWeek = new Date ( mydate ) . getDay ( ) ;
return dayOfWeek === 1 ;
2021-02-24 04:48:31 +01:00
} ,
2021-03-17 02:24:11 +01:00
isSundayDate ( mydate ) {
2021-10-05 15:39:44 +02:00
const dayOfWeek = mydate . getDay ( ) ;
return dayOfWeek === 0 ;
2021-03-17 02:24:11 +01:00
} ,
isMondayDate ( mydate ) {
2021-10-05 15:39:44 +02:00
const dayOfWeek = mydate . getDay ( ) ;
return dayOfWeek === 1 ;
2021-03-17 02:24:11 +01:00
} ,
2020-07-02 22:00:58 +02:00
getWeekDayByLang ( date , lang ) {
2021-10-05 15:39:44 +02:00
return this . getWeekDayByLangByNumCar ( date , lang , 3 ) ;
2020-07-02 22:00:58 +02:00
} ,
2020-05-04 19:34:41 +02:00
2020-07-02 22:00:58 +02:00
getWeekDayByLangTot ( date , lang ) {
2021-10-05 15:39:44 +02:00
return this . getWeekDayByLangByNumCar ( date , lang , 0 ) ;
2020-05-04 19:34:41 +02:00
} ,
2020-01-21 01:37:15 +01:00
getWeekDay ( date ) {
//Create an array containing each day, starting with Sunday.
const weekdays = [
2021-10-05 15:39:44 +02:00
'Domenica' ,
'Lunedì' ,
'Martedì' ,
'Mercoledì' ,
'Giovedí' ,
'Venerdì' ,
'Sabato' ,
2020-01-21 01:37:15 +01:00
] ;
//Use the getDay() method to get the day.
const day = date . getDay ( ) ;
//Return the element that corresponds to that index.
return weekdays [ day ] ;
} ,
2020-05-04 19:34:41 +02:00
getstrDateTimeShort ( mydate , lang ) {
2020-03-10 21:44:14 +01:00
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return this . getWeekDayByLang ( mydate , lang ) + ' ' +
this . appendLeadingZeroes ( mydate . getDate ( ) ) + '/' +
this . appendLeadingZeroes ( mydate . getMonth ( ) + 1 ) + ' ORE ' +
this . appendLeadingZeroes ( mydate . getHours ( ) ) + ':' +
this . appendLeadingZeroes ( mydate . getMinutes ( ) ) ;
2020-03-10 21:44:14 +01:00
} else {
return '' ;
}
} ,
2020-05-04 19:34:41 +02:00
getstrDateShort ( mydate , lang ) {
2020-03-10 21:44:14 +01:00
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return this . getWeekDayByLang ( mydate , lang ) . substring ( 0 , 3 ) + ' ' +
this . appendLeadingZeroes ( mydate . getDate ( ) ) + '/' +
this . appendLeadingZeroes ( mydate . getMonth ( ) + 1 ) ;
2020-03-10 21:44:14 +01:00
} else {
return '' ;
}
} ,
2021-06-04 10:07:57 +02:00
getstrDate _DD _MM _YYYY ( mydate ) {
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return this . appendLeadingZeroes ( mydate . getDate ( ) ) + '/' +
this . appendLeadingZeroes ( mydate . getMonth ( ) + 1 ) + '/' +
this . appendLeadingZeroes ( mydate . getFullYear ( ) ) ;
2021-06-04 10:07:57 +02:00
} else {
return '' ;
}
} ,
2021-02-24 04:48:31 +01:00
getstrDateYYYY _MM _DD ( mydate ) {
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return mydate . getFullYear ( ) + '-' +
this . appendLeadingZeroes ( mydate . getMonth ( ) + 1 ) + '-' +
this . appendLeadingZeroes ( mydate . getDate ( ) ) ;
2021-02-24 04:48:31 +01:00
} else {
return '' ;
}
} ,
2021-03-17 02:24:11 +01:00
getstrUTCDateYYYY _MM _DD ( mydate ) {
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return mydate . getUTCFullYear ( ) + '-' +
this . appendLeadingZeroes ( mydate . getUTCMonth ( ) + 1 ) + '-' +
this . appendLeadingZeroes ( mydate . getUTCDate ( ) ) ;
2021-03-17 02:24:11 +01:00
} else {
return '' ;
}
} ,
2020-05-04 19:34:41 +02:00
getstrDateLong ( mydate , lang ) {
2020-03-10 21:44:14 +01:00
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return this . getWeekDayByLang ( mydate , lang ) + ' ' +
this . appendLeadingZeroes ( mydate . getDate ( ) ) + '/' +
this . appendLeadingZeroes ( mydate . getMonth ( ) + 1 ) + '/' +
mydate . getFullYear ( ) ;
2020-03-10 21:44:14 +01:00
} else {
return '' ;
}
2020-01-21 01:37:15 +01:00
} ,
2020-07-02 22:00:58 +02:00
getstrDateLongTot ( mydate , lang ) {
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return this . getWeekDayByLangTot ( mydate , lang ) + ' ' +
this . appendLeadingZeroes ( mydate . getDate ( ) ) + '/' +
this . appendLeadingZeroes ( mydate . getMonth ( ) + 1 ) + '/' +
mydate . getFullYear ( ) ;
2020-07-02 22:00:58 +02:00
} else {
return '' ;
}
} ,
2020-06-08 13:31:05 +02:00
getstrDateLongFile ( mydate , lang ) {
if ( mydate ) {
// console.log('getstrDate', mytimestamp)
2021-10-05 15:39:44 +02:00
return mydate . getFullYear ( ) + '-' +
this . appendLeadingZeroes ( mydate . getMonth ( ) + 1 ) + '-' +
this . appendLeadingZeroes ( mydate . getDate ( ) ) + ' (' +
this . getWeekDayByLang ( mydate , lang ) + ')' ;
2020-06-08 13:31:05 +02:00
} else {
return '' ;
}
} ,
2020-07-02 22:00:58 +02:00
getlinkzoom ( rec ) {
if ( rec === null ) {
rec = {
typeconf : this . TYPECONF _ZOOM ,
id _conf _zoom : '' ,
2021-10-05 15:39:44 +02:00
} ;
2020-07-02 22:00:58 +02:00
}
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' ;
}
2021-10-05 15:39:44 +02:00
return mylink + rec . id _conf _zoom ;
2020-07-02 22:00:58 +02:00
2020-01-21 01:37:15 +01:00
} ,
2019-12-04 02:03:44 +01:00
getmd5 ( mystr ) {
return CryptoJS . MD5 ( mystr . toLowerCase ( ) ) . toString ( ) ;
} ,
getHash ( mystr ) {
2021-10-05 15:39:44 +02:00
return CryptoJS . SHA512 ( mystr , { outputLength : 256 } ) . toString ( ) ;
2019-12-04 02:03:44 +01:00
} ,
2020-01-03 01:52:49 +01:00
encrypt ( msg , pass ) {
var salt = CryptoJS . lib . WordArray . random ( 128 / 8 ) ;
var key = CryptoJS . PBKDF2 ( pass , salt , {
keySize : keySize / 32 ,
2021-10-05 15:39:44 +02:00
iterations : iterations ,
2020-01-03 01:52:49 +01:00
} ) ;
var iv = CryptoJS . lib . WordArray . random ( 128 / 8 ) ;
var encrypted = CryptoJS . AES . encrypt ( msg , key , {
iv : iv ,
padding : CryptoJS . pad . Pkcs7 ,
2021-10-05 15:39:44 +02:00
mode : CryptoJS . mode . CBC ,
2020-01-03 01:52:49 +01:00
} ) ;
// salt, iv will be hex 32 in length
// append them to the ciphertext for use in decryption
var transitmessage = salt . toString ( ) + iv . toString ( ) + encrypted . toString ( ) ;
return transitmessage ;
} ,
decrypt ( transitmessage , pass ) {
var salt = CryptoJS . enc . Hex . parse ( transitmessage . substr ( 0 , 32 ) ) ;
2021-10-05 15:39:44 +02:00
var iv = CryptoJS . enc . Hex . parse ( transitmessage . substr ( 32 , 32 ) ) ;
2020-01-03 01:52:49 +01:00
var encrypted = transitmessage . substring ( 64 ) ;
var key = CryptoJS . PBKDF2 ( pass , salt , {
keySize : keySize / 32 ,
2021-10-05 15:39:44 +02:00
iterations : iterations ,
2020-01-03 01:52:49 +01:00
} ) ;
var decrypted = CryptoJS . AES . decrypt ( encrypted , key , {
iv : iv ,
padding : CryptoJS . pad . Pkcs7 ,
2021-10-05 15:39:44 +02:00
mode : CryptoJS . mode . CBC ,
2020-01-03 01:52:49 +01:00
} ) ;
return decrypted ;
} ,
2019-12-04 02:03:44 +01:00
cryptdata ( mydata ) {
2022-01-07 01:18:01 +01:00
if ( mydata === '' )
return '' ;
2019-12-04 02:03:44 +01:00
// Encrypt
2020-01-03 01:52:49 +01:00
//return CryptoJS.AES.encrypt(JSON.stringify(mydata), process.env.SECRK);
return this . encrypt ( mydata , process . env . SECRK ) ;
2019-12-04 02:03:44 +01:00
} ,
decryptdata ( mydatacrypted ) {
2022-01-07 01:18:01 +01:00
if ( mydatacrypted === '' )
return '' ;
2019-12-04 02:03:44 +01:00
// Decrypt
2020-01-03 01:52:49 +01:00
// const bytes = CryptoJS.AES.decrypt(mydatacrypted.toString(), process.env.SECRK);
// return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
2021-10-05 15:39:44 +02:00
return this . decrypt ( mydatacrypted , process . env . SECRK ) .
toString ( CryptoJS . enc . Utf8 ) ;
2019-12-04 02:03:44 +01:00
} ,
BoolToInt ( mybool ) {
2021-10-05 15:39:44 +02:00
return ( mybool ) ? - 1 : 0 ;
2019-12-04 02:03:44 +01:00
} ,
StrToBool ( mystr ) {
2021-10-05 15:39:44 +02:00
return ( mystr === '-1' ) ? true : false ;
2019-12-27 12:41:39 +01:00
} ,
2020-02-19 16:09:16 +01:00
writelogfile ( mystr , filename ) {
// fs.appendFile(FILELOG, mystr, function (err) {
// if (err) throw err;
// console.log('Saved!');
// });
2022-02-27 16:56:02 +01:00
try {
mystr = this . getstrDateTimeShort ( new Date ( ) , 'it' ) + ': ' + mystr ;
2020-02-19 16:09:16 +01:00
2022-02-27 16:56:02 +01:00
const stream = fs . createWriteStream ( filename , { flags : 'a' } ) ;
stream . write ( '\n' + mystr ) ;
stream . end ( ) ;
2022-03-01 23:50:58 +01:00
} catch ( e ) {
2022-02-27 16:56:02 +01:00
}
2020-06-08 13:31:05 +02:00
2020-02-19 16:09:16 +01:00
} ,
2020-06-08 13:31:05 +02:00
readlogfile ( idapp , filename ) {
2020-07-02 22:00:58 +02:00
try {
2020-06-08 13:31:05 +02:00
return fs . readFileSync ( idapp + '/' + filename , 'utf8' ) ;
2020-07-02 22:00:58 +02:00
} catch ( e ) {
2020-06-08 13:31:05 +02:00
return '' ;
}
} ,
2020-02-19 16:09:16 +01:00
writelog ( mystr ) {
this . writelogfile ( mystr , FILELOG ) ;
} ,
writeEventsLog ( mystr ) {
this . writelogfile ( mystr , FILEEVENTS ) ;
} ,
2020-03-10 21:44:14 +01:00
writeManagersLog ( mystr ) {
this . writelogfile ( mystr , FILEMANAGERS ) ;
} ,
2022-02-27 16:56:02 +01:00
writeErrorLog ( mystr ) {
this . writelogfile ( mystr , FILEERRLOGIN ) ;
} ,
2020-03-10 21:44:14 +01:00
2020-06-08 13:31:05 +02:00
writeSostituzioniLog ( mystr ) {
this . writelogfile ( mystr , FILESOSTITUZIONI ) ;
} ,
2020-07-13 23:35:05 +02:00
writeIPToBan ( mystr ) {
this . writelogfile ( mystr , FILEIP _TO _BAN ) ;
} ,
2020-06-08 13:31:05 +02:00
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 ) ;
} ,
2020-03-10 21:44:14 +01:00
writeNaveLog ( mystr ) {
this . writelogfile ( mystr , FILENAVE ) ;
2020-02-19 16:09:16 +01:00
} ,
2019-12-27 12:41:39 +01:00
move ( oldPath , newPath , callback ) {
2021-10-05 15:39:44 +02:00
fs . rename ( oldPath , newPath , function ( err ) {
2019-12-27 12:41:39 +01:00
if ( err ) {
if ( err . code === 'EXDEV' ) {
copy ( ) ;
} else {
callback ( err ) ;
}
return ;
2022-03-01 23:50:58 +01:00
} else {
console . log ( ' ... File Rinominato' , oldPath , 'in:' , newPath ) ;
2019-12-27 12:41:39 +01:00
}
2022-03-01 23:50:58 +01:00
2019-12-27 12:41:39 +01:00
callback ( ) ;
} ) ;
function copy ( ) {
const readStream = fs . createReadStream ( oldPath ) ;
const writeStream = fs . createWriteStream ( newPath ) ;
readStream . on ( 'error' , callback ) ;
writeStream . on ( 'error' , callback ) ;
2021-10-05 15:39:44 +02:00
readStream . on ( 'close' , function ( ) {
2022-03-01 23:50:58 +01:00
console . log ( 'cancella file già copiato' , oldPath ) ;
2019-12-27 12:41:39 +01:00
fs . unlink ( oldPath , callback ) ;
} ) ;
readStream . pipe ( writeStream ) ;
}
} ,
2019-11-21 00:18:40 +01:00
2022-02-16 09:40:16 +01:00
copy ( oldPath , newPath , callback ) {
fs . copyFile ( oldPath , newPath , ( err ) => {
if ( err ) throw err ;
// console.log('source.txt was copied to destination.txt');
} ) ;
} ,
2022-01-14 23:54:33 +01:00
extractFileName : function ( filename ) {
return path . basename ( filename ) ;
2021-12-21 18:12:28 +01:00
} ,
2022-01-14 23:54:33 +01:00
extractFilePath : function ( filename ) {
return path . dirname ( filename ) ;
2021-12-21 18:12:28 +01:00
} ,
delete ( mypath , alsothumb , callback ) {
2019-12-28 02:16:29 +01:00
2021-12-21 18:12:28 +01:00
fs . unlink ( mypath , function ( err ) {
if ( alsothumb ) {
try {
2022-01-14 23:54:33 +01:00
let img _small = path . dirname ( mypath ) + '/' +
server _constants . PREFIX _IMG _SMALL + path . basename ( mypath ) ;
2022-03-01 23:50:58 +01:00
fs . unlink ( img _small , function ( err ) {
if ( err )
console . log ( 'Errore durante la Cancellazione del file' , mypath ) ;
else
console . log ( 'deleted file' , mypath ) ;
} ) ;
2021-12-21 18:12:28 +01:00
} catch ( e ) {
console . error ( err ) ;
}
}
2019-12-28 02:16:29 +01:00
if ( err ) {
console . error ( err ) ;
callback ( err ) ;
2021-10-05 15:39:44 +02:00
return ;
2019-12-28 02:16:29 +01:00
}
callback ( ) ;
} ) ;
2019-12-28 14:30:30 +01:00
} ,
mkdirpath ( dirPath ) {
2020-01-03 01:52:49 +01:00
if ( ! fs . existsSync ( dirPath ) ) {
2019-12-28 14:30:30 +01:00
try {
2021-10-05 15:39:44 +02:00
fs . mkdirSync ( dirPath , { recursive : true } ) ;
2020-12-21 02:16:42 +01:00
} catch ( e ) {
2021-02-18 12:19:35 +01:00
if ( dirPath !== path . dirname ( dirPath ) ) {
const myname = path . dirname ( dirPath ) ;
this . mkdirpath ( myname ) ;
// this.mkdirpath(dirPath);
}
2019-12-28 14:30:30 +01:00
}
}
} ,
2019-12-28 02:16:29 +01:00
2020-01-13 23:52:51 +01:00
extractNameAndSurnameByComplete ( name _complete ) {
const suffissoCognome = [ 'Del' , 'La' , 'De' , 'Lo' ] ;
2021-10-05 15:39:44 +02:00
let campi = name _complete . split ( ' ' ) ;
2020-01-13 23:52:51 +01:00
let namesurname = {
name : '' ,
surname : '' ,
} ;
if ( campi . length === 2 ) {
namesurname . name = campi [ 0 ] ;
namesurname . surname = campi [ 1 ] ;
2020-01-21 01:37:15 +01:00
} else if ( campi . length === 3 ) {
2020-01-13 23:52:51 +01:00
if ( suffissoCognome . includes ( campi [ 1 ] ) ) {
namesurname . name = campi [ 0 ] ;
2021-10-05 15:39:44 +02:00
namesurname . surname = campi [ 1 ] + ' ' + campi [ 2 ] ;
2020-01-13 23:52:51 +01:00
} else {
2021-10-05 15:39:44 +02:00
namesurname . name = campi [ 0 ] + ' ' + campi [ 1 ] ;
2020-01-13 23:52:51 +01:00
namesurname . surname = campi [ 2 ] ;
}
2020-01-21 01:37:15 +01:00
} else if ( campi . length === 4 ) {
2021-10-05 15:39:44 +02:00
namesurname . name = campi [ 0 ] + ' ' + campi [ 1 ] ;
namesurname . surname = campi [ 2 ] + ' ' + campi [ 3 ] ;
2020-01-21 01:37:15 +01:00
} else if ( campi . length > 4 ) {
2021-10-05 15:39:44 +02:00
namesurname . name = campi [ 0 ] + ' ' + campi [ 1 ] ;
namesurname . surname = ' ' + campi [ 2 ] ;
2020-01-20 01:48:25 +01:00
for ( let ind = 3 ; ind < campi . length ; ind ++ ) {
2021-10-05 15:39:44 +02:00
namesurname . surname += ' ' + campi [ ind ] ;
2020-01-13 23:52:51 +01:00
}
}
2021-10-05 15:39:44 +02:00
return namesurname ;
2020-01-13 23:52:51 +01:00
} ,
2022-01-23 23:25:34 +01:00
isFileExists ( filename ) {
2022-02-08 23:14:08 +01:00
return fs . existsSync ( filename ) ;
2022-01-23 23:25:34 +01:00
} ,
2020-02-02 04:06:32 +01:00
getiPAddressUser ( req ) {
2020-01-27 15:07:53 +01:00
try {
const striniziale = '::ffff:' ;
2020-02-02 04:06:32 +01:00
if ( req . ip . indexOf ( striniziale ) >= 0 ) {
2021-10-05 15:39:44 +02:00
return req . ip . substring ( striniziale . length ) ;
2020-01-27 15:07:53 +01:00
} else {
return req . ip ; // Express
}
} catch ( e ) {
2021-10-05 15:39:44 +02:00
return '' ;
2020-01-27 15:07:53 +01:00
}
2020-01-30 01:19:25 +01:00
} ,
removespaces ( mystr ) {
2021-10-05 15:39:44 +02:00
return mystr . replace ( /\s+/g , '' ) ;
2020-01-30 01:19:25 +01:00
} ,
2020-03-10 21:44:14 +01:00
ModificheConsentite ( table , fieldsvalue , idrec , user ) {
2021-01-18 00:48:17 +01:00
if ( table === 'sharewithus' ) {
return true ;
}
2021-02-18 12:19:35 +01:00
if ( table === 'hours' ) {
return true ;
}
2020-02-05 00:39:25 +01:00
if ( table === 'users' ) {
if ( 'aportador_solidario' in fieldsvalue ) {
return true ;
}
2020-03-10 21:44:14 +01:00
if ( 'ALL' in fieldsvalue ) {
//++Todo: Cancellalo solo se sono io il creatore dell'utente ... o se posso!
2021-10-05 15:39:44 +02:00
return true ;
2020-03-10 21:44:14 +01:00
}
2020-02-05 00:39:25 +01:00
}
2021-12-23 14:13:40 +01:00
if ( shared _consts . TABLES _PERM _CHANGE _FOR _USERS . includes ( table ) ) {
return true ;
}
2022-01-28 00:57:39 +01:00
if ( shared _consts . TABLES _PERM _NEWREC . includes ( table ) ) {
return true ;
}
2021-12-23 14:13:40 +01:00
2020-02-05 00:39:25 +01:00
return false ;
} ,
NotifyIfDelRecord ( table ) {
2021-10-05 15:39:44 +02:00
if ( ( table === 'users' ) || ( table === 'extralist' ) ||
2022-02-03 00:33:15 +01:00
( table === 'groups' ) || ( table === 'graduatorias' ) ) {
2020-02-05 00:39:25 +01:00
return true ;
}
return false ;
} ,
2020-03-10 21:44:14 +01:00
getFirstWord ( mystr ) {
2021-10-05 15:39:44 +02:00
const myarr = mystr . split ( ' ' ) ;
2020-03-10 21:44:14 +01:00
if ( myarr . length > 0 )
return myarr [ 0 ] ;
else
2021-10-05 15:39:44 +02:00
return mystr ;
2020-03-10 21:44:14 +01:00
} ,
getFirst2Car ( mystr ) {
if ( ! ! mystr )
return mystr . substring ( 0 , 2 ) + '.' ;
else
2021-10-05 15:39:44 +02:00
return '' ;
2020-03-10 21:44:14 +01:00
} ,
2020-05-19 00:18:13 +02:00
getmaxcol ( riga ) {
return Math . pow ( 2 , riga - 1 ) ;
} ,
2020-06-08 13:31:05 +02:00
getPrimoFuocoByIndCol ( col ) {
// let ris = Math.ceil(col - (col % 8)) + 1;
let ris = ( ( Math . ceil ( col / 8 ) - 1 ) * 8 ) + 1 ;
if ( ris <= 0 )
ris = 1 ;
2021-10-05 15:39:44 +02:00
return ris ;
2020-06-08 13:31:05 +02:00
} ,
getPrimaColFlotta ( col ) {
// let ris = Math.ceil(col - (col % 8)) + 1;
let ris = ( ( Math . ceil ( col / 64 ) - 1 ) * 64 ) + 1 ;
if ( ris <= 0 )
ris = 1 ;
2021-10-05 15:39:44 +02:00
return ris ;
2020-06-08 13:31:05 +02:00
} ,
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 ;
2020-07-02 22:00:58 +02:00
} ,
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 '🇫🇷' ;
2020-07-13 23:35:05 +02:00
} ,
2020-06-08 13:31:05 +02:00
2020-07-13 23:35:05 +02:00
blockwords ( mystr ) {
2022-02-24 19:13:20 +01:00
const arrwords = [
'http' ,
'Http' ,
'Asasfasfas' ,
'://' ,
'mrbit' ,
'admin' ,
'superuser' ] ;
2022-02-12 22:12:49 +01:00
try {
for ( const myword of arrwords ) {
if ( mystr ) {
if ( mystr . includes ( myword ) ) {
return true ;
}
}
2020-09-04 00:06:49 +02:00
}
2022-02-12 22:12:49 +01:00
} catch ( e ) {
2020-07-13 23:35:05 +02:00
}
2020-01-27 15:07:53 +01:00
2020-07-13 23:35:05 +02:00
return false ;
} ,
isAlphaNumeric ( str ) {
let code , i , len ;
for ( i = 0 , len = str . length ; i < len ; i ++ ) {
code = str . charCodeAt ( i ) ;
if ( ! ( code > 47 && code < 58 ) && // numeric (0-9)
2021-10-05 15:39:44 +02:00
! ( code > 64 && code < 91 ) && // upper alpha (A-Z)
! ( code > 96 && code < 123 ) ) { // lower alpha (a-z)
2020-07-13 23:35:05 +02:00
return false ;
}
}
return true ;
2020-12-21 02:16:42 +01:00
} ,
2022-02-14 19:35:11 +01:00
isAlphaNumericAndSpecialCharacter ( str ) {
let code , i , len ;
for ( i = 0 , len = str . length ; i < len ; i ++ ) {
code = str . charCodeAt ( i ) ;
if ( ! ( code > 47 && code < 58 ) && // numeric (0-9)
! ( code > 63 && code < 91 ) && // upper alpha (A-Z) // e @
2022-02-26 17:35:50 +01:00
( code !== 46 ) && // . (punto)
2022-02-14 19:35:11 +01:00
( code !== 95 ) && // _
( code !== 45 ) && // -
! ( code > 96 && code < 123 ) ) { // lower alpha (a-z)
return false ;
}
}
return true ;
} ,
2020-12-21 02:16:42 +01:00
categorizeQueryString ( queryObj ) {
2021-10-05 15:39:44 +02:00
let query = { } ;
let order = { } ;
2020-12-21 02:16:42 +01:00
//extract query, order, filter value
for ( const i in queryObj ) {
if ( queryObj [ i ] ) {
// extract order
if ( i === 'order' ) {
2021-10-05 15:39:44 +02:00
order [ 'sort' ] = queryObj [ i ] ;
continue ;
2020-12-21 02:16:42 +01:00
}
// extract range
if ( i === 'range' ) {
2021-10-05 15:39:44 +02:00
let range _arr = [ ] ;
let query _arr = [ ] ;
2020-12-21 02:16:42 +01:00
// multi ranges
if ( queryObj [ i ] . constructor === Array ) {
for ( const r of queryObj [ i ] ) {
2021-10-05 15:39:44 +02:00
range _arr = r . split ( '-' ) ;
2020-12-21 02:16:42 +01:00
query _arr . push ( {
2021-10-05 15:39:44 +02:00
price : { $gt : range _arr [ 0 ] , $lt : range _arr [ 1 ] } ,
} ) ;
2020-12-21 02:16:42 +01:00
}
}
// one range
if ( queryObj [ i ] . constructor === String ) {
2021-10-05 15:39:44 +02:00
range _arr = queryObj [ i ] . split ( '-' ) ;
2020-12-21 02:16:42 +01:00
query _arr . push ( {
2021-10-05 15:39:44 +02:00
price : { $gt : range _arr [ 0 ] , $lt : range _arr [ 1 ] } ,
} ) ;
2020-12-21 02:16:42 +01:00
}
2021-10-05 15:39:44 +02:00
Object . assign ( query , { $or : query _arr } ) ;
delete query [ i ] ;
continue ;
2020-12-21 02:16:42 +01:00
}
2021-10-05 15:39:44 +02:00
query [ i ] = queryObj [ i ] ;
2020-12-21 02:16:42 +01:00
}
}
2021-10-05 15:39:44 +02:00
return { query , order } ;
2020-12-21 02:16:42 +01:00
} ,
2021-02-24 04:48:31 +01:00
dateToEpoch ( thedate ) {
const time = new Date ( thedate ) . getTime ( ) ;
return time - ( time % 86400000 ) ;
} ,
dateToEpochStr ( thedate ) {
const time = new Date ( thedate ) . getTime ( ) ;
return new Date ( time - ( time % 86400000 ) ) ;
2021-04-30 01:31:12 +02:00
} ,
async loadApps ( ) {
2022-05-05 00:38:41 +02:00
this . MYAPPS = await Site . findAll ( 0 ) ;
2021-09-22 01:13:41 +02:00
// console.log('this.MYAPPS', this.MYAPPS);
2021-04-30 01:31:12 +02:00
} ,
getApps ( ) {
if ( this . MYAPPS . length <= 0 )
this . loadApps ( ) ;
return this . MYAPPS ;
2021-05-10 01:50:40 +02:00
} ,
getPaymentTypesById ( idmetodo ) {
2021-10-05 15:39:44 +02:00
return shared _consts . PaymentTypes [ idmetodo ] ;
2021-05-10 01:50:40 +02:00
} ,
2021-02-24 04:48:31 +01:00
2021-10-05 00:20:12 +02:00
getVersionint ( versionstr ) {
2021-10-28 00:38:10 +02:00
let versionarr = versionstr . split ( '.' ) ;
let version = 0 ;
versionarr = versionarr . reverse ( ) ;
for ( let i = 0 ; i < versionarr . length ; i ++ ) {
2022-01-14 23:54:33 +01:00
version += versionarr [ i ] * Math . pow ( 10 , i * 2 ) ;
2021-10-28 00:38:10 +02:00
}
2021-10-05 00:20:12 +02:00
return parseInt ( version ) ;
2021-10-05 15:39:44 +02:00
} ,
2021-10-05 00:20:12 +02:00
2021-10-28 00:38:10 +02:00
invertescapeslash ( mystr ) {
return mystr . replace ( /-/g , '/' ) ;
} ,
2022-01-14 23:54:33 +01:00
isNumber ( n ) {
return typeof ( n ) != 'boolean' && ! isNaN ( n ) && n ;
2021-12-29 18:26:08 +01:00
} ,
2021-12-03 22:48:05 +01:00
getNumObj ( obj ) {
let count = 0 ;
for ( let properties in obj ) {
count = count + 1 ;
}
return count ;
} ,
2022-02-08 23:14:08 +01:00
getNomeCognomeEUserNameByUser ( user ) {
2022-02-24 19:13:20 +01:00
let nome = ` ${ user . name } ${ user . surname } ( ${ user . username } ) ` ;
2022-02-08 23:14:08 +01:00
if ( ! user . name ) {
nome = user . username ;
}
return nome ;
} ,
2022-02-09 19:48:39 +01:00
sulServer ( ) {
2022-02-24 19:13:20 +01:00
return process . env . LOCALE !== '1' ;
2022-02-12 02:20:07 +01:00
} ,
2022-03-04 15:30:11 +01:00
refreshAllTablesInMem ( idapp , table , updatebot , username ) {
2022-02-27 16:56:02 +01:00
const telegrambot = require ( '../telegram/telegrambot' ) ;
2022-03-02 20:18:29 +01:00
if ( table === shared _consts . TAB _MYBOTS || updatebot ) {
2022-02-27 16:56:02 +01:00
telegrambot . reloadMenuBot ( idapp ) ;
2022-03-04 15:30:11 +01:00
}
if ( table === shared _consts . TAB _USERS ) {
telegrambot . deleteRecInMemByUsername ( idapp , username ) ;
2022-02-27 16:56:02 +01:00
} else if ( table === shared _consts . TAB _SITES ) {
telegrambot . reloadSites ( ) ;
}
2022-03-01 23:50:58 +01:00
} ,
downloadImage ( url , filepath ) {
2022-03-02 20:18:29 +01:00
try {
return download . image ( {
url ,
2022-03-06 00:48:33 +01:00
dest : filepath ,
2022-03-02 20:18:29 +01:00
} ) ;
2022-03-06 00:48:33 +01:00
} catch ( e ) {
2022-03-03 20:32:04 +01:00
console . error ( 'Err download image' , e ) ;
2022-03-02 20:18:29 +01:00
return false ;
}
2022-03-01 23:50:58 +01:00
} ,
2022-02-27 16:56:02 +01:00
2022-03-06 00:48:33 +01:00
convertSpecialTags ( user , msg ) {
try {
if ( ! ! user ) {
2022-03-12 21:38:19 +01:00
msg = msg . replace ( '{appname}' , this . getNomeAppByIdApp ( user . idapp ) ) ;
2022-03-06 00:48:33 +01:00
msg = msg . replace ( '{username}' , user . username ) ;
msg = msg . replace ( '{name}' , user . name ? user . name : user . username ) ;
msg = msg . replace ( '{surname}' , user . surname ? user . surname : '' ) ;
2022-03-09 14:53:09 +01:00
msg = msg . replace ( '{aportador_solidario}' , user . aportador _solidario ? user . aportador _solidario : '' ) ;
2022-03-06 00:48:33 +01:00
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 . payeer _id )
msg = msg . replace ( '{payeer_id}' , user . profile . payeer _id ) ;
if ( ! ! user . profile . advcash _id )
msg = msg . replace ( '{advcash_id}' , user . profile . advcash _id ) ;
if ( ! ! user . profile . email _paypal )
msg = msg . replace ( '{email_paypal}' , user . profile . email _paypal ) ;
if ( ! ! user . profile . note _payment )
msg = msg . replace ( '{note_payment}' , user . profile . note _payment ) ;
}
// const cl = getclTelegByidapp(user.idapp);
msg = msg . replace ( '{link_chathelp}' , this . HELP _CHAT ) ;
} catch ( e ) {
console . log ( e ) ;
}
return msg ;
} ,
getUserInfoMsg : function ( idapp , myuser , usernametelegram = '' , name _telegram = '' ,
surname _telegram = '' ) {
let msg = '' ;
try {
const name = myuser . username +
2022-03-11 12:38:01 +01:00
( myuser . name ? ` ( ${ myuser . name } ${ myuser . surname } ) ` : '' ) ;
2022-03-06 00:48:33 +01:00
const linkuserprof = this . getHostByIdApp ( idapp ) + '/my/' +
myuser . username ;
msg = ` <br>Username: <b> ${ name } </b><br>Profilo su APP: ${ linkuserprof } <br>Email: ${ myuser . email } ` ;
let u _tg = myuser . profile && myuser . profile . hasOwnProperty ( 'username_telegram' ) ? myuser . profile . username _telegram : usernametelegram ;
let name _tg = myuser . profile && myuser . profile . hasOwnProperty ( 'firstname_telegram' )
? myuser . profile . firstname _telegram
: name _telegram ;
let surname _tg = myuser . profile && myuser . profile . hasOwnProperty ( 'lastname_telegram' )
? myuser . profile . lastname _telegram
: surname _telegram ;
if ( u _tg ) {
2022-03-11 12:38:01 +01:00
msg += ` <br>Profilo su Telegram [ ${ name _tg } ${ surname _tg } ]:<br>https://t.me/ ${ u _tg } ` ;
2022-03-06 00:48:33 +01:00
}
} catch ( e ) {
console . error ( 'getUserInfoMsg' , e ) ;
}
return msg ;
} ,
2022-03-08 01:01:20 +01:00
getlinkRequestNewPassword : function ( idapp , email , tokenforgot ) {
const strlinkreg = this . getHostByIdApp ( idapp ) + process . env . LINK _UPDATE _PASSWORD + ` ?idapp= ${ idapp } &email= ${ email } &tokenforgot= ${ tokenforgot } ` ;
return strlinkreg ;
} ,
2022-03-06 00:48:33 +01:00
2022-03-12 21:38:19 +01:00
execScript : function ( idapp , msg , script , testo ) {
const { exec } = require ( "child_process" ) ;
const telegrambot = require ( '../telegram/telegrambot' ) ;
const idchat = msg . chat . id ;
console . log ( testo + ' (' + script + ')' ) ;
telegrambot . local _sendMsgTelegramByIdTelegram ( idapp , idchat , testo ) ;
exec ( script , ( error , stdout , stderr ) => {
if ( error ) {
telegrambot . local _sendMsgTelegramByIdTelegram ( idapp , idchat , 'ERROR: ' + error . message ) ;
console . log ( ` error: ${ error . message } ` ) ;
return ;
}
if ( stderr ) {
telegrambot . local _sendMsgTelegramByIdTelegram ( idapp , idchat , 'ERROR: ' + stderr ) ;
console . log ( ` stderr: ${ stderr } ` ) ;
return ;
}
// console.log(` ... stdout: ${stdout}`);
telegrambot . local _sendMsgTelegramByIdTelegram ( idapp , idchat , stdout ) ;
} ) ;
}
2019-12-28 14:30:30 +01:00
} ;