2024-07-03 14:21:02 +02:00
require ( './config/config' ) ;
require ( './config/config' ) ;
// console.log(" lodash");
console . log ( process . versions ) ;
const _ = require ( 'lodash' ) ;
// console.log(" cors");
const cors = require ( 'cors' ) ;
// console.log(" 2) fs");
const fs = require ( 'fs' ) ;
var https = require ( 'https' ) ;
const NUOVO _METODO _TEST = true ;
const server _constants = require ( './tools/server_constants' ) ;
//const throttle = require('express-throttle-bandwidth');
// app.use(throttle(1024 * 128)) // throttling bandwidth
const port = process . env . PORT ;
// var cookieParser = require('cookie-parser')
// var csrf = require('csurf')
const express = require ( 'express' ) ;
const bodyParser = require ( 'body-parser' ) ;
const path = require ( 'path' ) ;
const cron = require ( 'node-cron' ) ;
console . log ( 'Starting mongoose...' ) ;
const tls = require ( 'tls' ) ;
require ( './db/mongoose' ) ;
// console.log('Starting pem...');
// const pem = require('pem')
const { Settings } = require ( './models/settings' ) ;
const Site = require ( './models/site' ) ;
// test
const i18n = require ( 'i18n' ) ;
let credentials = null ;
// OBTAIN
// https://www.psclistens.com/insight/blog/enabling-a-nodejs-ssl-webserver-using-let-s-encrypt-pem-certificates/
if ( ( process . env . NODE _ENV === 'production' ) ) {
console . log ( '*** AMBIENTE DI PRODUZIONE (Aprile 2024) !!!!' )
} else if ( process . env . NODE _ENV === 'test' ) {
console . log ( '*** ### AMBIENTE DI TEST ' )
}
console . log ( 'DB: ' + process . env . DATABASE ) ;
// console.log("PORT: " + port);
// console.log("MONGODB_URI: " + process.env.MONGODB_URI);
var app = express ( ) ;
let telegrambot = null ;
const tools = require ( './tools/general' ) ;
const shared _consts = require ( './tools/shared_nodejs' ) ;
var mongoose = require ( 'mongoose' ) . set ( 'debug' , false ) ;
mongoose . set ( 'debug' , false ) ;
const { CfgServer } = require ( './models/cfgserver' ) ;
2024-12-17 17:55:47 +01:00
const { ObjectId } = require ( 'mongodb' ) ;
2024-07-03 14:21:02 +02:00
const populate = require ( './populate/populate' ) ;
const { Circuit } = require ( './models/circuit' ) ;
const printf = require ( 'util' ) . format ;
myLoad ( ) . then ( ris => {
const { User } = require ( './models/user' ) ;
require ( './models/todo' ) ;
require ( './models/project' ) ;
require ( './models/subscribers' ) ;
require ( './models/booking' ) ;
require ( './models/sendmsg' ) ;
require ( './models/sendnotif' ) ;
require ( './models/mailinglist' ) ;
require ( './models/newstosent' ) ;
require ( './models/mypage' ) ;
require ( './models/myelem' ) ;
require ( './models/bot' ) ;
require ( './models/calzoom' ) ;
const mysql _func = require ( './mysql/mysql_func' ) ;
const index _router = require ( './router/index_router' ) ;
const push _router = require ( './router/push_router' ) ;
const newsletter _router = require ( './router/newsletter_router' ) ;
const booking _router = require ( './router/booking_router' ) ;
const dashboard _router = require ( './router/dashboard_router' ) ;
const myevent _router = require ( './router/myevent_router' ) ;
const subscribe _router = require ( './router/subscribe_router' ) ;
const sendmsg _router = require ( './router/sendmsg_router' ) ;
const sendnotif _router = require ( './router/sendnotif_router' ) ;
const email _router = require ( './router/email_router' ) ;
const todos _router = require ( './router/todos_router' ) ;
const test _router = require ( './router/test_router' ) ;
const projects _router = require ( './router/projects_router' ) ;
const report _router = require ( './router/report_router' ) ;
const users _router = require ( './router/users_router' ) ;
const reactions _router = require ( './router/reactions_router' ) ;
const mygroups _router = require ( './router/mygroups_router' ) ;
const circuits _router = require ( './router/circuits_router' ) ;
const accounts _router = require ( './router/accounts_router' ) ;
const iscrittiConacreis _router = require ( './router/iscrittiConacreis_router' ) ;
const iscrittiArcadei _router = require ( './router/iscrittiArcadei_router' ) ;
const site _router = require ( './router/site_router' ) ;
const admin _router = require ( './router/admin_router' ) ;
const products _router = require ( './router/products_router' ) ;
const cart _router = require ( './router/cart_router' ) ;
const orders _router = require ( './router/orders_router' ) ;
const city _router = require ( './router/city_router' ) ;
const myskills _router = require ( './router/myskills_router' ) ;
const mygoods _router = require ( './router/mygoods_router' ) ;
const mygen _router = require ( './router/mygen_router' ) ;
const aitools _router = require ( './router/aitools_router' ) ;
const { MyEvent } = require ( './models/myevent' ) ;
app . use ( bodyParser . json ( { limit : '50mb' } ) ) ;
app . use ( bodyParser . urlencoded ( { limit : '50mb' , extended : true } ) ) ;
app . use ( express . static ( 'views' ) ) ;
// app.use(express.static(path.join(__dirname, 'client')));
app . use ( bodyParser . json ( ) ) ;
// app.set('view engine', 'pug');
// Set static folder
// app.use(express.static(path.join(__dirname, 'public')));
i18n . configure ( {
locales : [ 'it' , 'enUs' , 'es' , 'fr' , 'pt' , 'si' ] ,
defaultLocale : 'it' ,
// cookie: 'cook',
directory : _ _dirname + '/locales' ,
api : {
'__' : 'translate' ,
'__n' : 'translateN'
} ,
} ) ;
app . use ( cors ( {
exposedHeaders : [ 'x-auth' , 'x-refrtok' ] ,
} ) ) ;
app . use ( bodyParser . json ( ) ) ;
// app.use(express.cookieParser());
app . use ( i18n . init ) ;
console . log ( 'Use Routes \...' ) ;
// Use Routes
app . use ( '/' , index _router ) ;
app . use ( '/subscribe' , subscribe _router ) ;
app . use ( '/sendmsg' , sendmsg _router ) ;
app . use ( '/sendnotif' , sendnotif _router ) ;
app . use ( '/push' , push _router ) ;
app . use ( '/news' , newsletter _router ) ;
app . use ( '/booking' , booking _router ) ;
app . use ( '/dashboard' , dashboard _router ) ;
app . use ( '/event' , myevent _router ) ;
app . use ( '/email' , email _router ) ;
app . use ( '/todos' , todos _router ) ;
app . use ( '/test' , test _router ) ;
app . use ( '/projects' , projects _router ) ;
app . use ( '/users' , users _router ) ;
app . use ( '/reactions' , reactions _router ) ;
app . use ( '/mygroup' , mygroups _router ) ;
app . use ( '/circuit' , circuits _router ) ;
app . use ( '/account' , accounts _router ) ;
app . use ( '/iscritti_conacreis' , iscrittiConacreis _router ) ;
app . use ( '/iscritti_arcadei' , iscrittiArcadei _router ) ;
app . use ( '/report' , report _router ) ;
app . use ( '/site' , site _router ) ;
app . use ( '/admin' , admin _router ) ;
app . use ( '/products' , products _router ) ;
app . use ( '/cart' , cart _router ) ;
app . use ( '/orders' , orders _router ) ;
app . use ( '/city' , city _router ) ;
app . use ( '/myskills' , myskills _router ) ;
app . use ( '/mygoods' , mygoods _router ) ;
app . use ( '/mygen' , mygen _router ) ;
app . use ( '/aitools' , aitools _router ) ;
// catch 404 and forward to error handler
// app.use(function (req, res, next) {
// var err = new Error('Not Found');
// err.status = 404;
// next(err);
// });
// app.set('views', path.join(__dirname, 'views'));
// app.set('view engine', 'pug');
// development error handler
// will print stacktrace
if ( app . get ( 'env' ) === 'development' ) {
app . use ( function ( err , req , res , next ) {
console . log ( 'Server Error: ' , err . message ) ;
// console.trace();
res . status ( err . status || 500 ) . send ( { error : err . message } ) ;
// res.render('error', {
// message: err.message,
// error: err
// });
} ) ;
}
// require('./telegram/telegrambot');
// *** DB CONNECTIONS ***
// mysql_func.mySqlConn_Shen.connect((err) => {
// if (!err)
// console.log('DB connection to Shen Database succeded.');
// else
// console.log('DB connection to Shen Database FAILED \n Error: ' + JSON.stringify(err, undefined, 2));
// });
if ( process . env . NODE _ENV === 'production' ) {
console . log ( '*** PRODUCTION! ' ) ;
}
if ( ( process . env . NODE _ENV === 'production' ) ||
( process . env . NODE _ENV === 'test' ) ) {
const keyStream = path . resolve ( ` ./ ${ process . env . PATH _CERT _KEY } ` ) ;
const certificateStream = path . resolve ( ` ./ ${ process . env . PATH _SERVER _CRT } ` ) ;
let privateKey = fs . readFileSync ( keyStream , "utf8" ) ;
let certificate = fs . readFileSync ( certificateStream , "utf8" ) ;
let credentials = null ;
// arrSecureContext = ['piuchebuono.app', 'gruppomacro.app'];
arrSecureContext = [ 'freeplanet.app' , 'riso.app' , 'comunitanuovomondo.app' ] ;
let secureContext = { } ;
for ( let i = 0 ; i < arrSecureContext . length ; i ++ ) {
try {
secureContext = {
... secureContext ,
[ arrSecureContext [ i ] ] : tls . createSecureContext ( {
key : fs . readFileSync ( '/etc/letsencrypt/live/' + arrSecureContext [ i ] + '/privkey.pem' ) ,
cert : fs . readFileSync ( '/etc/letsencrypt/live/' + arrSecureContext [ i ] + '/fullchain.pem' )
// ca: fs.readFileSync('../path_to_certificate_authority_bundle.ca-bundle1', 'utf8'), // this ca property is optional
} )
}
credentials = {
SNICallback : function ( domain , cb ) {
if ( secureContext ) {
if ( cb ) {
cb ( null , secureContext ) ;
} else {
// compatibility for older versions of node
return secureContext ;
}
} else {
}
}
}
} catch ( err ) {
console . log ( 'Error: ' + err ) ;
}
}
/ *
let secureContext = {
'piuchebuono.app' : tls . createSecureContext ( {
key : fs . readFileSync ( '/etc/letsencrypt/live/piuchebuono.app/privkey.pem' ) ,
cert : fs . readFileSync ( '/etc/letsencrypt/live/piuchebuono.app/fullchain.pem' )
// ca: fs.readFileSync('../path_to_certificate_authority_bundle.ca-bundle1', 'utf8'), // this ca property is optional
} ) ,
'gruppomacro.app' : tls . createSecureContext ( {
key : fs . readFileSync ( '/etc/letsencrypt/live/gruppomacro.app/privkey.pem' ) ,
cert : fs . readFileSync ( '/etc/letsencrypt/live/gruppomacro.app/fullchain.pem' )
// ca: fs.readFileSync('../path_to_certificate_authority_bundle.ca-bundle1', 'utf8'), // this ca property is optional
} ) ,
} * /
console . log ( 'secureContext' , secureContext ) ;
if ( NUOVO _METODO _TEST ) {
credentials = {
SNICallback : function ( domain , cb ) {
if ( secureContext [ domain ] ) {
if ( cb ) {
cb ( null , secureContext [ domain ] ) ;
} else {
// compatibility for older versions of node
return secureContext [ domain ] ;
}
} else {
throw new Error ( 'No keys/certificates for domain requested' ) ;
}
} ,
// must list a default key and cert because required by tls.createServer()
key : privateKey ,
cert : certificate ,
}
/ * } e l s e {
// NON USATO !
credentials = {
key : privateKey ,
cert : certificate ,
ca : [
fs . readFileSync ( process . env . PATH _SSL _ROOT _PEM , 'utf8' ) ,
fs . readFileSync ( process . env . PATH _SSL _CHAIN _PEM , 'utf8' ) ,
] ,
} ;
}
/ * } e l s e {
* /
}
}
if ( process . env . HTTPS _LOCALHOST === "true" ) {
privateKey = fs . readFileSync ( process . env . PATH _CERT _KEY , 'utf8' ) ;
certificate = fs . readFileSync ( process . env . PATH _SERVER _CRT , 'utf8' ) ;
credentials = {
key : privateKey ,
cert : certificate ,
ciphers : 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384' ,
honorCipherOrder : true ,
secureProtocol : 'TLSv1_2_method' ,
} ;
} else {
var http = require ( 'http' ) ;
}
if ( ( process . env . NODE _ENV === 'production' ) ||
( process . env . NODE _ENV === 'test' ) || process . env . HTTPS _LOCALHOST === "true" ) {
const httpsServer = https . createServer ( credentials , app ) ;
console . log ( 'httpsServer: port ' , port ) ;
httpsServer . listen ( port ) ;
} else {
console . log ( 'httpServer: port ' , port ) ;
const httpServer = http . createServer ( app ) ;
httpServer . listen ( port ) ;
}
mystart ( ) ;
} ) ;
// app.use(throttle(1024 * 128)); // throttling bandwidth
// app.use((req, res, next) => {
// res.header('Access-Control-Allow-Origin', '*')
// res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
// next()
// });
async function myLoad ( ) {
return tools . loadApps ( ) ;
}
async function mystart ( ) {
// await estraiTutteLeImmagini();
await tools . getApps ( ) ;
if ( process . env . PROD !== 1 ) {
testmsgwebpush ( ) ;
// tools.sendNotifToAdmin('Riparti', 'Riparti');
let miapass = '' ;
if ( miapass !== '' ) {
let crypt = tools . cryptdata ( miapass ) ;
let decrypt = tools . decryptdata ( crypt ) ;
console . log ( 'crypted:' , crypt ) ;
console . log ( 'decrypted:' , decrypt ) ;
}
mycron ( ) ;
if ( ! process . env . DEBUG ) {
mycron ( ) ;
}
}
telegrambot = require ( './telegram/telegrambot' ) ;
await inizia ( ) ;
await resetProcessingJob ( ) ;
populate . popolaTabelleNuove ( ) ;
faitest ( ) ;
// ----------------- MAILCHIMP -----
const querystring = require ( 'querystring' ) ;
const mailchimpClientId = 'xxxxxxxxxxxxxxxx' ;
app . get ( '/mailchimp/auth/authorize' , function ( req , res ) {
res . redirect ( 'https://login.mailchimp.com/oauth2/authorize?' +
querystring . stringify ( {
'response_type' : 'code' ,
'client_id' : mailchimpClientId ,
'redirect_uri' : 'http://127.0.0.1:3000/mailchimp/auth/callback' ,
} ) ) ;
} ) ;
}
// -----------------
function populateDBadmin ( ) {
const cfgserv = [
{
2024-12-17 17:55:47 +01:00
_id : new ObjectId ( ) ,
2024-07-03 14:21:02 +02:00
idapp : '9' ,
chiave : 'vers' ,
userId : 'ALL' ,
valore : '0.1.2' ,
} ] ;
let cfg = new CfgServer ( cfgserv [ 0 ] ) . save ( ) ;
}
async function mycron ( ) {
try {
const sendemail = require ( './sendemail' ) ;
const arr = await tools . getApps ( ) ;
for ( const app of arr ) {
sendemail . checkifPendingNewsletter ( app . idapp ) ;
sendemail . checkifSentNewsletter ( app . idapp ) ;
}
} catch ( e ) {
console . error ( 'Err mycron' , e ) ;
}
}
async function mycron _30min ( ) {
for ( const app of await tools . getApps ( ) ) {
let enablecrontab = false ;
enablecrontab = await Settings . getValDbSettings ( app . idapp ,
tools . ENABLE _CRONTAB , false ) ;
if ( enablecrontab ) {
// ...
}
}
}
async function mycron _everyday ( ) {
try {
const { User } = require ( './models/user' ) ;
const arrapps = await tools . getApps ( ) ;
for ( const app of arrapps ) {
// Azzera le richieste di password:
const usersblocked = await User . find ( { idapp : app . idapp , retry _pwd : { $exists : true , $gte : 29 } } ) . lean ( ) ;
for ( const user of usersblocked ) {
await User . findOneAndUpdate ( { _id : user . _id } , { $set : { retry _pwd : 20 } } ) ;
let text = ` ⚠️⚠️⚠️ L \' utente ${ user . username } ( ${ user . name } ${ user . surname } ) viene sbloccato dal numero massimo di tentativi di richiesta password! \n Telerlo d \' occhio ! \n @ ${ user . profile . username _telegram } ` ;
await telegrambot . sendMsgTelegramToTheAdminAllSites ( text , false ) ;
}
}
// Crea un file con all'interno il nome del dominio per ogni app:
await tools . createFileWithDomainName ( ) ;
} catch ( e ) {
console . error ( 'mycron_everyday: ' , e ) ;
}
}
function testmsgwebpush ( ) {
const { User } = require ( './models/user' ) ;
// console.log('nomeapp 1: ' , tools.getNomeAppByIdApp(1));
// console.log('nomeapp 2: ' , tools.getNomeAppByIdApp(2));
User . find ( { username : 'paoloar77' , idapp : '1' } ) . then ( async ( arrusers ) => {
if ( arrusers !== null ) {
for ( const user of arrusers ) {
await tools . sendNotificationToUser ( user . _id , 'Server' ,
'Il Server è Ripartito' , '/' , '' , 'server' , [ ] ) . then ( ris => {
if ( ris ) {
} else {
// already sent the error on calling sendNotificationToUser
}
} ) ;
}
}
} ) ;
}
// Cron every X minutes
cron . schedule ( '*/1 * * * *' , ( ) => {
// console.log('Running Cron Job');
// if (!process.env.DEBUG) {
mycron ( ) ;
// }
} ) ;
// Cron every X minutes
cron . schedule ( '*/60 * * * *' , async ( ) => {
if ( ! process . env . DEBUG ) {
mycron _30min ( ) ;
}
} ) ;
// Cron every 21:00 (1 volta al giorno)
cron . schedule ( '0 21 * * *' , async ( ) => {
mycron _everyday ( ) ;
} ) ;
// mycron_30min();
// tools.writelogfile('test', 'prova.txt');
async function resetProcessingJob ( ) {
const { Newstosent } = require ( './models/newstosent' ) ;
arrrec = await Newstosent . find ( { } ) ;
for ( const rec of arrrec ) {
rec . processing _job = false ;
await Newstosent . findOneAndUpdate ( { _id : rec . id } , { $set : rec } , { new : false } ) .
then ( ( item ) => {
} ) ;
}
}
//app.listen(port, () => {
// console.log(`Server started at port ${port}`);
//});
async function inizia ( ) {
try {
if ( true ) {
const url = 'https://raw.githubusercontent.com/matteocontrini/comuni-json/master/comuni.json' ;
const outputPath = './comuni_italia_geojson.json' ;
downloadGeoJSON ( url , outputPath ) ;
}
mycron _everyday ( ) ;
if ( process . env . NODE _ENV === 'development' ) {
await telegrambot . sendMsgTelegram ( tools . FREEPLANET ,
telegrambot . ADMIN _USER _SERVER ,
` Ciao ${ telegrambot . ADMIN _USER _NAME _SERVER } ! ` ) ;
await telegrambot . sendMsgTelegramByIdTelegram ( tools . FREEPLANET ,
telegrambot . ADMIN _IDTELEGRAM _SERVER ,
` Ciao ${ telegrambot . ADMIN _USER _NAME _SERVER } \n ` +
` 🔅 Il Server ${ process . env . DATABASE } è appena ripartito! ` ) ;
} else {
await telegrambot . sendMsgTelegramToTheAdminAllSites ( ` Ciao Admin \n ` + ` 🔅🔅🔅 Il Server col BOT di {appname} è appena ripartito! ` , false ) ;
}
await Site . createFirstUserAdmin ( ) ;
/ * c o n s t { C i r c u i t } = r e q u i r e ( ' . / m o d e l s / c i r c u i t ' ) ;
await Circuit . setDeperimentoOff ( ) ;
* /
} catch ( e ) {
}
}
//
// telegrambot.sendMsgTelegramToTheManagers('7', 'PROVAAA!');
// if (process.env.PROD !== 1) {
// const reg = require('./reg/registration');
// const link = reg.getlinkregByEmail('7', 'tomasihelen@dasdasgmail.comAAAA' , 'HelenTomasidasdasd');
// const link2 = reg.getlinkregByEmail('7', 'tomasihelen@gmail.com' , 'HelenTomasi');
// //const link2 = reg.getlinkregByEmail('7', 'elenaliubicich@gmail.com' , 'Elenaliu');
//
// console.log(link);
// console.log(link2);
// }
async function estraiImmagini ( table ) {
const { User } = require ( './models/user' ) ;
let idapp = '13' ;
let arrlist ;
const globalTables = require ( './tools/globalTables' ) ;
const mytable = globalTables . getTableByTableName ( table ) ;
if ( ! mytable )
return ;
console . log ( 'INIZIO - estraiImmagini' , table ) ;
arrlist = await mytable . find ( { idapp } ) . lean ( ) ;
let file = '' ;
let filetocheck = '' ;
let dirmain = '' ;
let filefrom = '' ;
let filefrom2 = '' ;
let dir = tools . getdirByIdApp ( idapp ) + dirmain + '/upload/' ;
try {
if ( ! tools . sulServer ( ) ) {
dirmain = '/public' ;
}
for ( const rec of arrlist ) {
const myuser = await User . findOne ( { idapp , _id : rec . userId } ) . lean ( ) ;
if ( myuser ) {
const myphotos = rec . photos ;
if ( myphotos . length > 0 ) {
let folderprof = dir + 'profile/' + myuser . username ;
try {
// console.log('checkdir', folderprof);
if ( ! fs . existsSync ( folderprof ) ) {
console . log ( '*** Creadir' , folderprof ) ;
fs . mkdirSync ( folderprof ) ;
}
folderprof = dir + 'profile/' + myuser . username + '/' + table ;
// console.log('checkdir', folderprof);
if ( ! fs . existsSync ( folderprof ) ) {
console . log ( 'creadir' , folderprof ) ;
fs . mkdirSync ( folderprof ) ;
}
} catch ( e ) {
}
}
for ( const photo of myphotos ) {
if ( photo . imagefile ) {
file = dir + 'profile/' + myuser . username + '/' + table + '/' +
photo . imagefile ;
filefrom = dir + 'profile/undefined/' + table + '/' + photo . imagefile ;
filefrom2 = dir + 'profile/' + myuser . username + '/' + photo . imagefile ;
// console.log('file', file);
// console.log('filefrom', filefrom);
if ( ! tools . isFileExists ( file ) ) {
// non esiste
console . log ( 'non esiste' , file ) ;
console . log ( ' filefrom' , filefrom ) ;
console . log ( ' filefrom2' , filefrom2 ) ;
}
if ( ! tools . isFileExists ( file ) && tools . isFileExists ( filefrom ) ) {
console . log ( '@@@@@@ copia file:' , filefrom , 'a' , file ) ;
tools . copy ( filefrom , file ) ;
}
if ( ! tools . isFileExists ( file ) && tools . isFileExists ( filefrom2 ) ) {
console . log ( '@@@@@@ copia file 2:' , filefrom2 , 'a' , file ) ;
tools . copy ( filefrom2 , file ) ;
}
}
}
}
}
console . log ( 'FINE - estraiImmagini' , table ) ;
} catch ( e ) {
console . error ( 'e' , e ) ;
}
}
async function estraiTutteLeImmagini ( ) {
await estraiImmagini ( 'myskills' ) ;
await estraiImmagini ( 'mygoods' ) ;
await estraiImmagini ( 'mybachecas' ) ;
}
async function faitest ( ) {
// console.log('Fai Test:')
const testfind = false ;
// const $vers = tools.getVersionint('1.92.45');
if ( true ) {
// tools.execScript("ls -la");
}
if ( false ) {
prova = tools . removeAtChar ( '@prova' ) ;
}
if ( false ) {
const prova = tools . getConfSiteOptionEnabledByIdApp ( '13' , shared _consts . ConfSite . Notif _Reg _Push _Admin ) ;
console . log ( 'prova' , prova ) ;
}
if ( testfind ) {
const { City } = require ( './models/city' ) ;
let miacity = 'roma' ;
const ris = await City . findByCity ( miacity ) ;
console . log ( 'ris' , ris ) ;
}
const { User } = require ( './models/user' ) ;
if ( false ) {
let myuser = await User . findOne ( {
idapp : '1' ,
username : 'paoloar77' ,
} ) ;
const langdest = 'it' ;
telegrambot . askConfirmationUser ( myuser . idapp , shared _consts . CallFunz . REGISTRATION , myuser ) ;
}
if ( false ) {
const user = await User . findOne ( {
idapp : 12 ,
username : 'paolotest1' ,
} ) ;
await sendemail . sendEmail _Registration ( 'it' , 'paolo@arcodiluce.it' , user ,
'12' , '' ) ;
}
if ( false ) {
const { User } = require ( './models/user' ) ;
const idapp = tools . FREEPLANET ;
const idreg = 0 ;
try {
const user = await User . findOne ( {
idapp ,
username : 'paoloar773' ,
} ) ;
user . aportador _solidario = 'paoloar77' ;
let mylocalsconf = {
idapp ,
dataemail : null ,
locale : user . lang ,
nomeapp : tools . getNomeAppByIdApp ( idapp ) ,
strlinksito : tools . getHostByIdApp ( idapp ) ,
strlinkreg : '' ,
username : user . username ,
name : user . name ,
surname : user . surname ,
forgetpwd : tools . getHostByIdApp ( idapp ) + '/requestresetpwd' ,
emailto : '' ,
user ,
} ;
await telegrambot . notifyToTelegram ( telegrambot . phase . REGISTRATION ,
mylocalsconf ) ;
} catch ( e ) {
console . log ( 'error ' + e ) ;
}
}
}
module . exports = { app } ;