diff --git a/.env.development b/.env.development index 7013049..86c5b99 100644 --- a/.env.development +++ b/.env.development @@ -1,12 +1,12 @@ -DATABASE=test_FreePlanet +DATABASE=test_PiuCheBuono UDB=paofreeplanet PDB=mypassword@1A SEND_EMAIL=0 SEND_EMAIL_ORDERS=1 PORT=3000 -appTelegram_TEST=["1","13"] -appTelegram=["1","13"] -appTelegram_DEVELOP=["13"] +appTelegram_TEST=["1","17"] +appTelegram=["1","17"] +appTelegram_DEVELOP=["17"] DOMAIN=mongodb://localhost:27017/ AUTH_MONGODB=0 ENABLE_PUSHNOTIFICATION=1 @@ -29,7 +29,7 @@ GCM_API_KEY="" PROD=0 PROJECT_DESCR_MAIN='__PROJECTS' SECRK=Askb38v23jjDFaoskBOWj92axXCQ -TOKEN_LIFE=1m +TOKEN_LIFE=2h REFRESH_TOKEN_LIFE=14d FTPSERVER_HOST=139.162.166.31 FTPSERVER_PORT=21 @@ -38,4 +38,9 @@ FTPSERVER_PWD=ftpmypwd@1A_ AUTH_NEW_SITES=123123123 SCRIPTS_DIR=admin_scripts CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}] +MIAB_HOST=box.lamiaposta.org +MIAB_ADMIN_EMAIL=admin@lamiaposta.org +MIAB_ADMIN_PASSWORD=passpao1pabox@1A DS_API_KEY="sk-222e3addb3d8455d8b0516d93906eec7" +API_KEY_MSSQL="m68yADSr123MIVIDA@154$DSAGVOK" +SERVER_A_URL="http://51.77.156.69:3000" \ No newline at end of file diff --git a/.env.prod.pcb b/.env.prod.pcb index d0a7a1c..342e5db 100644 --- a/.env.prod.pcb +++ b/.env.prod.pcb @@ -34,12 +34,12 @@ TOKEN_LIFE=2h REFRESH_TOKEN_LIFE=14d AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNVZZ DOMAINS=[{"hostname":"piuchebuono.app","port":"3030"},{"hostname":"gruppomacro.app","port":"3010"}] +DOMAINS_ALLOWED=[] SCRIPTS_DIR=admin_scripts CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}] MIAB_HOST=box.lamiaposta.org MIAB_ADMIN_EMAIL=admin@lamiaposta.org MIAB_ADMIN_PASSWORD=passpao1pabox@1A - #DB_CONNECTION=sqlsrv DB_HOST_SQLSRVTEST=31.3.180.50 DB_PORT_SQLSRVTEST=14338 diff --git a/.env.prod.riso b/.env.prod.riso index ea784f9..03a36f8 100644 --- a/.env.prod.riso +++ b/.env.prod.riso @@ -31,6 +31,7 @@ TOKEN_LIFE=2h REFRESH_TOKEN_LIFE=14d AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV DOMAINS=[{"hostname":"riso.app","port":"3006"},{"hostname":"freeplanet.app","port":"3000"}] +DOMAINS_ALLOWED=["comunitanuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"] #DOMAINS=[{"hostname":"abitaregliiblei.it","port":"3021"},{"hostname":"riso.app","port":"3005"}] SCRIPTS_DIR=admin_scripts CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}] diff --git a/.env.test.pcb b/.env.test.pcb index 69511a4..e146916 100644 --- a/.env.test.pcb +++ b/.env.test.pcb @@ -35,6 +35,7 @@ TOKEN_LIFE=2h REFRESH_TOKEN_LIFE=14d AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV DOMAINS=[{"hostname":"piuchebuono.app","port":"3031"},{"hostname":"gruppomacro.app","port":"3011"}] +DOMAINS_ALLOWED=[] SCRIPTS_DIR=admin_scripts CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}] MIAB_HOST=box.lamiaposta.org diff --git a/.env.test.risosrv b/.env.test.risosrv index e548c02..db14910 100644 --- a/.env.test.risosrv +++ b/.env.test.risosrv @@ -32,6 +32,7 @@ TOKEN_LIFE=2h REFRESH_TOKEN_LIFE=14d AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV DOMAINS=[{"hostname":"riso.app","port":"3005"}] +DOMAINS_ALLOWED=["comunitanuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"] SCRIPTS_DIR=admin_scripts CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}] MIAB_HOST=box.lamiaposta.org diff --git a/docs/aaa.json b/docs/aaa.json new file mode 100644 index 0000000..d65a988 --- /dev/null +++ b/docs/aaa.json @@ -0,0 +1,38 @@ +{ + "id": "70606", + "title": "Grande Libro dell'Autosufficienza - 50 anni - Nuovo", + "description": "\"Il Grande Libro dell\u2019Autosufficienza\"<\/strong><\/em> di John Seymour \u00e8 un manuale completo che celebra 50 anni di pratiche di autosufficienza<\/strong> e sostenibilit\u00e0<\/strong>. Il libro offre insegnamenti pratici su come creare e gestire un orto biologico<\/strong>, raccogliere e conservare i raccolti, produrre energia rinnovabile<\/strong>, allevare animali e ridurre i rifiuti. Seymour ci guida passo passo in un viaggio verso una vita in armonia con la natura, promuovendo l\u2019indipendenza e la sostenibilit\u00e0. Un testo imprescindibile per chi desidera riscoprire le tradizioni agricole e applicarle per vivere in modo pi\u00f9 sostenibile<\/strong> e autonomo<\/strong>.\r\n

Con questo libro scoprirai<\/strong>:<\/h2>\r\n
    \r\n \t
  • Come coltivare un orto biologico<\/strong> e ottenere cibo sano.<\/li>\r\n \t
  • Le tecniche per conservare il raccolto<\/strong> e ottimizzare le risorse naturali.<\/li>\r\n \t
  • Come allevare animali per ottenere cibo e altri prodotti.<\/li>\r\n \t
  • Come produrre energia rinnovabile<\/strong> e ridurre l\u2019impatto ambientale.<\/li>\r\n \t
  • L\u2019arte di ridurre e riciclare<\/strong> rifiuti, promuovendo uno stile di vita pi\u00f9 sostenibile.<\/li>\r\n<\/ul>\r\n

    Domande cruciali a cui \"Il Grande Libro dell\u2019Autosufficienza\"<\/em> risponde<\/strong>:<\/h2>\r\n
      \r\n \t
    • Come posso vivere in modo autosufficiente<\/strong> e ridurre la mia dipendenza dalle risorse esterne?<\/li>\r\n \t
    • Quali sono le migliori tecniche per coltivare un orto biologico<\/strong> e garantire un raccolto abbondante?<\/li>\r\n \t
    • Come posso conservare il raccolto<\/strong> in modo naturale e duraturo?<\/li>\r\n \t
    • In che modo posso produrre energia rinnovabile<\/strong> a casa mia?<\/li>\r\n \t
    • Come posso vivere in armonia con la natura<\/strong> e promuovere la sostenibilit\u00e0<\/strong>?<\/li>\r\n<\/ul>\r\n

      Questo libro \u00e8 dedicato a<\/strong>:<\/h2>\r\n
        \r\n \t
      • Lettori appassionati di giardinaggio<\/strong>, agricoltura biologica<\/strong> e vita rurale.<\/li>\r\n \t
      • Chiunque desideri adottare uno stile di vita sostenibile<\/strong> e autosufficiente.<\/li>\r\n \t
      • Famiglie eco-consapevoli<\/strong> che vogliono ridurre il proprio impatto ambientale.<\/li>\r\n \t
      • Amanti della natura<\/strong> e sostenitori delle energie rinnovabili<\/strong>.<\/li>\r\n<\/ul>\r\n

        Contenuti chiave \"Il Grande Libro dell\u2019Autosufficienza\"<\/em><\/strong>:<\/h2>\r\nIl Grande Libro dell\u2019Autosufficienza<\/em> offre una panoramica completa di tutte le tecniche per vivere in modo autonomo<\/strong> e sostenibile<\/strong>. Attraverso 10 capitoli, il libro esplora vari aspetti dell\u2019autosufficienza, dalla coltivazione di ortaggi e frutti alla produzione di cibo dagli animali, fino alla gestione dell'energia e dei rifiuti. La guida si focalizza sul valore delle tradizioni agricole<\/strong>, sulla cura dell\u2019ambiente e sul benessere che deriva dal vivere in sintonia con la natura.\r\n\r\n ", + "link": "https:\/\/www.fioredellavita.it\/grande-libro-dellautosufficienza-50-anni\/?attribute_pa_versione=nuovo", + "image_link": "https:\/\/www.fioredellavita.it\/wp-content\/uploads\/2024\/09\/il-grande-libro-dell-autosufficienza-speciale-50-anni-copertina-web.jpg", + "price": "39,00", + "sale_price": "37,05", + "categories": "Informazione Libera", + "isbn": "", + "Autore": "John,Seymour", + "Editore": "Macro Edizioni", + "Tipologia": "Libri", + "Collezione": "Libri Informazione Libera,Informazione Libera", + "Quantita": "1821", + "Lunghezza": "", + "Stato": "publish", + "Pagine": "", + "Edizione": "", + "Traduzione": "", + "Versione": "Nuovo", + "StockStatus": "instock", + "downloadable": "no", + "img1": "https:\/\/www.fioredellavita.it\/wp-content\/uploads\/2024\/09\/quarta_nuovo_grande_libro_dell_autosufficienza_2024_17038.jpg", + "img2": "", + "img3": "", + "formato": "Cartonato", + "preOrderDate": "2025-02-25", + "short_descr": null, + "availability": "in stock", + "checkout_link": "https:\/\/www.fioredellavita.it\/carrello\/?productId=70606", + "seo_descr": "Versione: Nuovo", + "preord": "no", + "addtocart_link": "https:\/\/www.fioredellavita.it\/grande-libro-dellautosufficienza-50-anni\/?attribute_pa_versione=nuovo&variation_id=70606&add-to-cart=70606", + "eta": "", + "misure": "cm 22x28", + "sku": "22464" +}, \ No newline at end of file diff --git a/src/server/controllers/articleController.js b/src/server/controllers/articleController.js index 0eab1ec..ac295af 100644 --- a/src/server/controllers/articleController.js +++ b/src/server/controllers/articleController.js @@ -295,7 +295,7 @@ const getTableContent = async (options) => { // Se c'è un solo record, visualizza una lista di chiavi e valori const record = records[0]; output += ` - +
        @@ -419,8 +419,11 @@ exports.viewTable = async (req, res) => { if (options.outhtml) { out = ` -

        Tabella: ${options.nameTable}

        - ${tableContent} +

        Tabella: ${options.nameTable}

        +
        Query: ${options.where}
        +
        + ${tableContent} +
        ` } else { out = tableContent; @@ -445,6 +448,7 @@ exports.queryTable = async (req, res) => { if (options.outhtml) { out = `

        Tabella: ${options.nameTable}

        +
        Query: ${options.where}
        ${tableContent} ` } else { diff --git a/src/server/router/admin_router.js b/src/server/router/admin_router.js index 877379a..2aef7f7 100755 --- a/src/server/router/admin_router.js +++ b/src/server/router/admin_router.js @@ -764,6 +764,10 @@ router.post('/import', authenticate, async (req, res) => { } } + if (!myarr && ripopola) { + return res.status(400).send(data.arrdata); + } + // Rileggi tutti i record di ImportaDescr dataObjects = await ImportaDescr.find({ idapp }).lean(); @@ -819,6 +823,11 @@ router.post('/import', authenticate, async (req, res) => { let recisbn = {}; + const trovato = await ImportaIsbn.findOne({ isbn: product.code }).lean(); + if (trovato) { + recisbn = trovato; + } + if (pagine && pagine !== '0') { recisbn.Pagine = pagine; } @@ -827,6 +836,7 @@ router.post('/import', authenticate, async (req, res) => { recisbn.descrizione_breve_macro = productInfo.descrizione_breve_macro; recisbn.descrizione_completa_macro = productInfo.descrizione_completa_macro; recisbn.sottotitolo = productInfo.sottotitolo; + // recisbn.idapp = idapp; let risisbn = await ImportaIsbn.findOneAndUpdate({ isbn: product.code }, { $set: recisbn }, { new: true, upsert: true, strict: false }); @@ -859,7 +869,6 @@ router.post('/import', authenticate, async (req, res) => { dataObjects = null; } - if (dataObjects && dataObjects[0]) { // Cancella la collection ImportaIsbn await ImportaIsbn.deleteMany({ idapp }); @@ -883,6 +892,8 @@ router.post('/import', authenticate, async (req, res) => { let queryprod = { idapp, sku: recmacro.sku }; + // 13872 + try { let risrec = await ImportaIsbn.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false }); if (risrec) { @@ -1112,6 +1123,8 @@ router.post('/import', authenticate, async (req, res) => { let numprod = dataObjects.length; + let nontrovati = 0; + for (const product of dataObjects) { let isnuovo = false let setta = false @@ -1127,6 +1140,19 @@ router.post('/import', authenticate, async (req, res) => { // split versioneGM in array with separated "," let arrversGM = versGM.split(",").map(x => x.trim()); + // se non esiste l'ISBN, allora me lo cerco in base a sku ! + + if (!product.isbn) { + const rectrovare = await ImportaIsbn.findOne({ sku: product.sku }).lean(); + if (rectrovare) { + product.isbn = rectrovare.isbn; + } else { + nontrovati++; + console.log(`${nontrovati} - ISBN non trovato [sku=${product.sku} title=${product.title}]`) + } + + } + let productInfo = { idapp: product.idapp, code: product.isbn, diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index e49538d..c76baa3 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -2031,8 +2031,8 @@ async function load(req, res, version = '0') { const { data, totalTime, slowCalls } = await measurePromises(promises); // console.log('Risultati delle promise:', data); - console.log('Tempo totale di esecuzione:', totalTime, 'secondi'); - console.log('Le 5 chiamate più lente:', slowCalls); + // console.log('Tempo totale di esecuzione:', totalTime, 'secondi'); + // console.log('Le 5 chiamate più lente:', slowCalls); // Aggiornamento delle informazioni dell'utente, se presente let myuser = req.user; diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index f144f8a..ebac601 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -682,6 +682,8 @@ router.post('/newtok', async (req, res) => { try { const refreshToken = req.body.refreshToken; + // return res.status(403).send({ error: 'Refresh token non valido' }); + if (!refreshToken) { return res.status(400).send({ error: 'Refresh token mancante' }); } @@ -689,7 +691,7 @@ router.post('/newtok', async (req, res) => { const recFound = await User.findOne({ 'tokens.refreshToken': refreshToken }); if (!recFound) { - return res.status(404).send({ error: 'Refresh token non valido' }); + return res.status(403).send({ error: 'Refresh token non valido' }); } const { token, refreshToken: newRefreshToken } = await recFound.generateAuthToken(req); diff --git a/src/server/server.js b/src/server/server.js index b806bf3..4a352b0 100755 --- a/src/server/server.js +++ b/src/server/server.js @@ -763,10 +763,13 @@ connectToDatabase(connectionUrl, options) const isProduction = ['production', 'test'].includes(process.env.NODE_ENV); let domains = []; + let domains_allowed = []; try { if (process.env.DOMAINS) domains = JSON.parse(process.env.DOMAINS); + if (process.env.DOMAINS_ALLOWED) + domains_allowed = JSON.parse(process.env.DOMAINS_ALLOWED); } catch (error) { console.error("Errore durante la conversione della stringa DOMAINS:", error); } @@ -805,17 +808,23 @@ connectToDatabase(connectionUrl, options) `https://api.${domain.hostname}`, `https://test.${domain.hostname}`, `https://testapi.${domain.hostname}`, - `https://comunitanuovomondo.app`, - `https://kolibrilab.it`, - `https://artenergetica.org`, - `https://freeplanet.app:3001`, `http://${domain.hostname}`, `http://api.${domain.hostname}`, `http://test.${domain.hostname}`, `http://testapi.${domain.hostname}` ]); + + // Aggiungi i domini da DOMAINS_ALLOWED + allowedOrigins = allowedOrigins.concat( + domains_allowed.map(domain => [ + `https://${domain}`, + `http://${domain}` + ]).flat() + ); } + console.log('allowedOrigins', allowedOrigins) + let myorigin = '*'; @@ -823,6 +832,10 @@ connectToDatabase(connectionUrl, options) myorigin = (origin, callback) => { try { // Validazione dell'input + if (origin === undefined) { + console.log('✅ Origin UNDEFINED... vado avanti lo stesso !'); + return callback(null, true); + } if (!origin || typeof origin !== 'string' || !/^https?:\/\/[^\s/$.?#].[^\s]*$/.test(origin)) { console.error('❌ Origine non valida:', origin); return callback(new Error('Origine non valida'), false); @@ -830,7 +843,7 @@ connectToDatabase(connectionUrl, options) // Controllo delle origini consentite if (allowedOrigins.includes(origin)) { - console.log('✅ Origine consentita:', origin); + // console.log('✅ Origine consentita:', origin); return callback(null, true); } @@ -939,10 +952,10 @@ connectToDatabase(connectionUrl, options) const keyStream = path.resolve(`./${process.env.PATH_CERT_KEY}`); const certificateStream = path.resolve(`./${process.env.PATH_SERVER_CRT}`); - + const privateKey = fs.readFileSync(keyStream, "utf8"); const certificate = fs.readFileSync(certificateStream, "utf8"); - + mycredentials = { key: privateKey, cert: certificate, diff --git a/src/server/tools/general.js b/src/server/tools/general.js index d16912e..8d0b255 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -5831,7 +5831,7 @@ module.exports = { } if (mov.groupfrom) { userfrom += mov.groupfrom.groupname - tipocontofrom = shared_consts.AccountType.COLLECTIVE_ACCOUNT + tipocontofrom = shared_consts.AccountType.CONTO_DI_GRUPPO } if (mov.userfrom) { userfrom += mov.userfrom.username @@ -5844,7 +5844,7 @@ module.exports = { } if (mov.groupto) { userto += mov.groupto.groupname - tipocontoto = shared_consts.AccountType.COLLECTIVE_ACCOUNT + tipocontoto = shared_consts.AccountType.CONTO_DI_GRUPPO } if (mov.userto) { userto += mov.userto.username diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js index df7db3f..0e983be 100755 --- a/src/server/tools/shared_nodejs.js +++ b/src/server/tools/shared_nodejs.js @@ -824,7 +824,7 @@ module.exports = { sector: 1, recCatGrp: 1, mycircuits: 1, - lastdate_reqRisGroup: 1, + lastdate_reqRisGroup: 1, } } else if (table === this.TABLES_CIRCUITS) { proj = { @@ -1165,7 +1165,7 @@ module.exports = { AUDIOLIBRO: 22, VIDEO: 23, CARTE: 25, - // ----------- + // ----------- NUOVO: 101, USATO: 102, DOWNLOAD: 103, @@ -1180,7 +1180,7 @@ module.exports = { AccountType: { USER: 0, - COLLECTIVE_ACCOUNT: 1, + CONTO_DI_GRUPPO: 1, COMMUNITY_ACCOUNT: 2, }, @@ -1189,7 +1189,7 @@ module.exports = { SET: 1, }, - SENDRIS_CODES: { + SENDRIS_CODES: { EXCEED_FIDO: 10, EXCEED_QTAMAX: 20, }, diff --git a/src/server/version.txt b/src/server/version.txt index 280fc9d..828cb60 100644 --- a/src/server/version.txt +++ b/src/server/version.txt @@ -1 +1 @@ -1.2.29 \ No newline at end of file +1.2.32 \ No newline at end of file
        Campo