51 Commits

Author SHA1 Message Date
Surya Paolo
8e42baf79e bottoni fiducia 2023-11-30 19:50:12 +01:00
Surya Paolo
e3ed2934ee Struttura Scheda Prodotti... 2023-11-30 14:27:37 +01:00
Surya Paolo
e895e7dae2 ignore 2023-11-30 01:49:51 +01:00
Surya Paolo
4a408b4ebd Riso: Ris Italia, altre modifiche grafiche
Lista Utenti da Verificare
2023-11-30 01:49:17 +01:00
Surya Paolo
0e3ba5ff87 agg 2023-11-28 15:04:17 +01:00
Surya Paolo
a66cd610dd Develop PDB 1 2023-11-28 14:20:22 +01:00
Surya Paolo
5aa6accfc5 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-27 16:42:52 +01:00
Surya Paolo
35178684af aaa 2023-11-27 16:42:44 +01:00
Surya Paolo
bba0df4302 aa 2023-11-27 14:43:13 +01:00
Surya Paolo
f1954d98d6 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-27 11:16:13 +01:00
Surya Paolo
34b00bdf98 ds 2023-11-27 11:16:09 +01:00
Surya Paolo
0cfabed233 - tutorial Circuito Ris Italia
- Invia RIS (visibile per tutti)
2023-11-26 01:38:02 +01:00
Surya Paolo
c92dc8f216 fixed: se aggiungo una Provincia sul frontend non si aggiungeva 2023-11-24 17:52:17 +01:00
Surya Paolo
7b14c09fd5 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-23 16:06:38 +01:00
Surya Paolo
2258e8e7e1 aaa 2023-11-23 16:06:20 +01:00
Surya Paolo
e8c961f500 aaa 2023-11-23 15:58:13 +01:00
Surya Paolo
b395d1a30a aaa 2023-11-23 15:57:02 +01:00
Surya Paolo
341af6a3b2 test 2 2023-11-23 15:55:55 +01:00
Surya Paolo
3d876687b6 Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop 2023-11-23 15:55:16 +01:00
Surya Paolo
560a532a85 aaa 2023-11-23 15:33:45 +01:00
Surya Paolo
aac8ce0a4c ok 2023-11-23 12:45:27 +01:00
Surya Paolo
d434374ed9 Click per mandare un messaggio al Destinatario dei RIS, se non è entrato ancora in RIS ITALIA. 2023-11-19 23:40:38 +01:00
Surya Paolo
045057082c Se aggiorno il fido e massimo di un circuito, devo aggiornare anche tutti gli account dei Circuiti Nazionali 2023-11-15 18:23:10 +01:00
Surya Paolo
18c5630a45 Quando accedi al Circuito RIS Nazionale, ti imposta il Fido e QtaMax DOPPIA rispetto al tuo Circuito Locale 2023-11-15 17:50:14 +01:00
Surya Paolo
7f1bd15bcf ver 1.0.19 2023-11-03 12:49:10 +01:00
Surya Paolo
c1a9a9a555 Versione 1.0.17
- Fix saldo pendente
- aggiunto bottone markup Telegram
- aggionta opzione per registrarsi direttamente su Telegram, senza doversi registrare ad un sito
2023-10-21 15:27:53 +02:00
Surya Paolo
536fbd1752 - se iOS non ricarica la pagina ma disinstalla il SW precedente e chiede di riavviare
- fixed: Creando un Conto di Gruppo, pare che venga impostato anche l'username... invece dev'essere solo il groupname
-
2023-10-03 23:16:52 +02:00
Surya Paolo
d6303f5880 Merge branch 'develop' of gitlab.com:surya89/freeplanet_serverside into develop 2023-10-03 00:44:24 +02:00
Surya Paolo
b6579832b6 correzione numseen, numfav, ...: ora li ho aggiunti alle tabelle... 2023-10-03 00:40:42 +02:00
Surya Paolo
04c8e929ee - Migliorata la Notifica degli Eventi su Telegram
- Gli annunci (beni/servizi/ospitalità) ora possono essere visti anche tramite un link, anche per chi non è dentro alla App.
- Aggiunto bottone "Aggiorna" per aggiornare il Saldo attuale.
- I "Conti Collettivi" ora vengono chiamati Gruppi (o Conto di Gruppo).
2023-10-01 01:24:47 +02:00
Surya Paolo
142dcadca9 Fixed: le reactions devono stare in una tabella a parte (reactions).
- cambiata la gestione dei seen, fav, book, attend
2023-09-27 18:38:57 +02:00
Surya Paolo
ad6b4c2bfa Modifiche prima di Luglio... 2023-08-27 23:55:31 +02:00
Surya Paolo
ba81a33c88 l'admin non riesce a cambiare il fido degli utenti... 2023-06-20 01:07:57 +02:00
Surya Paolo
baf56b59d0 default min e max fido e accumulo, per Circuito 2023-06-19 00:47:13 +02:00
Surya Paolo
3393af36aa la creazione dell'annuncio impiega troppo tempo (e le persone cliccavano su "Salva" più volte)... 2023-06-18 22:29:06 +02:00
Surya Paolo
95a812f002 - transazioni pendenti errore fixed (Elena) 2023-06-15 23:30:48 +02:00
Surya Paolo
aff50b03d4 Controllare che le notifiche per gli Eventi arrivino agli utenti (se io sono in una provincia mi deve arrivare almeno quella) 2023-06-07 18:46:04 +02:00
Surya Paolo
e28cd5f043 Poter modificare i limiti min e max su di 1 circuito specifico 2023-06-07 12:41:01 +02:00
Surya Paolo
9e499b8f43 Notifica Telegram e Push quando mandi la stretta di mano 2023-06-07 10:14:57 +02:00
Surya Paolo
84328e7bcd Filtra Ricerca... 2023-06-05 16:36:00 +02:00
Surya Paolo
a79e79a85e - L'utente entra direttamente sul circuito, con fido a zero.
++Abilitazione Fido utente (per admin).
2023-06-01 11:39:53 +02:00
Surya Paolo
0945f1af08 ++ aggiunta la prenotazione negli eventi. con la lista degli utenti. 2023-04-17 00:11:36 +02:00
Surya Paolo
eea6e63c58 aggiunto "Seen" 2023-04-13 14:27:00 +02:00
Surya Paolo
cda0bff21f set notif if service your province 2023-04-13 13:46:48 +02:00
Surya Paolo
cada7aa0b6 favorite: send if alert active 2023-04-12 16:29:22 +02:00
Surya Paolo
f13786fca1 fix: ordinamento membri (namecomplete (concat: name, surname, username) 2023-04-12 15:37:54 +02:00
Surya Paolo
5bb6611384 Revert "Aggiornamento a 0.6.1"
This reverts commit 198b5914bc.
2023-04-07 21:02:33 +02:00
Surya Paolo
0d5bff5849 Revert "cambio nome ai circuiti"
This reverts commit 6d1ad4132f.
2023-04-07 17:19:59 +02:00
Surya Paolo
198b5914bc Aggiornamento a 0.6.1 2023-04-07 17:14:44 +02:00
Surya Paolo
94ef2c4c85 nuova veste grafica: myskills, mygoods, mybachecas, myhosps,
- cambiato id (da numero a stringa)
2023-04-07 02:45:21 +02:00
Surya Paolo
8a77dabc22 new version Visualizzazione Service 2023-04-04 15:26:56 +02:00
76 changed files with 15668 additions and 12077 deletions

BIN
.DS_Store vendored

Binary file not shown.

4
.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
./node_modules
Dockerfile
.dockerignore
docker-compose.yml

5
.gitignore vendored
View File

@@ -25,3 +25,8 @@ src/.DS_Store
.gitignore
src/server/router/.DS_Store
src/server/.DS_Store
emails/.DS_Store
.DS_Store
.DS_Store
.DS_Store
logtrans.txt

46
.vscode/launch.json vendored
View File

@@ -2,6 +2,48 @@
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via Nodemon",
"program": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"restart": true,
"runtimeExecutable": "node",
"runtimeArgs": [
"--inspect=9229" // Use "--inspect=0.0.0.0:9229" for remote debugging
],
"args": ["${workspaceFolder}/src/server/server.js"], // Replace with your entry file
"cwd": "${workspaceFolder}",
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"env": {
"NODE_ENV":"development",
"TESTING_ON":"1"
},
},
{
"type": "node",
"request": "launch",
"name": "Launch Trace Warning",
"program": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"restart": true,
"runtimeExecutable": "node",
"runtimeArgs": [
"--trace-warnings" // Use "--inspect=0.0.0.0:9229" for remote debugging
],
"args": ["${workspaceFolder}/src/server/server.js"], // Replace with your entry file
"cwd": "${workspaceFolder}",
"autoAttachChildProcesses": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"env": {
"NODE_ENV":"development",
"TESTING_ON":"1"
},
},
{
"name": "Server Debug",
"request": "launch",
"runtimeArgs": [
@@ -12,6 +54,10 @@
"skipFiles": [
"<node_internals>/**"
],
"env": {
"NODE_ENV":"development",
"TESTING_ON":"1"
},
"type": "node"
},
{

7
Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM node:alpine
WORKDIR /Users/suryapaolo/myproject/freeplanet_serverside
COPY package*.json .
RUN npm ci
COPY . .
#CMD ["npm", "start"]
CMD ["npm", "run", "dev"]

18
deploy_solo1.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
source ./.env.production
msg="*** SERVER DI PRODUZIONE **** SEI SICURO DI INVIARE IL SINGOLO FILE GENERAL.JS - SUL SERVER DI PRODUZIONE ?? $SERVERDIR_WEBSITE (Y/N) ? "
if [ "$1" = "" ]; then
read -p "$msg" risposta
else
echo $msg
risposta=$1
fi
if [[ $risposta == "Y" || $risposta == "y" ]]; then
echo "Sincronizzazione di 1 FILE in corso..."
rsync -avz -e 'ssh -p 8855' src/server/tools/general.js suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/src/server/tools/general.js
echo "Sincronizzazione TERMINATA - SERVER PRODUZIONE!"
fi

30
docker-compose.yml Normal file
View File

@@ -0,0 +1,30 @@
version: '3.9'
services:
# mongoDB service
mongo_db:
container_name: db_container
image: mongo:4.4
restart: always
ports:
- 2717:27017
volumes:
- mongo_db:/data/db
# Node API service
api:
build: .
ports:
- 4000:3000
volumes:
- .:/Users/suryapaolo/myproject/freeplanet_serverside
environment:
PORT: 3000
DOMAIN: mongodb://mongo_db:27017/
DATABASE: test_FreePlanet
UDB: paofreeplanet
depends_on:
- mongo_db
volumes:
mongo_db: {}

BIN
emails/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,5 +1,6 @@
p Ciao,
p Ti avvisiamo che #{username} (#{name} #{surname}) ha appena cancellato la prenotazione per l'evento #{event}:
span #{msgbooking}
span #{participants}
span #{participantsLunch}
span #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao,
p Ti confermiamo che #{username} (#{name} #{surname}) ha appena inviato una richiesta di prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao,
p Ti confermiamo che #{username} (#{name} #{surname}) ha appena Modificato la sua prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

BIN
emails/admin/registration/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,5 +1,6 @@
p Ciao #{name},
p Ti confermiamo che la prenotazione per l'evento "#{event}" è stata cancellata.
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao #{name},
p Ti confermiamo che hai appena inviato una richiesta di prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -1,5 +1,6 @@
p Ciao #{name},
p Ti confermiamo che hai modificato la prenotazione per l'evento #{event}
p #{msgbooking}
p #{participants}
p #{participantsLunch}
p #{participantsDinner}

View File

@@ -25,3 +25,71 @@ Gio 05/01 ORE 19:28: USER [paoloar77]: vai al sito
Gio 05/01 ORE 19:28: USER [paoloar77]: link da condividere
Gio 16/02 ORE 18:14: USER [paoloar77]: vai al sito
Mar 06/06 ORE 19:39: USER [paoloar77]: ciaooooooooooooooooo
Mar 06/06 ORE 19:54: USER [paoloar77]: dasjdalksjdasdklasjkldasjlkdjasl
Sab 17/06 ORE 20:03: USER [paoloar77]: pro v adsasdasdaksdas
Dom 18/06 ORE 19:22: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:42: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:58: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
Ven 23/06 ORE 14:08: USER [paoloar77]: link da condividere
Sab 30/09 ORE 00:21: USER [SuryaArena]: vai al sito
Sab 30/09 ORE 00:32: USER [SuryaArena]: vai al sito
Gio 12/10 ORE 11:11: USER [paoloar77]: prova
Gio 12/10 ORE 11:48: USER [paoloar77]: prova
Gio 12/10 ORE 12:07: USER [SuryaArena]: prova
Gio 12/10 ORE 12:07: USER [SuryaArena]: prova
Gio 12/10 ORE 12:09: USER [SuryaArena]: prova
Gio 12/10 ORE 12:10: USER [SuryaArena]: prova
Gio 12/10 ORE 12:10: USER [SuryaArena]: prova
Gio 12/10 ORE 12:13: USER [SuryaArena]: prova
Gio 12/10 ORE 12:14: USER [SuryaArena]: prova
Gio 12/10 ORE 12:16: USER [SuryaArena]: prova
Gio 12/10 ORE 12:21: USER [SuryaArena]: prova
Gio 12/10 ORE 12:33: USER [paoloar77]: prova
Gio 12/10 ORE 12:33: USER [SuryaArena]: ciao
Gio 12/10 ORE 12:33: USER [SuryaArena]: prova
Gio 12/10 ORE 12:45: USER [SuryaArena]: bottone
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
Gio 12/10 ORE 14:52: USER [paoloar77]: bottone
Gio 12/10 ORE 14:57: USER [paoloar77]: bottone
Gio 12/10 ORE 15:06: USER [paoloar77]: bottone
Ven 13/10 ORE 11:05: USER [SuryaArena]: bottone
Ven 13/10 ORE 11:40: USER [SuryaArena]: bottone

27
logevents.txt Normal file
View File

@@ -0,0 +1,27 @@
Mar 06/06 ORE 19:06: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:07: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:38: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:39: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
ciaooooooooooooooooo
Mar 06/06 ORE 19:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
Mar 06/06 ORE 19:54: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
dasjdalksjdasdklasjkldasjlkdjasl
Sab 17/06 ORE 20:03: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
pro v adsasdasdaksdas
Dom 18/06 ORE 19:22: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
/start inv
Ven 23/06 ORE 14:13: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Dom 25/06 ORE 16:11: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Ven 29/09 ORE 23:18: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!

View File

@@ -5,3 +5,115 @@ Lun 06/02 ORE 23:17: Inviate Monete da paoloar77 a surya1977 1 RISTEST [causale:
Dom 12/03 ORE 13:35: Inviate Monete da paoloar77 a 1 RIS [causale: ] [Saldo paoloar77: 3 RIS] [Saldo : 2 RIS]
Mer 15/03 ORE 22:15: Inviate Monete da pontiUmani (paoloar77) a paoloar77 1 RIS [causale: ] [Saldo pontiUmani (paoloar77): 1 RIS] [Saldo paoloar77: 4 RIS]
Mer 15/03 ORE 22:37: Inviate Monete da pontiUmani (paoloar77) a surya1977 1 RIS [causale: ] [Saldo pontiUmani (paoloar77): 0 RIS] [Saldo surya1977: 1 RIS]
Ven 28/04 ORE 01:33: Inviate Monete da surya1977 a risotest 1 RISTEST [causale: ] [Saldo surya1977: 0 RISTEST] [Saldo risotest: 9.5 RISTEST]
Gio 01/06 ORE 12:22: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -2 RIS] [Saldo surya1977: 1 RIS]
Gio 01/06 ORE 12:25: Inviate Monete da paoloar77 a surya1977 2 RIS [causale: ] [Saldo paoloar77: -4 RIS] [Saldo surya1977: 3 RIS]
Gio 01/06 ORE 12:31: Inviate Monete da paoloar77 a surya1977 4 RIS [causale: ] [Saldo paoloar77: -8 RIS] [Saldo surya1977: 7 RIS]
Gio 01/06 ORE 17:26: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -9 RIS] [Saldo surya1977: 8 RIS]
Gio 01/06 ORE 17:41: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -10 RIS] [Saldo surya1977: 9 RIS]
Ven 02/06 ORE 19:29: Inviate Monete da paoloar77 a 2 RIS [causale: ] [Saldo paoloar77: 8 RIS] [Saldo : -261 RIS]
Ven 02/06 ORE 19:31: Inviate Monete da paoloar77 a pontiUmani 4 RIS [causale: ] [Saldo paoloar77: 0 RIS] [Saldo pontiUmani: -253 RIS]
Lun 26/06 ORE 23:23: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da risragusa (paoloar77) a paogruppo2 300 RIS [causale: aaa]
Saldi:
risragusa (paoloar77): -300 RIS]
paogruppo2: 300 RIS]
Lun 26/06 ORE 23:27: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da paoloar77 a paogruppo2 20 RIS [causale: ]
Saldi:
paoloar77: -20 RIS]
paogruppo2: 320 RIS]
Sab 30/09 ORE 13:32: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 1 RIS [causale: aaa]
Saldi:
SuryaArena: -1 RIS]
paoloar77: 11 RIS]
Lun 09/10 ORE 09:04: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -2 RIS]
SuryaArena2: 1 RIS]
Lun 09/10 ORE 09:21: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -3 RIS]
SuryaArena2: 2 RIS]
Lun 09/10 ORE 10:25: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -4 RIS]
SuryaArena2: 3 RIS]
Lun 09/10 ORE 10:26: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -5 RIS]
SuryaArena2: 4 RIS]
Lun 09/10 ORE 23:26: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -2 RIS]
SuryaArena2: 1 RIS]
Lun 09/10 ORE 23:36: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -3 RIS]
SuryaArena2: 2 RIS]
Lun 09/10 ORE 23:36: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -4 RIS]
SuryaArena2: 3 RIS]
Mar 10/10 ORE 00:04: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -5 RIS]
SuryaArena2: 4 RIS]
Mar 10/10 ORE 00:21: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -6 RIS]
SuryaArena2: 5 RIS]
Mar 10/10 ORE 00:34: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -7 RIS]
SuryaArena2: 6 RIS]
Mar 10/10 ORE 22:47: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -8 RIS]
PaoTEST1: 1 RIS]
Mar 10/10 ORE 22:49: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -9 RIS]
PaoTEST1: 2 RIS]
Mar 10/10 ORE 23:08: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 2 RIS [causale: ]
Saldi:
paoloar77: -11 RIS]
PaoTEST1: 4 RIS]
Mar 10/10 ORE 23:13: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 3 RIS [causale: ]
Saldi:
paoloar77: -14 RIS]
PaoTEST1: 7 RIS]
Mar 10/10 ORE 23:22: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -15 RIS]
PaoTEST1: 8 RIS]
Mer 11/10 ORE 22:33: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -16 RIS]
PaoTEST1: 9 RIS]
Gio 12/10 ORE 08:05: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
Saldi:
paoloar77: -17 RIS]
PaoTEST1: 10 RIS]
Gio 12/10 ORE 08:06: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
Saldi:
paoloar77: -18 RIS]
SuryaArena2: 7 RIS]
Mer 29/11 ORE 16:35: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 5 RIS [causale: Seconda]
Saldi:
SuryaArena: -5 RIS]
paoloar77: 5 RIS]
Mer 29/11 ORE 16:44: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Eccolo]
Saldi:
SuryaArena: -8 RIS]
paoloar77: 8 RIS]
Mer 29/11 ORE 16:50: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Ricevuto un bel massaggio]
Saldi:
SuryaArena: -11 RIS]
paoloar77: 11 RIS]
Mer 29/11 ORE 16:52: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 4 RIS [causale: Un bel massaggio con olio caldo]
Saldi:
SuryaArena: -4 RIS]
paoloar77: 14 RIS]
Mer 29/11 ORE 17:14: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 2 RIS [causale: Massaggio !]
Saldi:
SuryaArena: -13 RIS]
paoloar77: 13 RIS]

View File

@@ -10,91 +10,345 @@ let aggregation = [
{
$match: {
idapp: "13",
},
},
{
$sort: {
date_updated: -1,
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
"profile.resid_card": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "goods",
localField: "idGood",
foreignField: "_id",
as: "recGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$recGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
"profile.resid_card": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "sectorgoods",
localField: "idSectorGood",
foreignField: "_id",
as: "sectorGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$sectorGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "cities",
localField: "idCity",
foreignField: "_id",
as: "mycities",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$mycities",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$match: {
$or: [
{
deleted: {
$exists: false,
},
$and: [
{
"profile.mygroups": {
$elemMatch: {
groupname: {
$in: [
"000017",
"risoprova",
"VillaggiamoItalia",
"Terraw",
"RisoBenevento",
"111",
"gruppodefaultriso",
"pontiUmani",
],
},
},
},
},
{
pub_to_share: 1,
},
],
},
{
deleted: {
$exists: true,
$eq: false,
},
$or: [
{
pub_to_share: {
$exists: false,
},
},
{
pub_to_share: {
$exists: true,
$eq: 0,
},
},
],
},
],
},
},
{
$match: {
$and: [
{
"mycities.reg": "EMR",
},
],
},
},
{
$group: {
_id: "$aportador_solidario",
_id: null,
count: {
$sum: 1,
},
},
},
{
$match: { "count": { $gte: 2 } }
},
{
$sort: {
count: -1,
},
},
{
$lookup: {
from: "users",
let: {
username: "$_id",
idapp: "13",
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$$username",
"$username",
],
},
{
$eq: [
"$$idapp",
"$idapp",
],
},
],
},
},
},
],
as: "user",
},
},
{ $unwind: "$user" },
{
$replaceRoot: {
newRoot: {
$mergeObjects: [ "$user", "$$ROOT" ],
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
_id: 0,
count: 1,
aportador_solidario: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
idapp: 1,
"profile.img": 1,
rows: {
$slice: [
"$results",
0,
10,
],
},
},
},
];
db.users.aggregate(aggregation);
db.myskills.aggregate(aggregation);

432
mongodb/Favorite.mongodb Normal file
View File

@@ -0,0 +1,432 @@
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
},
},
{
$sort: {
date_updated: -1,
},
},
{
$lookup: {
from: "users",
let: {
tab: 1,
id: "$_id",
},
pipeline: [
{
$unwind: "$profile.favorite",
},
{
$match: {
$expr: {
$and: [
{
$eq: [
"$profile.favorite.id",
"$$id",
],
},
{
$eq: [
"$profile.favorite.tab",
"$$tab",
],
},
{
$eq: [
"$idapp",
"13",
],
},
],
},
},
},
{ $project: { username: 1, _id: 0 } },
],
as: "myfav",
},
},
{
$lookup: {
from: "users",
let: {
tab: 1,
id: "$_id",
},
pipeline: [
{
$unwind: "$profile.bookmark",
},
{
$match: {
$expr: {
$and: [
{
$eq: [
"$profile.bookmark.id",
"$$id",
],
},
{
$eq: [
"$profile.bookmark.tab",
"$$tab",
],
},
],
},
},
},
],
as: "mybook",
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
},
},
{
$lookup: {
from: "skills",
localField: "idSkill",
foreignField: "_id",
as: "recSkill",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$recSkill",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
},
},
{
$lookup: {
from: "sectors",
localField: "idSector",
foreignField: "_id",
as: "sector",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$sector",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
myseen: 1,
},
},
{
$lookup: {
from: "cities",
localField: "idCity",
foreignField: "_id",
as: "mycities",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$mycities",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
myfav: 1,
mybook: 1,
},
},
{
$match: {
$or: [
{
$and: [
{
"profile.mygroups": {
$elemMatch: {
groupname: {
$in: [
"000017",
"risoprova",
"VillaggiamoItalia",
"Terraw",
"RisoBenevento",
"111",
"gruppodefaultriso",
"pontiUmani",
],
},
},
},
},
{
pub_to_share: 1,
},
],
},
{
$or: [
{
pub_to_share: {
$exists: false,
},
},
{
pub_to_share: {
$exists: true,
$eq: 0,
},
},
],
},
],
},
},
{
$match: {
$and: [
{
"mycities.reg": "EMR",
},
],
},
},
{
$group: {
_id: null,
count: {
$sum: 1,
},
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
count: 1,
rows: {
$slice: [
"$results",
0,
10,
],
},
},
},
];
db.myskills.aggregate(aggregation);

203
mongodb/Members.mongodb Normal file
View File

@@ -0,0 +1,203 @@
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
"profile.mycircuits": {
$elemMatch: {
circuitname: {
$eq: "Circuito RIS Bologna",
},
},
},
},
},
{
$lookup: {
from: "circuits",
as: "circuit",
let: {
circuitname: "Circuito RIS Bologna",
idapp: "$idapp",
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$name",
"$$circuitname",
],
},
{
$eq: [
"$idapp",
"$$idapp",
],
},
],
},
},
},
],
},
},
{
$unwind: "$circuit",
},
{
$project: {
username: 1,
name: 1,
surname: 1,
date_reg: 1,
profile: 1,
idapp: 1,
"circuit.name": 1,
"circuit._id": 1,
},
},
{
$lookup: {
from: "accounts",
as: "account",
let: {
username: "$username",
idapp: "$idapp",
circuitId: "$circuit._id",
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$$username",
"$username",
],
},
{
$eq: [
"$$idapp",
"$idapp",
],
},
{
$eq: [
"$$circuitId",
"$circuitId",
],
},
],
},
},
},
],
},
},
{
$unwind: "$account",
},
{
$match: {
idapp: "13",
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
namecomplete: {
$concat: [
{
$toLower: "$name",
},
{
$toLower: "$surname",
},
{ $toLower: "$username" },
],
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
username: 1,
name: 1,
surname: 1,
"profile.img": 1,
"profile.mycircuits": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
"account._id": 1,
"account.saldo": 1,
"account.fidoConcesso": 1,
"account.qta_maxConcessa": 1,
"account.totTransato": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
namecomplete: 1,
date_reg: 1,
},
},
{
$sort: {
date_reg: 1,
},
},
{
$group: {
_id: null,
count: {
$sum: 1,
},
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
count: 1,
rows: {
$slice: [
"$results",
1,
15,
],
},
},
},
];
db.users.aggregate(aggregation);

352
mongodb/MySkills.mongodb Normal file
View File

@@ -0,0 +1,352 @@
// MongoDB Playground
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
// Make sure you are connected to enable completions and to be able to run a playground.
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
// Select the database to use.
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
},
},
{
$sort: {
date_updated: -1,
},
},
{
$addFields: {
myId1: {
$toObjectId: "$userId",
},
},
},
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "goods",
localField: "idGood",
foreignField: "_id",
as: "recGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$recGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "sectorgoods",
localField: "idSectorGood",
foreignField: "_id",
as: "sectorGood",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$sectorGood",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$lookup: {
from: "cities",
localField: "idCity",
foreignField: "_id",
as: "mycities",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$mycities",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
recGood: 1,
sectorGood: 1,
idSectorGood: 1,
idGood: 1,
mygood: 1,
idStatusSkill: 1,
idContribType: 1,
"profile.username_telegram": 1,
"profile.favorite": 1,
"profile.bookmark": 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
comune: 1,
mycities: 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
},
{
$match: {
$or: [
{
$and: [
{
"profile.mygroups": {
$elemMatch: {
groupname: {
$in: [
"000017",
"risoprova",
"VillaggiamoItalia",
"Terraw",
"RisoBenevento",
"111",
"gruppodefaultriso",
"pontiUmani",
],
},
},
},
},
{
pub_to_share: 1,
},
],
},
{
$or: [
{
pub_to_share: {
$exists: false,
},
},
{
pub_to_share: {
$exists: true,
$eq: 0,
},
},
],
},
],
},
},
{
$match: {
$and: [
{
"mycities.reg": "EMR",
},
],
},
},
{
$group: {
_id: null,
count: {
$sum: 1,
},
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
count: 1,
rows: {
$slice: [
"$results",
0,
10,
],
},
},
},
];
db.myskills.aggregate(aggregation);

View File

@@ -278,3 +278,11 @@ if (test) {
// Use toArray() to exhaust the cursor to return the whole result set.
// You can use hasNext()/next() to iterate through the cursor page by page.
db.users.aggregate(aggregation);
db.getCollection('myskills').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('mygoods').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('mybachecas').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('myhosps').deleteMany({ '_id': { $lte: 10000 }})
db.getCollection('mygroups').deleteMany({ '_id': { $lte: 10000 }})

View File

@@ -0,0 +1,23 @@
use('test_FreePlanet');
let aggregation = [
{
$match: {
idapp: "13",
"profile.favorite": {
$elemMatch:
{ id: '10256', tab: 4 }
}
},
},
{
$group:
{
_id: null,
count: { $sum: 1 },
}
},
{ $project: { _id: 0 } }
];
db.users.aggregate(aggregation);

View File

@@ -4,7 +4,8 @@
"description": "freeplanet serverside",
"main": "server/server.js",
"scripts": {
"start": "NODE_ENV=development nodemon src/server/server.js",
"start": "node src/server/server.js",
"dev": "NODE_ENV=development nodemon src/server/server.js",
"build": "gulp build",
"watch": "gulp watch",
"test": "export NODE_ENV=development || SET NODE_ENV=development && mocha src/server/**/*.test.js",
@@ -13,7 +14,7 @@
"test-watch": "nodemon --exec 'npm test'"
},
"engines": {
"node": "^16.14.0"
"node": "^16.19.0"
},
"author": "Paolo Arena",
"license": "MIT",
@@ -35,8 +36,8 @@
"i18n": "^0.15.0",
"image-downloader": "^4.3.0",
"internet-available": "^1.0.0",
"jade": "^1.11.0",
"jsonwebtoken": "^8.5.1",
"jade": "^1.9.2",
"jsonwebtoken": "^9.0.1",
"lodash": "^4.17.21",
"mongodb": "^4.4.1",
"mongoose": "^5.13.15",
@@ -53,7 +54,7 @@
"pug": "^3.0.2",
"rate-limiter-flexible": "^2.3.9",
"save": "^2.5.0",
"sharp": "0.30.0",
"sharp": "^0.30.7",
"superagent": "^8.0.0",
"url-parse": "^1.5.10",
"validator": "^13.7.0",
@@ -63,15 +64,15 @@
"devDependencies": {
"browser-sync": "^2.27.10",
"expect": "^29.0.2",
"gulp": "^4.0.2",
"gulp-inline-css": "^4.0.0",
"gulp": "^3.9.1",
"gulp-inline-css": "^2.0.0",
"gulp-pug": "^5.0.0",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.1.3",
"gulp-sass": "^5.1.0",
"jest": "^29.0.2",
"mocha": "^10.0.0",
"nodemon": "^2.0.19",
"nodemon": "^3.0.1",
"supertest": "^6.2.4"
}
}

0
prova111 Normal file
View File

View File

@@ -5,6 +5,9 @@
},
{
"path": "../../../newfreeplanet"
},
{
"path": "../../../cnm"
}
],
"settings": {

View File

@@ -2,6 +2,8 @@ const tools = require('../tools/general');
// still in app.js
const node_env = process.env.NODE_ENV || 'production';
console.log('node_env=', node_env);
var file = `.env.${node_env}`;
@@ -18,7 +20,10 @@ require('dotenv').config({ path: file });
process.env.DATABASE = process.env.DATABASE || 'FreePlanet';
console.log('process.env.DOMAIN:', process.env.DOMAIN);
process.env.MONGODB_URI = process.env.DOMAIN + process.env.DATABASE;
console.log('process.env.MONGODB_URI:', process.env.MONGODB_URI);
/*

View File

@@ -44,6 +44,9 @@ const db = mongoose.connection;
// mongoose.connect(process.env.MONGODB_URI + '?authSource=admin', { options })
// console.log(' -> PASSAGGIO PARAMETRI MONGOOSE')
console.log('Node Version ' + process.version);
console.log('Mongoose Version ' + mongoose.version);
console.log('Connessione a ' + process.env.MONGODB_URI + ' in corso...');
mongoose.connect(process.env.MONGODB_URI, options);
db.on('error', console.error.bind(console, 'connection error:'));

View File

@@ -3,8 +3,15 @@
"Hello %s": "Ciao %s",
"Good: %s": "Bene: %s",
"Service: %s": "Servizio: %s",
"<strong>%s</strong> new Good: %s": "<strong>%s</strong> nuovo Bene: %s",
"<strong>%s</strong> new Service: %s": "<strong>%s</strong> nuovo Servizio: %s",
"NEW_GOOD": "❇️ <strong>%s</strong> ha aggiunto un nuovo Bene: \n<strong>%s</strong>",
"NEW_SERVICE": "❇️ <strong>%s</strong> ha aggiunto un nuovo Servizio: \n<strong>%s</strong>",
"NEW_HOSP": "❇️ <strong>%s</strong> ha aggiunto una nuova Ospitalità: \n<strong>%s</strong>",
"NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n%s\n<strong>%s</strong>\n%s",
"NEW_EVENT_TELEGRAM": "%s\n\n❇ <strong>%s</strong>\n\n%s\n\n%s",
"ADDED_FROM": "\n\n<i>(Evento aggiunto da <strong>%s</strong>)</i>",
"CONTRIB": "\n💠 Contributo richiesto: %s",
"ORGANIZED_BY": "\n<i>Organizzato da <strong>%s</strong></i>",
"SHOW_POST": "👉🏻 vedi post su RISO",
"OPEN PAGE": "<em>APRI la APP RISO oppure visita riso.app</em>",
"<strong>%s</strong> asked you for Friendship": "<strong>%s</strong> ti ha chiesto l'Amicizia",
"<strong>%s</strong> accepted your Friendship": "<strong>%s</strong> ha accettato l'Amicizia",
@@ -12,6 +19,8 @@
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
"HANDSHAKE_SET": "<strong>%s</strong> ha comunicato che ti conosce personalmente e ha fiducia in te.",
"HANDSHAKE_CONFIRMED": "🤝 Hai contraccambiato la fiducia in <strong>%s</strong>!",
"HANDSHAKE_ACCEPTED": "🤝 <strong>%s</strong> ha contraccambiato la stretta di mano (fiducia) !",
"GROUPS_ACCEPTED": "✅ Sei stato accettato a far parte del Gruppo %s (da parte di %s)",
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
@@ -34,57 +43,75 @@
"FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s",
"FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.",
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍‍♂️ Accetta Ingresso nel Circuito %s:",
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍‍♂️ Accetta Ingresso nel Circuito il gruppo %s:",
"CIRCUIT_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel circuito %s",
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel circuito %s",
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍‍♂️ Abilita fido a %s nel '%s':",
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍‍♂️ Abilita fido nel Circuito al gruppo %s:",
"CIRCUIT_OPEN_RISITALIA": "Apri il Circuito RIS Italia e chiedi di entrare",
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato al Fido (è stato invitato da %s)",
"CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s",
"CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s",
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel %s (con %s iscritti)",
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
"CIRCUIT_REQUEST": "Richiesta di entrare nel Circuito %s da parte di %s",
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del circuito %s da parte di %s",
"CIRCUIT_ADDED_ADMIN_YOU": "Sei stato aggiunto come Amministratore del circuito %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del circuito %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN_YOU": "Ti è stato rimosso l'incarico di Amministratore del circuito %s da parte di %s",
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il Circuito %s da parte di %s",
"CIRCUIT_ELIMINATO": "Il circuito %s è stato eliminato da parte di %s",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del Circuito %s (da parte di %s)",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto Collettivo %s è stato accettato a far parte del Circuito %s (da parte di %s)",
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Circuito %s.\nApri la APP e clicca in alto a destra sull'icona delle monete, oppure clicca qui: %s",
"CIRCUIT_ACCEPTED_YOU": "✅ Hai accettato %s a far parte del Circuito %s",
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Circuito %s. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del Circuito %s (da parte di %s)",
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
"CIRCUIT_REFUSED_TO_MYGROUP": "Al Conto Collettivo %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal Circuito %s",
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal Circuito %s",
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)",
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong>.",
"CIRCUIT_REQUEST": "Richiesta di entrare nel %s da parte di %s",
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del %s da parte di %s",
"CIRCUIT_ADDED_ADMIN_YOU": "%s sei stato aggiunto come Amministratore del %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del %s da parte di %s",
"CIRCUIT_REMOVED_ADMIN_YOU": "%s ti è stato rimosso l'incarico di Amministratore del %s da parte di %s",
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il %s da parte di %s",
"CIRCUIT_ELIMINATO": "Il %s è stato eliminato da parte di %s",
"FIDO_IMPOSTATO_ADMINS_CIRCUIT": "✅ l'utente %s è stato abilitato al Fido (%s RIS) sul '%s' (da parte di %s)",
"FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato abilitato al Fido fino a -%s sul '%s' (da parte di %s)",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del '%s' (da parte di %s)",
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato accettato a far parte del '%s' (da parte di %s)",
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del %s.\nApri la APP e clicca in alto a destra sull'icona delle monete, oppure clicca qui: %s",
"FIDO_IMPOSTATO": "✅ Ti è stata attivata la possibilità di utilizzare il fido (Fiducia Concessa) fino a %s RIS da %s sul '%s'.",
"CIRCUIT_ACCEPTED_YOU": "✅ Hai accettato %s a far parte del '%s'",
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del '%s'. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del %s (da parte di %s)",
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del '%s' (da parte di %s).",
"CIRCUIT_REFUSED_TO_MYGROUP": "Al Conto Collettivo %s gli è stato rifiutato l'accesso a far parte del '%s' (da parte di %s).",
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal '%s'",
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal '%s'",
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal '%s' (da parte di %s)",
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong> sul <strong>'%s'</strong>",
"COMUNITARIO": "Comunitario",
"COLLETTIVO": "Collettivo",
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s'.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> a %s.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU": "il conto %s '%s' (%s) ti sta inviando <strong>%s %s</strong>",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> al conto %s '%s'.",
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s. \nIl destinatario deve accettare la transazione.",
"CIRCUIT_SENDCOINSREQ_TO_GROUP": "Stai inviando <strong>%s %s</strong> al Conto %s '%s'. \nIl destinatario deve accettare la transazione.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU": "<strong>%s %s</strong> accettati dal Conto %s '%s' (%s).",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> dal conto %s '%s' (%s).",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> da %s.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU": "<strong>%s %s</strong> accettati da %s.",
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s.",
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong>]",
"SALDO_UPDATE_WHO": "[Saldo %s <strong>%s %s</strong>]",
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "<strong>%s %s</strong> sono stati accettati da %s.",
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s.",
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s.",
"COLLETTIVO": "Gruppo",
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> a %s sul '%s'.",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU": "il conto %s '%s' (%s) ti sta inviando <strong>%s %s</strong> sul '%s'",
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> al conto %s '%s' sul '%s'.",
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s sul '%s'. \nIl destinatario deve accettare la transazione.",
"CIRCUIT_SENDCOINSREQ_TO_GROUP": "Stai inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'. \nIl destinatario deve accettare la transazione.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU": "<strong>%s %s</strong> accettati dal Conto %s '%s' sul '%s' (%s) .",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> dal conto %s '%s' sul '%s' (%s).",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> da %s sul '%s'.",
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU": "<strong>%s %s</strong> accettati da %s sul '%s'.",
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s sul '%s'.",
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong> sul '%s']",
"SALDO_UPDATE_WHO": "[Saldo %s <strong>%s %s</strong> sul '%s']",
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "<strong>%s %s</strong> sono stati accettati da %s sul '%s'.",
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s sul '%s'.",
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s sul '%s'.",
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa per %s",
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario (%s) può accumulare",
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
"STATUS_SENT": "Inviato",
"STATUS_REFUSED": "Rifiutato",
"SALDO_VARIATO": "[Circuito %s] l'utente %s ha variato il Saldo di %s da %s a %s %s",
"FIDOCONCESSO_VARIATO": "[Circuito %s] l'utente %s ha variato il Fido Concesso di %s da %s a %s %s",
"QTAMAX_VARIATO": "[Circuito %s] l'utente %s ha variato la quantità massima concessa di %s da %s a %s %s",
"CLICCA_QUI": "CLICCA QUI"
"SALDO_VARIATO": "[%s] l'utente %s ha variato il Saldo di %s da %s a %s %s",
"FIDOCONCESSO_VARIATO": "[%s] l'utente %s ha variato il Fido Concesso di %s da %s a %s %s",
"QTAMAX_VARIATO": "[%s] l'utente %s ha variato la quantità massima concessa di %s da %s a %s %s",
"SET_FAVORITE": "%s ha messo 'Mi Piace' al tuo post: %s",
"SET_FAVORITE_OTHERS": "%s e altre %s persone hanno messo 'Mi Piace' al tuo post: %s",
"EVENT_SEND_MSG": "%s ha mandato un messaggio sull'evento %s: \n%s",
"SET_ATTEND": "%s ha detto che Parteciperà all'evento: %s",
"SET_ATTEND_OTHERS": "%s e altre %s persone hanno detto che Parteciperanno all'evento: %s",
"DATEDAYONLY": "%s dalle %s alle %s",
"DATE_2DAYS": "%s dalle %s fino a %s alle %s",
"SENDMSG_ENTRA_IN_RISO_ITALIA": "Ciao %s!<br>%s che appartiene al <em>%s</em> vuole inviarti dei RIS. Per poterli ricevere dovete entrambi utilizzare il <strong>Circuito RIS Italia</strong>.",
"CLICCA_QUI": "CLICCA QUI",
"✅ %s è stato Abilitato correttamente (da %s)!": "✅ %s è stato Abilitato correttamente (da %s)!",
"✅ Sei stato Abilitato correttamente da %s!": "✅ Sei stato Abilitato correttamente da %s!",
"🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!",
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
"🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !",
"✅ Hai Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !"
}

View File

@@ -56,12 +56,23 @@ const AccountSchema = new Schema({
},
importo_iniziale: {
type: Number,
default: 0,
},
saldo: {
type: Number,
default: 0,
},
totTransato: {
type: Number,
default: 0,
},
saldo_pend: {
type: Number,
default: 0,
},
totTransato_pend: {
type: Number,
default: 0,
},
regulation_ok: {
type: Boolean,
@@ -138,7 +149,7 @@ AccountSchema.statics.calcTotCircolante = async function (idapp, circuitId) {
{ $group: { _id: null, count: { $sum: '$saldo' } } }
];
ris = await Account.aggregate(aggr1);
const ris = await Account.aggregate(aggr1);
return ris ? ris[0].count : 0;
@@ -147,23 +158,69 @@ AccountSchema.statics.calcTotCircolante = async function (idapp, circuitId) {
}
};
AccountSchema.methods.addtoSaldoSave = async function (amount) {
const account = this;
AccountSchema.methods.calcPending = async function (mittente) {
try {
const account = this;
if (account) {
account.saldo = account.saldo + amount;
if (!account.totTransato) {
account.totTransato = 0;
const { SendNotif } = require('../models/sendnotif');
const { Circuit } = require('../models/circuit');
// *** Calc Pending Transactions ***
const circuit = await Circuit.getCircuitById(account.circuitId);
if (circuit) {
let prec_saldo_pend = account.saldo_pend;
let prec_totTransato_pend = account.totTransato_pend;
let transatopending = 0;
if (mittente) {
let pendingtransactionsMittente = await SendNotif.getSumPendingTransactionsMittente(account.idapp, account.username, circuit.name, account.groupname);
let saldopendingMitt = pendingtransactionsMittente.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
transatopending = pendingtransactionsMittente.reduce((sum, rec) => sum + Math.abs(rec.extrarec.qty), 0);
account.saldo_pend = account.saldo - saldopendingMitt;
} else {
// let pendingtransactionsDest = await SendNotif.getSumPendingTransactionsMittente(account.idapp, account.username, circuit.name, account.groupname);
// let saldopendingDest = pendingtransactionsDest.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
// transatopending = pendingtransactionsDest.reduce((sum, rec) => sum + Math.abs(rec.extrarec.qty), 0);
// account.saldo_pend = account.saldo + saldopendingDest;
account.saldo_pend = account.saldo;
}
account.totTransato_pend = account.totTransato + transatopending;
if (prec_saldo_pend !== account.saldo_pend || prec_totTransato_pend !== account.totTransato_pend) {
const myaccountupdate = {
saldo_pend: account.saldo_pend,
totTransato_pend: account.totTransato_pend,
};
// Update Record
return await Account.findByIdAndUpdate(account.id,
{
$set: myaccountupdate
}).then((ris) => {
console.log('calcPending', ris);
}).catch((err) => {
console.error('calcPending', err);
});
}
}
account.totTransato += Math.abs(amount);
account.date_updated = new Date();
return await account.save();
// -----
} catch (e) {
console.error(e);
}
return null;
};
}
AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
const Account = this;
try {
@@ -181,10 +238,16 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
myaccountupdate.totTransato = myaccount.totTransato;
myaccountupdate.date_updated = myaccount.date_updated;
return await Account.updateOne({ _id: myaccount.id },
const ris = await Account.updateOne({ _id: myaccount.id },
{
$set: myaccountupdate
});
await myaccount.calcPending(mitt);
return ris;
}
} catch (e) {
console.error('error', e);
@@ -195,13 +258,14 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
AccountSchema.pre('save', async function (next) {
if (this.isNew) {
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
});
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, groupname = '', contocom = "") {
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, confido, groupname = '', contocom = "") {
const Account = this;
try {
@@ -233,15 +297,18 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
myaccount = new Account({
_id: new ObjectID().toString(),
idapp,
username,
username: (!groupname && !contocom) ? username : '',
groupname,
contocom,
circuitId: mycircuit._id,
deperibile: false,
importo_iniziale: 0,
saldo: 0,
saldo_pend: 0,
fidoConcesso: 0,
qta_maxConcessa: 0,
totTransato: 0,
totTransato_pend: 0,
});
if (contocom) {
@@ -262,6 +329,9 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
}
}
if (!confido) {
myaccount.fidoConcesso = 0;
}
return await myaccount.save();
}
@@ -276,14 +346,52 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
};
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, groupname = '', contocom = '') {
AccountSchema.statics.isExistAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, groupname = '', contocom = "") {
const Account = this;
try {
const { Circuit } = require('../models/circuit');
if (username === undefined)
return false;
let myquery = {
idapp,
circuitId,
};
if (groupname) {
myquery.groupname = groupname;
} else if (contocom) {
myquery.contocom = contocom;
} else {
myquery.username = username;
}
let mycircuit = await Circuit.getCircuitById(circuitId);
if (mycircuit) {
let myaccount = await Account.findOne(myquery);
return !!myaccount
}
return false;
} catch (e) {
console.error('error', e);
}
};
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, confido, groupname = '', contocom = '') {
const { Circuit } = require('../models/circuit');
try {
mycircuit = await Circuit.findOne({ name: circuitName }, { _id: 1 });
if (mycircuit) {
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, groupname, contocom);
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, confido, groupname, contocom);
} else {
return null;
}
@@ -295,6 +403,7 @@ AccountSchema.statics.createAccount = async function (idapp, username, circuitNa
};
AccountSchema.statics.getUserAccounts = async function (idapp, username) {
const { SendNotif } = require('../models/sendnotif');
try {
let aggr1 = [
@@ -326,42 +435,64 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
$match: {
$expr: {
$and: [
{ $eq: ['$idapp', '$$idapp'] },
{ $eq: ['$typedir', '$$typedir'] },
{ $eq: ['$typeid', '$$typeid'] },
{ $eq: ['$status', 0] },
{ $eq: ['$sender', '$$username'] },
{ $eq: ['$idapp', '$$idapp'] },
{ $eq: ['$extrarec.circuitname', '$$circuitname'] },
],
},
},
},
{
$group:
{ _id: "$extrarec.notifIdToUpdate", result: { $first: "$$ROOT" } }
},
],
},
},
];
ris = await this.aggregate(aggr1);
const ris = await this.aggregate(aggr1);
const { SendNotif } = require('../models/sendnotif');
// console.log('1 - INIZIA getUserAccounts ')
// console.log(aggr1);
if (ris) {
/* if (ris) {
for (const account of ris) {
const pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
const saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
account.saldo -= saldopending;
try {
//++OTTIMIZZARE QUESTA PARTE ! (CON UNA QUERY...)
// console.log(' 1B - PENDIND... ')
let pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
let saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
if (saldopending !== 0) {
account.saldo -= saldopending;
account.totTransato = account.totTransato || 0;
}
} catch (e) {
console.error('getUserAccounts 1) ', e);
}
}
}
} */
return ris;
} catch (e) {
console.error('e', e);
console.error('getUserAccounts', e);
}
};
AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
if (!groupname) {
return [];
}
try {
let aggr1 = [
{
@@ -402,22 +533,16 @@ AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
},
},
},
{
$group:
{ _id: "$extrarec.notifIdToUpdate", result: { $first: "$$ROOT" } }
},
],
},
},
];
ris = await this.aggregate(aggr1);
const { SendNotif } = require('../models/sendnotif');
if (ris) {
for (const account of ris) {
const pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, '', account.circuit.name, groupname);
const saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
account.saldo -= saldopending;
}
}
const ris = await this.aggregate(aggr1);
return ris;
} catch (e) {
@@ -430,7 +555,7 @@ AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valmax) {
const Account = this;
ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
const ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
{
$set:
{
@@ -445,7 +570,7 @@ AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valma
AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valmax) {
const Account = this;
ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
const ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
{
$set:
{
@@ -457,18 +582,121 @@ AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valma
};
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, valmin, valmax) {
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, fidoConcesso, qta_maxConcessa, circuitId) {
const Account = this;
ris = await Account.updateMany({ idapp, username: { "$nin": [null, ""] } },
{
$set:
if (circuitId) {
const ris = await Account.updateMany({ idapp, circuitId, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
{
fidoConcesso: valmin,
qta_maxConcessa: valmax,
}
});
$set:
{
fidoConcesso,
qta_maxConcessa,
}
});
// Se aggiorno questi dati, allora devo aggiornare anche gli account del RIS Nazionale
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
} else {
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
{
$set:
{
fidoConcesso,
qta_maxConcessa,
}
});
}
};
AccountSchema.statics.updateFido = async function (idapp, username, groupname, circuitId, fido) {
let paramstoupdate = {
fidoConcesso: fido,
};
let risult = null;
if (groupname)
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
else
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
return risult;
};
AccountSchema.statics.updateQtaMax = async function (idapp, username, groupname, circuitId, qtamax) {
let paramstoupdate = {
qta_maxConcessa: qtamax,
};
let risult = null;
if (groupname)
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
else
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
return risult;
};
AccountSchema.statics.getAccountsCircuitiNazionali = async function (idapp) {
const { Circuit } = require('../models/circuit');
const circuit = await Circuit.find({ idapp, showAlways: true });
return Account.find({ idapp, circuitId: circuit.id });
};
AccountSchema.statics.updateAccountCircuitoNazionaleByLimiti = async function (idapp, circuitId, fidoConcesso, qta_maxConcessa) {
const { Circuit } = require('../models/circuit');
try {
const accounts = await this.getAccountsCircuitiNazionali(idapp);
for (const account of accounts) {
const circuitId = account.circuitId;
const circuit = await Circuit.findOne({ _id: circuitId });
if (circuit) {
let fido = 0;
let qtamax = 0;
if (account.groupname) {
fido = circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
qtamax = circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
} else {
fido = circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
qtamax = circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
}
let paramstoupdate = {
fidoConcesso: fido,
qta_maxConcessa: qtamax,
};
risult = await Account.updateOne({ _id: account.id }, { $set: paramstoupdate });
}
}
return risult;
} catch (e) {
console.error('updateAccountCircuitoNazionaleByLimiti', e);
}
return false;
};
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
const account = await Account.findOne({ _id: id }).lean();
const { Circuit } = require('../models/circuit');
if (account) {
const circuit = await Circuit.findOne({ _id: account.circuitId }).lean();
if (circuit) {
return circuit.admins.findIndex((admin) => admin.username === username) >= 0;
}
}
return false;
};
AccountSchema.statics.addToPeopleOfMyAccount = async function (idapp, username, circuitId, person_username, perm) {
@@ -489,11 +717,28 @@ AccountSchema.statics.addToPeopleOfMyAccount = async function (idapp, username,
// Rimuovi dagli Admin del Account
AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, circuitId, person_username, perm) {
const { Circuit } = require('../models/circuit');
return await Circuit.updateOne({ idapp, username, circuitId },
{ $pull: { people: { username: { $in: [person_username] } } } });
};
// Rimuovi l'account
AccountSchema.statics.removeAccount = async function (accountId) {
const { Circuit } = require('../models/circuit');
return await Circuit.deleteOne({ _id: accountId});
};
AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) {
const recaccounts = await Account.find({ idapp });
for (const account of recaccounts) {
await account.calcPending();
}
};
const Account = mongoose.model('Account', AccountSchema);

View File

@@ -20,6 +20,12 @@ const bookingSchema = new Schema({
userId: {
type: String,
},
username: {
type: String,
},
tableType: {
type: Number,
},
id_bookedevent: {
type: String,
},

View File

@@ -9,16 +9,16 @@ const CartSchema = new Schema({
idapp: {
type: String,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
totalQty: {type: Number, default: 0},
totalPrice: {type: Number, default: 0},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
totalQty: { type: Number, default: 0 },
totalPrice: { type: Number, default: 0 },
department: {
type: String, ref: 'Department',
},
items: [
{
order:
{type: Schema.Types.ObjectId, ref: 'Order'},
{ type: Schema.Types.ObjectId, ref: 'Order' },
},
],
note: {
@@ -31,57 +31,61 @@ const CartSchema = new Schema({
var Cart = module.exports = mongoose.model('Cart', CartSchema);
module.exports.findAllIdApp = async function(idapp, userId) {
const myfind = {idapp, userId};
module.exports.findAllIdApp = async function (idapp, userId) {
const myfind = { idapp, userId };
return await Cart.findOne(myfind).lean();
};
module.exports.getCartByUserId = async function(uid, idapp) {
let query = {userId: uid, idapp};
const mycart = await Cart.findOne(query).lean();
module.exports.getCartByUserId = async function (uid, idapp) {
try {
let query = { userId: uid, idapp };
const mycart = await Cart.findOne(query).lean();
if (!!mycart) {
for (const idkey in mycart.items) {
try {
idorder = mycart.items[idkey]._id.toString();
const myorder = mycart.items[idkey].order;
if (!!myorder) {
idorder = mycart.items[idkey].order._id.toString();
if (!!mycart) {
for (const idkey in mycart.items) {
try {
idorder = mycart.items[idkey]._id.toString();
const myorder = mycart.items[idkey].order;
if (!!myorder) {
idorder = mycart.items[idkey].order._id.toString();
}
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
mycart.items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
}
const myord = await Order.getTotalOrderById(idorder);
if (myord.length > 0) {
mycart.items[idkey].order = myord[0];
}
} catch (e) {
console.log('err', e);
}
return mycart;
}
return mycart;
return null;
} catch (e) {
console.log('getCartByUserId err', e);
}
return null;
};
module.exports.updateCartByUserId = function(userId, newCart, callback) {
let query = {userId: userId};
Cart.find(query, function(err, c) {
module.exports.updateCartByUserId = function (userId, newCart, callback) {
let query = { userId: userId };
Cart.find(query, function (err, c) {
if (err) throw err;
//exist cart in databse
if (c.length > 0) {
Cart.findOneAndUpdate(
{userId: userId},
{
$set: {
items: newCart.items,
totalQty: newCart.totalQty,
totalPrice: newCart.totalPrice,
userId: userId,
},
{ userId: userId },
{
$set: {
items: newCart.items,
totalQty: newCart.totalQty,
totalPrice: newCart.totalPrice,
userId: userId,
},
{new: true},
callback,
},
{ new: true },
callback,
);
} else {
//no cart in database
@@ -90,7 +94,7 @@ module.exports.updateCartByUserId = function(userId, newCart, callback) {
});
};
module.exports.updateCartByCartId = async function(cartId, newCart) {
module.exports.updateCartByCartId = async function (cartId, newCart) {
// delete newCart._doc._id;
const items = newCart.items;
const totalQty = newCart.totalQty;
@@ -98,14 +102,14 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
const modify_at = new Date();
return await Cart.findOneAndUpdate({_id: cartId}, {
return await Cart.findOneAndUpdate({ _id: cartId }, {
$set: {
items,
totalPrice,
totalQty,
modify_at,
},
}, {new: false}).lean().then((ris) => {
}, { new: false }).lean().then((ris) => {
return ris;
}).catch(err => {
console.log('err', err);
@@ -114,11 +118,11 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
};
module.exports.deleteCartByCartId = async function(cartId) {
return await Cart.remove({_id: cartId});
module.exports.deleteCartByCartId = async function (cartId) {
return await Cart.remove({ _id: cartId });
};
module.exports.createCart = async function(newCart) {
module.exports.createCart = async function (newCart) {
return await newCart.save();
};

View File

@@ -1,9 +1,11 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -11,20 +13,41 @@ mongoose.plugin(schema => {
});
const CategorySchema = new Schema({
idapp: {
type: String,
},
name: {
type: String,
unique: true,
index: true,
lowercase: true
}
},
img: {
type: String,
},
});
module.exports.getAllCategories = function (callback) {
CategorySchema.statics.getAllCategories = function (callback) {
Category.find(callback)
}
module.exports.getCategoryById = function (id, callback) {
CategorySchema.statics.getCategoryById = function (id, callback) {
Category.findById(id, callback);
}
module.exports = mongoose.model('Category', CategorySchema);
CategorySchema.statics.getFieldsForSearch = function () {
return [{ field: 'name', type: tools.FieldType.string }]
};
CategorySchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
CategorySchema.statics.findAllIdApp = async function (idapp) {
const myfind = { idapp };
return await Category.find(myfind);
};
const Category = mongoose.model('Category', CategorySchema);
module.exports = { Category };

View File

@@ -57,6 +57,10 @@ const CircuitSchema = new Schema({
{
type: String,
},
card: // Punti cardinali
{
type: String,
},
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
@@ -80,6 +84,9 @@ const CircuitSchema = new Schema({
totCircolante: {
type: Number,
},
showAlways: {
type: Boolean,
},
totTransato: {
type: Number,
},
@@ -212,6 +219,10 @@ const CircuitSchema = new Schema({
type: Number,
default: 0,
},
showAlways: {
type: Boolean,
default: false,
},
status: {
type: Number,
default: 0,
@@ -276,12 +287,14 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
fido_scoperto_default_grp: 1,
qta_max_default_grp: 1,
deperimento: 1,
showAlways: 1,
transactionsEnabled: 1,
status: 1,
valuta_per_euro: 1,
symbol: 1,
idCity: 1,
strProv: 1,
card: 1,
link_group: 1,
pub_to_share: 1,
visibility: 1,
@@ -331,6 +344,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
longdescr: 1,
regulation: 1,
numMembers: 1,
showAlways: 1,
systemUserId: 1,
founderUserId: 1,
nome_valuta: 1,
@@ -345,6 +359,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
color: 1,
idCity: 1,
strProv: 1,
card: 1,
link_group: 1,
pub_to_share: 1,
visibility: 1,
@@ -469,13 +484,40 @@ CircuitSchema.statics.getCircuitByName = async function (idapp, name) {
};
CircuitSchema.statics.getCircuitByProvince = async function (idapp, strProv) {
CircuitSchema.statics.getCircuitIdByName = async function (idapp, name) {
const myfind = {
idapp,
strProv,
name,
};
try {
const circuit = await Circuit.findOne(myfind);
return (!!circuit ? circuit._id : 0);
} catch (e) {
return null;
}
};
CircuitSchema.statics.getCircuitByProvinceAndCard = async function (idapp, strProv, card) {
let myfind = {};
if (card) {
myfind = {
idapp,
strProv,
card
};
} else {
myfind = {
idapp,
strProv,
};
}
try {
return await Circuit.findOne(myfind);
@@ -505,59 +547,6 @@ CircuitSchema.statics.deleteCircuit = async function (idapp, usernameOrig, name)
return await Circuit.findOneAndRemove({ idapp, name });
};
CircuitSchema.statics.getUserCircuits = async function (idapp, username) {
try {
let aggr1 = [
{
$match: {
idapp, username,
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } }],
},
},
{
$lookup: {
from: 'circuits',
localField: 'circuitId',
foreignField: '_id',
as: 'circuit',
},
},
{
'$replaceRoot': {
'newRoot': {
'$mergeObjects': [
{
'$arrayElemAt': [
'$circuit',
0,
],
},
'$$ROOT',
],
},
},
},
/*
{
$project: {
"circuit.name": 1,
},
},
*/
];
ris = await this.aggregate(aggr1);
return ris;
} catch (e) {
console.error('e', e);
}
};
CircuitSchema.statics.getUsersSingleCircuit = async function (idapp, username, circuitname, circuitId) {
@@ -658,6 +647,8 @@ CircuitSchema.statics.getCircolanteSingolaTransaz = function (accountorigTable,
CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig, extrarec) {
const { User } = require('../models/user');
let ris = {
result: false,
cansend: true,
@@ -676,8 +667,30 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
if (circuittable) {
const myqty = Math.abs(extrarec.qty);
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true, extrarec.groupdest, extrarec.contoComDest);
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true, extrarec.grouporig, extrarec.contoComOrig);
const esisteDest = await Account.isExistAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, extrarec.groupdest, extrarec.contoComDest);
if (!esisteDest) {
// Fallo entrare anche sul Circuito (oltre ad aver creato l'Account).
await User.addCircuitToUser(idapp, usernameOrig, extrarec.circuitname, false, extrarec.groupdest, extrarec.contoComDest);
}
if (extrarec.dest) {
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(idapp, extrarec.dest, extrarec.circuitname);
if (!foundIfAlreadyCircuit) {
update = {
$push: {
'profile.mycircuits': {
circuitname: extrarec.circuitname,
date: new Date(),
},
},
};
const ris = await User.updateOne({ idapp, username: extrarec.dest }, update);
}
}
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true, false, extrarec.groupdest, extrarec.contoComDest);
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true, true, extrarec.grouporig, extrarec.contoComOrig);
const circolantePrec = this.getCircolanteSingolaTransaz(accountorigTable, accountdestTable);
@@ -687,7 +700,7 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_FIDO', usernameOrig);
}
if (accountdestTable.saldo + myqty > accountorigTable.qta_maxConcessa) {
if (accountdestTable.saldo + myqty > accountdestTable.qta_maxConcessa) {
ris.cansend = false;
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_QTAMAX', extrarec.dest);
}
@@ -723,10 +736,11 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
if (extrarec.contoComOrig) {
orig = extrarec.contoComOrig + ' (' + usernameOrig + ')'
}
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupDest ? extrarec.groupDest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupdest ? extrarec.groupdest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
ris.result = true;
let msg = 'Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal + `] [Saldo ${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + ` [Saldo ${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
let msg = '[<b>' + circuittable.name + '</b>]: Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal +
`]\nSaldi:\n${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + `\n${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
console.log(msg);
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
@@ -817,7 +831,13 @@ CircuitSchema.statics.updateData = async function (idapp, circuitname) {
const ris = await User.aggregate(aggr1);
let numMembers = ris ? ris[0].count : 0;
let numMembers = 0;
try {
numMembers = ris && tools.isArray(ris) ? ris[0].count : 0;
} catch (e) {
};
let paramstoupdate = {
numMembers: numMembers,
@@ -890,67 +910,90 @@ CircuitSchema.statics.setstrProvByIdCityCircuits = async function (idapp) {
};
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax) {
ris = await Circuit.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
CircuitSchema.statics.AbilitaTuttiCircuiti = async function (idapp) {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
fido_scoperto_default: valmin,
qta_max_default: valmax,
transactionsEnabled: true
}
});
return ris;
};
CircuitSchema.statics.AzzeraRegolamentiTuttiCircuiti = async function (idapp) {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
regulation: '',
}
});
return ris;
};
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax) {
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax, circuitId) {
ris = await Circuit.updateMany({ idapp },
{
$set:
if (circuitId) {
const ris = await Circuit.updateOne({ _id: circuitId },
{
fido_scoperto_default: valmin,
qta_max_default: valmax,
}
});
$set:
{
fido_scoperto_default: valmin,
qta_max_default: valmax,
}
});
} else {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
fido_scoperto_default: valmin,
qta_max_default: valmax,
}
});
}
};
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
CircuitSchema.statics.replaceAllCircuits = async function (idapp) {
CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
const { User } = require('../models/user');
const globalTables = require('../tools/globalTables');
const myuser = await User.getUserByUsername(idapp, username);
const arrcircuit = await Circuit.find({ idapp }).lean();
try {
const circuit = await this.getCircuitByProvinceAndCard(idapp, myuser.profile.resid_province, myuser.profile.resid_card);
let num = 0;
for (const circuit of arrcircuit) {
if (circuit.strProv) {
let nomeprovincia = await Province.getStrProvinceByProv(circuit.strProv);
let newname = 'Circuito RIS ' + nomeprovincia;
if (newname !== circuit.name) {
ris = await globalTables.ReplaceCircuitName(idapp, circuit.name, newname);
if (ris)
num++;
if (circuit) {
if (await User.ifAlreadyInCircuit(idapp, username, circuit.name)) {
return circuit.name;
}
}
return '[nessun Circuito]';
} catch (e) {
console.error('Error', e);
}
console.log('*** Replaced Circuits ', num);
};
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province, card) {
const { User } = require('../models/user');
const useradmin = tools.USER_ADMIN_CIRCUITS;
let myrec = null;
try {
const circuit = await this.getCircuitByProvince(idapp, province);
const circuit = await this.getCircuitByProvinceAndCard(idapp, province, card);
const nomeprovincia = await Province.getStrProvinceByProv(province);
@@ -960,11 +1003,12 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
name: 'Circuito RIS ' + nomeprovincia,
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
strProv: province,
card,
photos: [],
admins: [],
color: '#ff5500',
deperimento: false,
transactionsEnabled: false,
showAlways: false,
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
symbol: 'RIS',
fido_scoperto_default: 100,
@@ -1006,17 +1050,173 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
return myrec;
};
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax) {
ris = await Circuit.updateMany({ idapp },
{
$set:
{
fido_scoperto_default_grp: valmin,
qta_max_default_grp: valmax,
CircuitSchema.statics.getListAdmins = async function (idapp, circuitname) {
let arr = await Circuit.findOne({
idapp,
name: circuitname,
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } }],
}, { admins: 1 }).lean();
let mystr = '';
if (arr) {
for (const admin of arr.admins) {
mystr += await tools.getAhref(admin.username, await tools.getLinkUserTelegram(idapp, admin.username)) + ', ';
}
}
return { str: mystr, num: arr ? arr.admins.length : 0 };
};
CircuitSchema.statics.isAdminCircuit = async function (idapp, circuitname, username) {
let arr = await Circuit.findOne({
idapp,
name: circuitname,
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } }],
}, { admins: 1 }).lean();
if (arr) {
for (const admin of arr.admins) {
if (admin.username === username)
return true;
}
}
return false;
};
CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, username, groupname) {
let mystr = '';
const { User } = require('../models/user');
const myuser = await User.getUserByUsername(idapp, username);
const useraccounts = await Account.getUserAccounts(idapp, username);
const groupsaccounts = await Account.getGroupAccounts(idapp, groupname);
for (let account of useraccounts) {
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
if (account.groupname === '') {
mystr += '\n👉🏻 ' + account.circuit.name + '\n';
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
mystr += ' Fido: ' + account.fidoConcesso + ' RIS, ';
mystr += ' Transato: ' + account.totTransato + ' RIS]';
}
});
}
}
for (let account of groupsaccounts) {
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
mystr += '\n GRUPPO: 👉🏻 <b>' + account.groupname + '</b> in ' + account.circuit.name + '\n';
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
mystr += ' Fido: ' + account.fidoConcesso + ' RIS, ';
mystr += ' Transato: ' + account.totTransato + ' RIS]';
}
}
if (!mystr) {
mystr = '[Nessun Circuito]';
}
return mystr;
};
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax, circuitId) {
if (circuitId) {
const ris = await Circuit.updateOne({ _id: circuitId },
{
$set:
{
fido_scoperto_default_grp: valmin,
qta_max_default_grp: valmax,
}
});
} else {
const ris = await Circuit.updateMany({ idapp },
{
$set:
{
fido_scoperto_default_grp: valmin,
qta_max_default_grp: valmax,
}
});
}
};
CircuitSchema.statics.setFido = async function (idapp, username, circuitName, groupname) {
mycircuit = await Circuit.findOne({ idapp, name: circuitName });
if (mycircuit) {
const circuitId = mycircuit._id;
let account = null;
let fido = 0;
let qtamax = 0;
if (mycircuit.showAlways) {
const { User } = require('../models/user');
const myuser = await User.getUserByUsername(idapp, username);
// Se è il circuito Nazionale, allora prende i valori dal proprio Circuito Locale:
const accountsuser = await Account.getUserAccounts(idapp, username);
if (accountsuser) {
// Se lo trovo della mia provincia, prendo quello
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province && account.circuit.card === myuser.profile.resid_card)
if (!account && accountsuser.length > 0) {
// Se non lo trovo, prendo il primo in cui sono entrato !
account = accountsuser[0];
}
if (account && account.circuit) {
if (groupname) {
qtamax = account.circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
fido = account.circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
} else {
qtamax = account.circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
fido = account.circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
}
}
} else {
// Se non ho Circuiti locali, non applico il Fido !
return false;
}
} else {
account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
if (groupname)
fido = mycircuit.fido_scoperto_default_grp;
else
fido = mycircuit.fido_scoperto_default;
}
if (account) {
if (qtamax > 0) {
await Account.updateQtaMax(idapp, username, groupname, circuitId, qtamax);
}
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido);
if (ris) {
return { qta_maxConcessa: qtamax, fidoConcesso: fido };
}
}
}
return false;
};
const Circuit = mongoose.model('Circuit', CircuitSchema);

View File

@@ -77,6 +77,17 @@ CitySchema.statics.getProvinceByIdCity = async function(idcity) {
return '';
}
CitySchema.statics.getCircuitNameBystrProv = async function(strProv) {
const { Circuit } = require('../models/circuit');
const myrec = await Circuit.findOne({strProv}).lean();
if (myrec) {
return myrec.name;
}
return '';
}
CitySchema.statics.getRegionByIdCity = async function(idcity) {
const myrec = await City.findOne({_id: idcity}).lean();
if (myrec) {

View File

@@ -47,9 +47,11 @@ const MovementSchema = new Schema({
},
causal: {
type: String,
default: '',
},
residual: {
type: Number,
default: 0,
},
expiringDate: {
type: Date,
@@ -111,9 +113,9 @@ MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accou
if (mymov) {
// Update saldo dell'Account
await Account.addtoSaldo(accountToIdTable, amount);
await Account.addtoSaldo(accountToIdTable, amount, true);
await Account.addtoSaldo(accountFromIdTable, -amount);
await Account.addtoSaldo(accountFromIdTable, -amount, false);
return mymov;
}
@@ -128,7 +130,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
if (!circuitId) {
return [];
}
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, groupname, contocom);
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, true, groupname, contocom);
if (myaccount) {
@@ -206,6 +208,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'circuits',
@@ -678,7 +681,6 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
try {
const rec = await MyMovement.findOne({ notifId }, { _id: 1 });
return !!rec;
} catch (e) {

View File

@@ -7,6 +7,11 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
const shared_consts = require('../tools/shared_nodejs');
const { Reaction } = require('./reaction');
const tableModel = shared_consts.TABLES_MYBACHECAS;
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -14,92 +19,112 @@ mongoose.plugin(schema => {
});
const MyBachecaSchema = new Schema({
_id: {
type: Number,
},
idapp: {
type: String,
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
idSector: {
type: Number,
},
idSkill: {
type: Number,
default: 0,
},
idStatusSkill: [
{
type: Number,
}],
idContribType: [
{
...{
_id: {
type: String,
}],
idCity: [
{
default: function () {
return new ObjectID().toString();
},
},
idapp: {
type: String,
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
groupname: { type: String },
idSector: {
type: Number,
}],
dateTimeStart: {
type: Date,
},
dateTimeEnd: {
type: Date,
},
numLevel: {
type: Number,
default: 0,
},
adType: {
type: Number,
},
photos: [
{
imagefile: {
},
idSkill: {
type: Number,
default: 0,
},
idStatusSkill: [
{
type: Number,
}],
idContribType: [
{
type: String,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
note: {
type: String,
default: '',
},
descr: {
type: String,
},
//**ADDFIELD_MYBACHECAS
website: {
type: String,
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
}],
idCity: [
{
type: Number,
}],
dateTimeStart: {
type: Date,
},
dateTimeEnd: {
type: Date,
},
organisedBy: {
type: String
},
contact_phone: {
type: String
},
contact_telegram: {
type: String
},
address: {
type: String,
},
min_partecip: {
type: Number,
},
max_partecip: {
type: Number,
},
link_maplocation: {
type: String,
},
contribstr: {
type: String,
},
numLevel: {
type: Number,
default: 0,
},
adType: {
type: Number,
},
photos: [
{
imagefile: {
type: String,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
note: {
type: String,
default: '',
},
descr: {
type: String,
},
//**ADDFIELD_MYBACHECAS
website: {
type: String,
},
date_created: {
type: Date,
},
date_updated: {
type: Date,
},
},
...Reaction.getFieldsForReactions()
});
MyBachecaSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyBacheca.findOne().limit(1).sort({ _id: -1 });
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
@@ -144,37 +169,7 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
idSubSkill: 1,
MyBacheca: 1,
idStatusSkill: 1,
idContribType: 1,
dateTimeStart: 1,
dateTimeEnd: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
//**ADDFIELD_MYBACHECAS
website: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
'profile.qualifica': 1,
reported: 1,
date_report: 1,
username_who_report: 1,
},
lk_proj: shared_consts.getProjectForAll({}, tableModel),
},
};
@@ -186,28 +181,24 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
const MyBacheca = this;
const query = [
let myparsid = {
'_id': id,
idapp,
};
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(id),
},
],
$match:
myparsid,
},
{
$sort: {
desc: 1,
},
},
{
'$match': {
'idapp': idapp,
},
},
{
'$sort': {
'desc': 1,
},
},
{
'$addFields': {
$addFields: {
'myId1': {
'$toObjectId': '$userId',
},
@@ -237,39 +228,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -295,39 +254,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -353,40 +280,22 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
$lookup: {
'from': 'mygroups',
'localField': 'groupname',
'foreignField': 'groupname',
'as': 'mygrp',
},
},
{
$unwind: {
path: '$mygrp',
preserveNullAndEmptyArrays: true,
},
},
{
'$project': shared_consts.getProjectForAll({}, tableModel),
},
/*{
'$lookup': {
'from': 'subskills',
@@ -411,39 +320,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
'$project': shared_consts.getProjectForAll({}, tableModel),
},
{
'$lookup': {
@@ -468,48 +345,29 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
},
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
dateTimeStart: 1,
dateTimeEnd: 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYBACHECAS
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
try {
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
let objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: shared_consts.getProjectForAll(objadd.proj, tableModel),
};
query = [...query, { ...toadd }];
} catch (e) {
console.error('e', e);
}
return MyBacheca.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
const MyBacheca = this;

View File

@@ -143,6 +143,7 @@ const MyElemSchema = new Schema({
anim: animation,
active: {
type: Boolean,
default: false,
},
class: {
type: String,

View File

@@ -6,7 +6,11 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const { Reaction } = require('./reaction');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -14,104 +18,96 @@ mongoose.plugin(schema => {
});
const MyGoodSchema = new Schema({
_id: {
type: Number,
},
idapp: {
type: String,
required: true,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
idSectorGood: {
type: Number,
},
idGood: {
type: Number,
default: 0,
},
idShipping: [
{
type: Number,
}],
idContribType: [
{
...{
_id: {
type: String,
}],
idCity: [
{
},
idapp: {
type: String,
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
idSectorGood: {
type: Number,
},
idGood: {
type: Number,
default: 0,
},
idShipping: [
{
type: Number,
}],
idContribType: [
{
type: String,
}],
idCity: [
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
numLevel: {
type: Number,
default: 0,
},
adType: {
type: Number,
},
otherfilters: [{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
numLevel: {
type: Number,
default: 0,
},
adType: {
type: Number,
},
otherfilters: [{
type: Number,
}],
photos: [
{
imagefile: {
type: String,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
note: {
type: String,
default: '',
},
descr: {
type: String,
},
//**ADDFIELD_MyGood
website: {
type: String,
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
photos: [
{
imagefile: {
type: String,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
note: {
type: String,
default: '',
},
descr: {
type: String,
},
//**ADDFIELD_MyGood
website: {
type: String,
},
date_created: {
type: Date,
},
date_updated: {
type: Date,
},
},
...Reaction.getFieldsForReactions()
});
MyGoodSchema.pre('save', async function(next) {
MyGoodSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyGood.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
});
MyGoodSchema.statics.findAllIdApp = async function(idapp) {
MyGoodSchema.statics.findAllIdApp = async function (idapp) {
const MyGood = this;
const query = [
{$match: {idapp}},
{$sort: {descr: 1}},
{ $match: { idapp } },
{ $sort: { descr: 1 } },
];
return await MyGood.aggregate(query).then((arrrec) => {
@@ -120,21 +116,21 @@ MyGoodSchema.statics.findAllIdApp = async function(idapp) {
};
MyGoodSchema.statics.getFieldsForSearch = function() {
MyGoodSchema.statics.getFieldsForSearch = function () {
return [];
};
MyGoodSchema.statics.getFieldsLastForSearch = function() {
MyGoodSchema.statics.getFieldsLastForSearch = function () {
return [
{field: 'note', type: tools.FieldType.string},
{field: 'descr', type: tools.FieldType.string},
{field: 'recGood.descr', type: tools.FieldType.string},
{field: 'MyGood.descr', type: tools.FieldType.string},
{ field: 'note', type: tools.FieldType.string },
{ field: 'descr', type: tools.FieldType.string },
{ field: 'recGood.descr', type: tools.FieldType.string },
{ field: 'MyGood.descr', type: tools.FieldType.string },
];
};
MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
MyGoodSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -145,60 +141,27 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idGood: 1,
idShipping: 1,
MyGood: 1,
idStatusGood: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
otherfilters: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MyGood
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
params = {...params, ...otherparams};
params = { ...params, ...otherparams };
return tools.executeQueryTable(this, idapp, params, user);
};
MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
const MyGood = this;
const query = [
let myparsid = {
'_id': idGood,
idapp,
};
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(idGood),
},
],
},
},
{
'$match': {
'idapp': idapp,
},
'$match':
myparsid,
},
{
'$sort': {
@@ -236,38 +199,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
note: 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -293,38 +225,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -351,38 +252,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -408,38 +278,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -464,55 +303,49 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
},
},
},
{
'$project': {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
otherfilters: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MyGood
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYGOODS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
};
query = [...query, { ...toadd }];
return MyGood.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MyGoodSchema.statics.getCompleteRecord = function(idapp, id) {
MyGoodSchema.statics.getCompleteRecord = function (idapp, id) {
const MyGood = this;
return MyGood.getMyRecById(idapp, id);
};
MyGoodSchema.statics.getProject = function () {
let proj = {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
//**ADDFIELD_MYGOOD
};
const proj_add = shared_consts.getProjectForAll()
return Object.assign({}, proj, proj_add);
}
const MyGood = mongoose.model('MyGood', MyGoodSchema);
module.exports = {MyGood};
module.exports = { MyGood };

View File

@@ -15,7 +15,10 @@ mongoose.plugin(schema => {
const MyGroupSchema = new Schema({
_id: {
type: Number,
type: String,
default: function () {
return new ObjectID().toString();
},
},
idapp: {
type: String,
@@ -144,18 +147,8 @@ MyGroupSchema.statics.executeQueryTable = function (idapp, params, user) {
MyGroupSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyGroup.findOne().limit(1).sort({ _id: -1 });
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();

View File

@@ -6,7 +6,10 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const { Reaction } = require('./reaction');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
@@ -14,109 +17,101 @@ mongoose.plugin(schema => {
});
const MyHospSchema = new Schema({
_id: {
type: Number,
},
idapp: {
type: String,
required: true,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
visibile: {
type: Boolean
},
typeHosp: { // scambio casa / ospitalità
type: Number,
},
numMaxPeopleHosp: {
type: Number,
},
accomodation: [
{
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
type: Number,
},
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
type: Number,
},
num: {
type: Number,
},
}],
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
{
type: Number,
}],
photos: [
{
imagefile: {
type: String,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
idContribType: [
{
...{
_id: {
type: String,
}],
idCity: [
{
},
idapp: {
type: String,
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
visibile: {
type: Boolean
},
typeHosp: { // scambio casa / ospitalità
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
descr: {
type: String,
},
note: {
type: String,
default: '',
},
website: {
type: String,
},
link_maplocation: {
type: String,
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
},
numMaxPeopleHosp: {
type: Number,
},
accomodation: [
{
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
type: Number,
},
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
type: Number,
},
num: {
type: Number,
},
}],
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
{
type: Number,
}],
photos: [
{
imagefile: {
type: String,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
idContribType: [
{
type: String,
}],
idCity: [
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
descr: {
type: String,
},
note: {
type: String,
default: '',
},
website: {
type: String,
},
link_maplocation: {
type: String,
},
date_created: {
type: Date,
},
date_updated: {
type: Date,
},
},
...Reaction.getFieldsForReactions()
});
MyHospSchema.pre('save', async function(next) {
MyHospSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MyHosp.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
});
MyHospSchema.statics.findAllIdApp = async function(idapp) {
MyHospSchema.statics.findAllIdApp = async function (idapp) {
const MyHosp = this;
const query = [
{$match: {idapp}},
{$sort: {descr: 1}},
{ $match: { idapp } },
{ $sort: { descr: 1 } },
];
return await MyHosp.aggregate(query).then((arrrec) => {
@@ -125,18 +120,18 @@ MyHospSchema.statics.findAllIdApp = async function(idapp) {
};
MyHospSchema.statics.getFieldsForSearch = function() {
MyHospSchema.statics.getFieldsForSearch = function () {
return [];
};
MyHospSchema.statics.getFieldsLastForSearch = function() {
MyHospSchema.statics.getFieldsLastForSearch = function () {
return [
{field: 'descr', type: tools.FieldType.string},
{field: 'note', type: tools.FieldType.string},
{ field: 'descr', type: tools.FieldType.string },
{ field: 'note', type: tools.FieldType.string },
];
};
MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
MyHospSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -147,59 +142,24 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
'mycities': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
params = {...params, ...otherparams};
params = { ...params, ...otherparams };
return tools.executeQueryTable(this, idapp, params, user);
};
MyHospSchema.statics.getMyRecById = function(idapp, id) {
MyHospSchema.statics.getMyRecById = function (idapp, id) {
const MyHosp = this;
const query = [
const myparsid = { '_id': id, idapp };
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(id),
},
],
},
},
{
'$match': {
'idapp': idapp,
},
'$match':
myparsid,
},
{
'$sort': {
@@ -237,34 +197,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -290,34 +223,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -343,34 +249,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
/*{
'$lookup': {
@@ -396,34 +275,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -448,50 +300,52 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
},
},
},
{
'$project': {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
note: 1,
website: 1,
link_maplocation: 1,
descr: 1,
date_created: 1,
date_updated: 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYHOSPS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
};
query = [...query, { ...toadd }];
return MyHosp.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MyHospSchema.statics.getCompleteRecord = function(idapp, id) {
MyHospSchema.statics.getCompleteRecord = function (idapp, id) {
const MyHosp = this;
return MyHosp.getMyRecById(idapp, id);
};
MyHospSchema.statics.getProject = function () {
let proj = {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
photos: 1,
website: 1,
link_maplocation: 1,
//**ADDFIELD_MYHOSP
};
const proj_add = shared_consts.getProjectForAll()
return Object.assign({}, proj, proj_add);
}
const MyHosp = mongoose.model('MyHosp', MyHospSchema);
module.exports = {MyHosp};
module.exports = { MyHosp };

View File

@@ -6,115 +6,118 @@ mongoose.level = 'F';
const tools = require('../tools/general');
const {ObjectID} = require('mongodb');
const { Reaction } = require('./reaction');
const shared_consts = require('../tools/shared_nodejs');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true;
});
const MySkillSchema = new Schema({
_id: {
type: Number,
},
idapp: {
type: String,
required: true,
},
userId: {type: Schema.Types.ObjectId, ref: 'User'},
idSector: {
type: Number,
},
idSkill: {
type: Number,
default: 0,
},
/*idSubSkill: [
{
type: Number,
default: 0,
}],
const MySkillSchema = new Schema(
{
...{
_id: {
type: String,
default: function () {
return new ObjectID().toString();
},
},
idapp: {
type: String,
required: true,
},
userId: { type: Schema.Types.ObjectId, ref: 'User' },
idSector: {
type: Number,
},
idSkill: {
type: Number,
default: 0,
},
/*idSubSkill: [
{
type: Number,
default: 0,
}],
*/
idStatusSkill: [
{
type: Number,
}],
idContribType: [
{
type: String,
}],
idCity: [
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
numLevel: {
type: Number,
default: 0,
},
adType: {
type: Number,
},
photos: [
{
imagefile: {
*/
idStatusSkill: [
{
type: Number,
}],
idContribType: [
{
type: String,
}],
idCity: [
{
type: Number,
}],
pub_to_share: {
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
},
numLevel: {
type: Number,
default: 0,
},
adType: {
type: Number,
},
photos: [
{
imagefile: {
type: String,
},
alt: {
type: String,
},
description: {
type: String,
},
}],
note: {
type: String,
default: '',
},
descr: {
type: String,
},
alt: {
//**ADDFIELD_MYSKILL
website: {
type: String,
},
description: {
type: String,
date_created: {
type: Date,
},
}],
note: {
type: String,
default: '',
},
descr: {
type: String,
},
//**ADDFIELD_MYSKILL
website: {
type: String,
},
date_created: {
type: Date,
default: Date.now,
},
date_updated: {
type: Date,
},
});
date_updated: {
type: Date,
},
},
...Reaction.getFieldsForReactions()
}, { strict: false });
MySkillSchema.pre('save', async function(next) {
MySkillSchema.index({ 'idapp': 1 });
MySkillSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await MySkill.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this.date_created = new Date();
if (!this.date_created)
this.date_created = new Date();
}
next();
});
MySkillSchema.statics.findAllIdApp = async function(idapp) {
MySkillSchema.statics.findAllIdApp = async function (idapp) {
const MySkill = this;
const query = [
{$match: {idapp}},
{$sort: {descr: 1}},
{ $match: { idapp } },
{ $sort: { descr: 1 } },
];
return await MySkill.aggregate(query).then((arrrec) => {
@@ -123,20 +126,20 @@ MySkillSchema.statics.findAllIdApp = async function(idapp) {
};
MySkillSchema.statics.getFieldsForSearch = function() {
MySkillSchema.statics.getFieldsForSearch = function () {
return [];
};
MySkillSchema.statics.getFieldsLastForSearch = function() {
MySkillSchema.statics.getFieldsLastForSearch = function () {
return [
{field: 'note', type: tools.FieldType.string},
{field: 'descr', type: tools.FieldType.string},
{field: 'recSkill.descr', type: tools.FieldType.string},
{field: 'myskill.descr', type: tools.FieldType.string},
{ field: 'note', type: tools.FieldType.string },
{ field: 'descr', type: tools.FieldType.string },
{ field: 'recSkill.descr', type: tools.FieldType.string },
{ field: 'myskill.descr', type: tools.FieldType.string },
];
};
MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
MySkillSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
params.fieldsearch_last = this.getFieldsLastForSearch();
@@ -147,58 +150,22 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
lk_FF: '_id',
lk_as: 'user',
af_objId_tab: 'myId',
lk_proj: {
idSkill: 1,
// idSubSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
idCity: 1,
pub_to_share: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
lasttimeonline: 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
lk_proj: this.getProject(),
},
};
params = {...params, ...otherparams};
params = { ...params, ...otherparams };
return tools.executeQueryTable(this, idapp, params, user);
};
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
const MySkill = this;
const query = [
let query = [
{
'$match': {
'$and': [
{
'_id': parseInt(idSkill),
},
],
},
},
{
'$match': {
'idapp': idapp,
'_id': idSkill, idapp
},
},
{
@@ -237,37 +204,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -293,37 +230,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -349,37 +256,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
//'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
/*{
'$lookup': {
@@ -407,37 +284,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
$project: this.getProject(),
},
{
'$lookup': {
@@ -462,47 +309,43 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
},
},
},
{
'$project': {
'recSkill': 1,
'sector': 1,
'idSector': 1,
'idSkill': 1,
// 'idSubSkill': 1,
'idStatusSkill': 1,
'idContribType': 1,
'idCity': 1,
pub_to_share: 1,
'numLevel': 1,
adType: 1,
'photos': 1,
'note': 1,
website: 1,
//**ADDFIELD_MYSKILL
'descr': 1,
'date_created': 1,
'date_updated': 1,
'userId': 1,
'username': 1,
'name': 1,
'surname': 1,
'comune': 1,
'mycities': 1,
'profile.img': 1,
"profile.mygroups": 1,
"profile.mycircuits": 1,
'profile.qualifica': 1,
reported: 1,
},
},
];
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYSKILLS);
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
query = [...query, ...objadd.query];
const toadd = {
$project: this.getProject(objadd.proj),
};
query = [...query, { ...toadd }];
return MySkill.aggregate(query).then((rec) => {
return rec ? rec[0] : null;
});
};
MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
MySkillSchema.statics.getProject = function (proj_add2) {
let proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
idStatusSkill: 1,
website: 1,
'numLevel': 1,
//**ADDFIELD_MYSKILL
};
const proj_add = shared_consts.getProjectForAll(proj_add2)
return Object.assign({}, proj, proj_add);
}
MySkillSchema.statics.getCompleteRecord = function (idapp, id) {
const MySkill = this;
return MySkill.getMyRecById(idapp, id);
@@ -511,4 +354,4 @@ MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
const MySkill = mongoose.model('MySkill', MySkillSchema);
module.exports = {MySkill};
module.exports = { MySkill };

View File

@@ -51,6 +51,9 @@ const orderSchema = new Schema({
weight: {
type: Number
},
unit: {
type: Number
},
stars: {
type: Number
},

View File

@@ -20,12 +20,12 @@ const PermissionSchema = new Schema({
type: String,
default: ''
}
},{ _id : false });
}, { _id: false });
PermissionSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await Permission.findOne().limit(1).sort({_id:-1});
const myrec = await Permission.findOne().limit(1).sort({ _id: -1 });
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
@@ -48,7 +48,7 @@ PermissionSchema.statics.executeQueryTable = function (idapp, params) {
PermissionSchema.statics.findAllIdApp = async function () {
const Permission = this;
const myfind = { };
const myfind = {};
return await Permission.find(myfind, (err, arrrec) => {
return arrrec

View File

@@ -27,7 +27,6 @@ const productSchema = new Schema({
],
code: {
type: String,
lowercase: true
},
name: {
type: String,
@@ -39,8 +38,13 @@ const productSchema = new Schema({
type: String, ref: 'Department'
},
category: {
type: String, ref: 'Category'
// type: String
type: Array,
},
prezzo_ivato: { // Con IVA
type: Number
},
perc_iva: { // 4, 10, 22 &
type: Number
},
price: {
type: Number
@@ -57,6 +61,9 @@ const productSchema = new Schema({
weight: {
type: Number
},
unit: {
type: Number
},
quantityAvailable: {
type: Number
},
@@ -183,6 +190,9 @@ module.exports.getProductByID = function (id, callback) {
Product.findById(id, callback);
}
// const Product = mongoose.model('Product', ProductSchema);
// module.exports = { Product };
// PROVA

View File

@@ -35,8 +35,32 @@ const ProvinceSchema = new Schema({
link_grp: {
type: String,
},
card : {
type: String,
},
link_telegram: {
type: String,
},
}, { _id : false });
ProvinceSchema.pre('save', async function (next) {
if (this.isNew) {
const myrec = await Province.findOne().limit(1).sort({_id:-1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
}
next();
});
ProvinceSchema.statics.getRegionByStrProvince = async function(strprovince) {
const myrec = await Province.findOne({prov: strprovince}).lean();
if (myrec) {

436
src/server/models/reaction.js Executable file
View File

@@ -0,0 +1,436 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const i18n = require('i18n');
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
mongoose.Promise = global.Promise;
mongoose.level = "F";
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const reactionSchema = new Schema({
idapp: {
type: String,
},
userId: {
type: String,
},
username: {
type: String,
},
idrec: {
type: String,
},
tab: {
type: Number,
},
fav: {
type: Boolean,
},
book: {
type: Boolean,
},
seen: {
type: Boolean,
},
attend: {
type: Boolean,
},
});
reactionSchema.statics.getFieldsForReactions = function () {
let reactionsField = {
numseen: {
type: Number,
},
numbook: {
type: Number,
},
numfav: {
type: Number,
},
numattend: {
type: Number,
},
};
return reactionsField;
};
reactionSchema.statics.getReactionsCounts = async function (mytable, idapp, idrec, numtab) {
let query = [];
try {
query =
[
{
$match: {
_id: idrec,
},
},
{
$lookup: {
from: "reactions",
let: {
tab: numtab,
id: '$_id',
},
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$idrec', idrec] },
{ $eq: ['$tab', numtab] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{
$group: {
_id: "$idrec",
numseen: {
$sum: {
$cond: {
if: { $ifNull: ["$seen", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numfav: {
$sum: {
$cond: {
if: { $ifNull: ["$fav", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numbook: {
$sum: {
$cond: {
if: { $ifNull: ["$book", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numattend: {
$sum: {
$cond: {
if: { $ifNull: ["$attend", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
}
},
},
],
as: 'myreact',
},
},
{
$unwind: {
path: "$myreact",
preserveNullAndEmptyArrays: true,
},
},
];
const ris = await mytable.aggregate(query);
return ris ? ris[0]: null;
} catch (e) {
}
};
reactionSchema.statics.updateReactionsCounts = async function () {
const globalTables = require('../tools/globalTables');
console.log('INIZIO - updateReactionsCounts');
try {
for (const tablestr of shared_consts.TABLES_REACTIONS) {
const numtab = tools.getNumTabByTable(tablestr);
const mytable = globalTables.getTableByTableName(tablestr);
const arrrec = await mytable.find({});
console.log(' updateReactionsCounts tabella', tablestr);
for (const rec of arrrec) {
// Calcola
const ris = await Reaction.getReactionsCounts(mytable, idapp, rec._id, numtab);
if (ris && ris.myreact) {
risupdate = await mytable.updateOne({ _id: rec._id }, {
$set: {
numseen: ris.myreact.numseen | 0,
numfav: ris.myreact.numfav | 0,
numbook: ris.myreact.numbook | 0,
numattend: ris.myreact.numattend | 0,
}
})
}
}
}
console.log('FINE - updateReactionsCounts');
} catch (err) {
console.error(err);
}
};
;
reactionSchema.statics.getFieldsForSearch = function () {
return [
{ field: 'username', type: tools.FieldType.string }];
};
reactionSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, 0, params);
};
reactionSchema.statics.calcReactions = async function (idapp, id, tab) {
try {
let myquerycountreaction = [
{
$match: {
idapp,
idrec: id,
tab,
},
},
{
$group: {
_id: null,
numseen: {
$sum: {
$cond: {
if: { $ifNull: ["$seen", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numfav: {
$sum: {
$cond: {
if: { $ifNull: ["$fav", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numbook: {
$sum: {
$cond: {
if: { $ifNull: ["$book", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numattend: {
$sum: {
$cond: {
if: { $ifNull: ["$attend", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
}
},
},
];
return await Reaction.aggregate(myquerycountreaction)
.then((ris) => {
return ris ? ris[0] : null;
});
} catch (err) {
console.error(err);
}
};
// Aggiungo il Favorite
reactionSchema.statics.addFavorite = async function (req, idapp, username, id, tab) {
let ris = null;
try {
let ok = false;
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
if (!myrec) {
const myrec = new Reaction({ idrec: id, idapp, userId: req.user.id, username, tab, fav: true });
ris = await myrec.save();
ok = ris ? 1 : 0;
} else {
ris = await Reaction.updateOne({ idrec: id, idapp, username }, {
$set: {
fav: true,
}
})
ok = ris.ok;
}
const { SendNotif } = require('../models/sendnotif');
const globalTables = require('../tools/globalTables');
// Invia una Notifica al Destinatario
const recObjCreator = await globalTables.getUserCreatorByNumTabAndId(idapp, id, tab);
if (recObjCreator) {
await SendNotif.createNewNotifToSingleUser(req, null, { usernameDest: recObjCreator.username, recObjCreator, username_action: req.user.username }, false, shared_consts.TypeNotifs.TYPEDIR_FAVORITE,
shared_consts.TypeNotifs.ID_FAVORITE_ADDED);
}
return { ris, ok };
} catch (e) {
console.error('Err addFavorite', e);
return { ris: null, ok: 0 };
}
};
// Aggiungo il Seen
reactionSchema.statics.addSeen = async function (req, idapp, username, id, tab) {
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
if (!myrec) {
const myrec = new Reaction({ idrec: id, idapp, userId: req.user.id, username, tab, seen: true });
return await myrec.save()
.then((ris) => {
// console.log('salvato proj!');
return { ris, ok: ris ? 1 : 0 };
})
.catch(err => {
console.log("Error addSeen", err.message);
});
} else {
return Reaction.updateOne({ _id: myrec._id }, {
$set: {
seen: true,
}
})
}
};
// Aggiungo il Bookmark
reactionSchema.statics.addBookmark = async function (req, idapp, username, id, tab) {
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
if (!myrec) {
const myrec = new Reaction({ idrec: id, idapp, userId: req.user.id, username, tab, book: true });
return await myrec.save()
.then((ris) => {
return { ris, ok: ris ? 1 : 0 };
})
.catch(err => {
console.log("Error addBookmark", err.message);
});
} else {
return Reaction.updateOne({ _id: myrec._id }, {
$set: {
book: true,
}
})
}
};
// Aggiungo il Attend
reactionSchema.statics.addAttend = async function (req, idapp, username, id, tab) {
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
if (!myrec) {
const myrec = new Reaction({ idrec: id, idapp, userId: req.user.id, username, tab, attend: true });
return await myrec.save()
.then((ris) => {
return { ris, ok: ris ? 1 : 0 };
})
.catch(err => {
console.log("Error addAttend", err.message);
});
} else {
return Reaction.updateOne({ _id: myrec._id }, {
$set: {
attend: true,
}
})
}
};
// Rimuovo il Favorite
reactionSchema.statics.removeFavorite = async function (
idapp, username, id, tab) {
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
if (myrec) {
return Reaction.updateOne({ _id: myrec._id }, {
$set: {
fav: false,
}
})
}
return false;
};
// Rimuovo il Bookmark
reactionSchema.statics.removeBookmark = async function (
idapp, username, id, tab) {
const myrec = await Reaction.findOne({ idrec: id, idapp, username });
if (myrec) {
return Reaction.updateOne({ _id: myrec._id }, {
$set: {
book: false,
}
})
}
return false;
};
const Reaction = mongoose.model('Reaction', reactionSchema);
module.exports = { Reaction };

45
src/server/models/search.js Executable file
View File

@@ -0,0 +1,45 @@
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const searchSchema = new Schema({
idapp: {
type: String,
},
userId: {
type: String,
},
text: {
type: String,
},
});
searchSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp, sall) {
const Search = this;
let myfind = {};
if (sall === '1')
myfind = { idapp };
else
myfind = { userId, idapp };
return Search.find(myfind, (err, arrsearch) => {
return arrsearch
});
};
const Search = mongoose.model('Search', searchSchema);
module.exports = { Search };

View File

@@ -17,14 +17,14 @@ const sendmsgSchema = new Schema({
},
source: {
page: { type: String },
event_id: { type: String }
event_id: { type: String },
infoevent: { type: String }
},
origin: {
username: { type: String },
type: String,
},
dest: {
idapp: { type: String, },
username: { type: String },
type: String,
},
message: {
type: String,
@@ -54,7 +54,7 @@ sendmsgSchema.statics.findAllMsgByUsernameIdAndIdApp = function (username, lastd
return SendMsg.find({
$and: [
{ $or: [ { 'dest.username': username }, { 'origin.username': username },] },
{ $or: [ { 'dest': username }, { 'origin': username },] },
{ 'datemsg': {$gt: new Date(lastdataread)} },
{ idapp }
]
@@ -73,14 +73,14 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
return SendMsg.aggregate([
{
$match: {
$or: [{ 'origin.username': username }, { 'dest.username': username }, { idapp }],
$or: [{ 'origin': username }, { 'dest': username }, { idapp }],
$and: [{ idapp }]
}
},
{
$group:
{
_id: "$dest.username",
_id: "$dest",
message: { $last: "$message" },
datemsg: { $last: "$datemsg" },
dest: { $last: "$dest" },

View File

@@ -22,18 +22,22 @@ mongoose.plugin(schema => {
const sendNotifSchema = new Schema({
idapp: {
type: String,
index: true,
},
typedir: {
type: Number,
default: 0,
index: true,
},
typeid: {
type: Number,
default: 0,
index: true,
},
sender: { // mittente
type: String,
default: '',
index: true,
},
dest: {
type: String,
@@ -66,6 +70,7 @@ const sendNotifSchema = new Schema({
status: {
type: Number,
default: 0,
index: true,
},
typesend: {
type: Number,
@@ -96,8 +101,25 @@ const sendNotifSchema = new Schema({
options: {
type: Array,
},
textaddTelegram: {
type: String,
},
textcontent_Telegram: {
type: String,
},
linkaddTelegram: {
type: String,
}
});
sendNotifSchema.index({ idapp: 1 });
sendNotifSchema.index({ typedir: 1 });
sendNotifSchema.index({ typeid: 1 });
sendNotifSchema.index({ sender: 1 });
sendNotifSchema.index({ idapp: 1, typedir: 1, typeid: 1, status: 1, sender: 1 });
sendNotifSchema.statics.setNotifAsRead = function (idapp, username, idnotif) {
const SendNotif = this;
@@ -139,7 +161,7 @@ sendNotifSchema.statics.getRecNotif = function (id) {
};
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp) {
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp, limitrecord) {
const SendNotif = this;
if (!lastdataread)
@@ -151,7 +173,7 @@ sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, l
{ 'dest': username },
{ 'datenotif': { $gt: new Date(lastdataread) } },
],
}).lean().sort({ datenotif: -1 }).then(async (arrnotif) => {
}).lean().limit(limitrecord).sort({ datenotif: -1 }).then(async (arrnotif) => {
// console.log('arrnotif', arrnotif.length);
return this.compileOtherFields(arrnotif);
@@ -166,11 +188,15 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
const numchars = 80;
let newdescr = '';
let newdescrtelegram = '';
let mydescr = '';
let myidrec = '';
let sender = recnotif.sender;
let sender = recnotif.sender ? recnotif.sender : '';
let tag = '';
const { Circuit } = require('../models/circuit');
const { User } = require('../models/user');
try {
if (recnotif.myrectableorig) {
myidrec = recnotif.myrectableorig._id;
@@ -179,14 +205,44 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA) {
if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD) {
newdescr = i18n.__('<strong>%s</strong> new Good: %s', userorig, mydescr);
recnotif.openUrl = '/mygood/' + myidrec;
newdescr = i18n.__('NEW_GOOD', userorig, mydescr);
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYGOODS, true) + myidrec;
tag = 'newgood';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE) {
newdescr = i18n.__('<strong>%s</strong> new Service: %s', userorig, mydescr);
recnotif.openUrl = '/myservice/' + myidrec;
newdescr = i18n.__('NEW_SERVICE', userorig, mydescr);
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYSKILLS, true) + myidrec;
tag = 'newservice';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_HOSP) {
newdescr = i18n.__('NEW_HOSP', userorig, mydescr);
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYHOSPS, true) + myidrec;
tag = 'newhosp';
}
recnotif.linkaddTelegram = 'Vedi annuncio';
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec;
tag = 'newevent';
if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_NEW_REC) {
let eventobj = await tools.getEventForTelegram(recnotif.myrectableorig, mydescr, userorig);
newdescr = eventobj.newdescr;
newdescrtelegram = eventobj.newdescrtelegram;
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_SEND_MSG) {
newdescr = i18n.__('EVENT_SEND_MSG', userorig, recnotif.title, recnotif.msg);
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_ATTEND) {
// ++ Controlla se esiste già
let esitegia = recnotif.paramsObj.recObjCreator.exist; // ++
if (esitegia)
newdescr = i18n.__('SET_ATTEND_OTHERS', recnotif.paramsObj.username_action, recnotif.paramsObj.recObjCreator.numattend - 1, recnotif.paramsObj.recObjCreator.descr);
else
newdescr = i18n.__('SET_ATTEND', recnotif.paramsObj.username_action, recnotif.paramsObj.recObjCreator.descr);
recnotif.openUrl = shared_consts.getDirectoryByTable(recnotif.paramsObj.recObjCreator.table, true) + recnotif.paramsObj.recObjCreator.id;
tag = 'attend';
}
recnotif.textcontent_Telegram = newdescrtelegram;
recnotif.linkaddTelegram = i18n.__('SHOW_POST');
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
recnotif.openUrl = '/my/' + sender;
if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC) {
@@ -222,7 +278,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
}
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
tag = 'group';
recnotif.openUrl = '/grp/' + recnotif.paramsObj.groupnameDest;
recnotif.openUrl = shared_consts.getDirectoryByTable('mygroups', true) + recnotif.paramsObj.groupnameDest;
if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_NEW_REC) {
newdescr = i18n.__('GROUP_CREATED', sender, recnotif.paramsObj.groupnameDest);
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
@@ -280,11 +336,17 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
}
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
tag = 'circuit';
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path;
strtipocontoOrig = recnotif.paramsObj.extrarec.contoComOrig ? i18n.__('COMUNITARIO') : i18n.__('COLLETTIVO');
strtipocontoDest = recnotif.paramsObj.extrarec.contoComDest ? i18n.__('COMUNITARIO') : i18n.__('COLLETTIVO');
let groupOComorig = recnotif.paramsObj.extrarec.contoComOrig ? recnotif.paramsObj.extrarec.contoComOrig : recnotif.paramsObj.extrarec.grouporig;
let groupOComdest = recnotif.paramsObj.extrarec.contoComDest ? recnotif.paramsObj.extrarec.contoComDest : recnotif.paramsObj.extrarec.groupdest;
let strtipocontoDest = '';
let strtipocontoOrig = '';
let groupOComorig = '';
let groupOComdest = '';
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TAB_MYCIRCUITS, true) + recnotif.paramsObj.path;
if (recnotif.paramsObj.extrarec) {
strtipocontoOrig = recnotif.paramsObj.extrarec.contoComOrig ? i18n.__('COMUNITARIO') : i18n.__('COLLETTIVO');
strtipocontoDest = recnotif.paramsObj.extrarec.contoComDest ? i18n.__('COMUNITARIO') : i18n.__('COLLETTIVO');
groupOComorig = recnotif.paramsObj.extrarec.contoComOrig ? recnotif.paramsObj.extrarec.contoComOrig : recnotif.paramsObj.extrarec.grouporig;
groupOComdest = recnotif.paramsObj.extrarec.contoComDest ? recnotif.paramsObj.extrarec.contoComDest : recnotif.paramsObj.extrarec.groupdest;
}
let myorig = '';
let mydest = '';
let destinatario = '';
@@ -292,6 +354,8 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
let symbol = '';
let username_action = '';
let username_mittente = '';
let circuitname = '';
let numuserincircuit = 0;
try {
username_action = recnotif.paramsObj.username_action
username_mittente = recnotif.paramsObj.sender ? recnotif.paramsObj.sender : username_action
@@ -300,15 +364,35 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
destinatario = recnotif.paramsObj.extrarec.dest ? recnotif.paramsObj.extrarec.dest : (recnotif.paramsObj.extrarec.groupdest ? recnotif.paramsObj.extrarec.groupdest : recnotif.paramsObj.extrarec.contoComDest);
qty = recnotif.paramsObj.extrarec && recnotif.paramsObj.extrarec.qty ? recnotif.paramsObj.extrarec.qty.toString() : '';
symbol = recnotif.paramsObj.extrarec ? recnotif.paramsObj.extrarec.symbol : '';
circuitname = recnotif.paramsObj.circuitnameDest;
numuserincircuit = await User.countUsersInCircuit(recnotif.idapp, circuitname);
} catch (e) {
}
recnotif.textaddTelegram = '';
if (groupOComdest) {
destinatario += ' (' + username_mittente + ')'
}
if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC) {
newdescr = i18n.__('CIRCUIT_CREATED', sender, recnotif.paramsObj.circuitnameDest);
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
if (recnotif.paramsObj.isAdmin) {
if (recnotif.extrarec.groupname) {
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
username_action);
} else {
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
username_action);
}
recnotif.openUrl = '/my/' + sender;
} else {
newdescr = i18n.__('FIDO_IMPOSTATO', -recnotif.paramsObj.extrarec.fidoConcesso, username_action, recnotif.paramsObj.circuitnameDest);
}
tag = 'setfido';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
if (recnotif.paramsObj.isAdmin) {
if (recnotif.extrarec.groupname) {
@@ -351,13 +435,20 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
}
tag = 'refcircuit';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER) {
aportador_solidario = await User.getAportadorSolidarioByUsername(recnotif.idapp, sender);
if (recnotif.extrarec.groupname) {
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP', recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest,
recnotif.paramsObj.singleadmin_username);
numuserincircuit, recnotif.paramsObj.singleadmin_username);
} else {
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', sender, recnotif.paramsObj.circuitnameDest,
recnotif.paramsObj.singleadmin_username);
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', sender, '<strong>' + recnotif.paramsObj.circuitnameDest + '</strong>', numuserincircuit, aportador_solidario);
}
const myadmins = await Circuit.getListAdmins(recnotif.idapp, recnotif.paramsObj.circuitnameDest);
recnotif.textaddTelegram += '\n' + i18n.__('CIRCUIT_ADMINS', myadmins.num, myadmins.str);
recnotif.textaddTelegram += '\n' + i18n.__('CIRCUIT_WHERE_IS_PRESENT', await Circuit.getListCircuitsByUsername(recnotif.idapp, sender, recnotif.extrarec.groupname));
tag = 'reqcircuits';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
@@ -365,7 +456,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
tag = 'deletecircuit';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN) {
if (sender === recnotif.paramsObj.usernameDest) {
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, username_action);
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN_YOU', recnotif.paramsObj.usernameDest, recnotif.paramsObj.circuitnameDest, username_action);
} else {
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN', sender, recnotif.paramsObj.circuitnameDest, username_action);
recnotif.openUrl = '/my/' + sender;
@@ -373,7 +464,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
tag = 'addadmingrp';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN) {
if (sender === recnotif.paramsObj.usernameDest) {
newdescr = i18n.__('CIRCUIT_REMOVED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, username_action);
newdescr = i18n.__('CIRCUIT_REMOVED_ADMIN_YOU', recnotif.paramsObj.usernameDest, recnotif.paramsObj.circuitnameDest, username_action);
} else {
newdescr = i18n.__('CIRCUIT_REMOVED_ADMIN', sender, recnotif.paramsObj.circuitnameDest, username_action);
recnotif.openUrl = '/my/' + sender;
@@ -382,56 +473,56 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ) {
if (groupOComdest) {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_GROUP', tools.getAhref(username_action, await tools.getLinkUserTelegram(recnotif.idapp, username_action)), qty,
symbol, strtipocontoDest, groupOComdest);
symbol, strtipocontoDest, groupOComdest, circuitname);
} else if (groupOComorig && (sender === recnotif.paramsObj.usernameDest)) {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU', strtipocontoOrig, groupOComorig, username_action, qty, symbol, recnotif.paramsObj.extrarec.dest);
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU', strtipocontoOrig, groupOComorig, username_action, qty, symbol, recnotif.paramsObj.extrarec.dest, circuitname);
} else if (groupOComorig) {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, groupOComorig, username_action, qty, symbol, recnotif.paramsObj.extrarec.dest);
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, groupOComorig, username_action, qty, symbol, recnotif.paramsObj.extrarec.dest, circuitname);
} else {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', tools.getAhref(username_action, await tools.getLinkUserTelegram(recnotif.idapp, username_action)), qty,
symbol);
symbol, circuitname);
}
tag = 'sendcoin';
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TAB_MYCIRCUITS, true) + recnotif.paramsObj.path; //++Todo: dove lo mando ?
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT) {
if (myorig) {
if (groupOComdest) {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP', strtipocontoOrig, myorig, username_action, qty, symbol, strtipocontoDest, groupOComdest);
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP', strtipocontoOrig, myorig, username_action, qty, symbol, strtipocontoDest, groupOComdest, circuitname);
} else {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, myorig, username_action, qty, symbol, mydest);
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, myorig, username_action, qty, symbol, mydest, circuitname);
}
} else {
if (groupOComdest) {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_GROUP', qty, symbol, strtipocontoDest, groupOComdest);
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_GROUP', qty, symbol, strtipocontoDest, groupOComdest, circuitname);
} else {
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_ME', qty, symbol, mydest);
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_ME', qty, symbol, mydest, circuitname);
}
}
tag = 'sendcoin';
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TAB_MYCIRCUITS, true) + recnotif.paramsObj.path; //++Todo: dove lo mando ?
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', qty, symbol,
username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol);
username_action, circuitname) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol, circuitname);
if (myorig) {
if (groupOComdest) {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP', strtipocontoDest, myorig, username_action, qty, symbol, strtipocontoDest, groupOComdest, username_mittente) + `\n`
+ i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol);
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP', strtipocontoDest, myorig, username_action, qty, symbol, strtipocontoDest, groupOComdest, circuitname, username_mittente) + `\n`
+ i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol, circuitname);
} else {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU', qty, symbol, strtipocontoOrig, myorig, username_action)
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU', qty, symbol, strtipocontoOrig, myorig, circuitname, username_action)
+ `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol);
}
} else {
if (groupOComdest) {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP', strtipocontoDest, groupOComdest, username_action, qty, symbol, username_mittente)
+ `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol);
+ `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol, circuitname);
} else {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU', qty, symbol, username_action)
+ `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol);
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU', qty, symbol, username_action, circuitname)
+ `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol, circuitname);
}
}
@@ -440,22 +531,35 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
if (!destinatario) {
destinatario = username_action
}
let saldostr = i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig, symbol);
let saldostr = i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig, symbol, circuitname);
if (groupOComorig) {
saldostr = i18n.__('SALDO_UPDATE_WHO', groupOComorig, recnotif.paramsObj.extrarec.saldoOrig, symbol);
saldostr = i18n.__('SALDO_UPDATE_WHO', groupOComorig, recnotif.paramsObj.extrarec.saldoOrig, symbol, circuitname);
}
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_TO_ME', qty, symbol, destinatario)
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_TO_ME', qty, symbol, destinatario, circuitname)
+ `\n` + saldostr;
tag = 'sendcoin';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED', qty, symbol, username_action);
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED', qty, symbol, username_action, circuitname);
tag = 'sendcoin';
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', qty, symbol, destinatario);
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', qty, symbol, destinatario, circuitname);
tag = 'sendcoin';
}
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FAVORITE) {
// ++ Controlla se esiste già
let esitegia = recnotif.paramsObj.recObjCreator.exist; // ++
if (esitegia)
newdescr = i18n.__('SET_FAVORITE_OTHERS', recnotif.paramsObj.username_action, recnotif.paramsObj.recObjCreator.numfav - 1, recnotif.paramsObj.recObjCreator.descr);
else
newdescr = i18n.__('SET_FAVORITE', recnotif.paramsObj.username_action, recnotif.paramsObj.recObjCreator.descr);
tag = 'favorite';
recnotif.openUrl = shared_consts.getDirectoryByTable(recnotif.paramsObj.recObjCreator.table, true) + recnotif.paramsObj.recObjCreator.id;
recnotif.linkaddTelegram = i18n.__('SHOW_POST');
}
recnotif.tag = recnotif.tag ? recnotif.tag : tag;
@@ -531,6 +635,8 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
// console.log('myrecout._id', myrecout._id.toString());
let risnotif = null;
if (save) {
let res = null;
try {
@@ -541,7 +647,10 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
const myrecread = await SendNotif.findById(idobj).lean();
// console.log('myrecread._id', myrecread._id.toString());
return await globalTables.sendNotif(myrecread.typedir, myrecread.typeid, res, idapp, user ? user : req.user, myrecread);
if (myrecread)
risnotif = await globalTables.sendNotif(myrecread.typedir, myrecread.typeid, res, idapp, user ? user : req.user, myrecread);
else
return false;
}
} catch (e) {
@@ -550,9 +659,12 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
}
} else {
return await globalTables.sendNotif(myrecout.typedir, myrecout.typeid, res, idapp, user ? user : req.user, myrecout);
risnotif = await globalTables.sendNotif(myrecout.typedir, myrecout.typeid, res, idapp, user ? user : req.user, myrecout);
}
return risnotif;
};
sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlysave, userorig) {
@@ -569,10 +681,10 @@ sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlys
let typeidsearch = 0;
let dest = '';
let sender = myrecnotif.sender;
let newdest = myrecnotif.dest;
let sendergroup = myrecnotif.sendergroup;
let newdestgroup = myrecnotif.destgroup;
let sender = myrecnotif.sender ? myrecnotif.sender : '';
let newdest = myrecnotif.dest ? myrecnotif.dest : '';
let sendergroup = myrecnotif.sendergroup ? myrecnotif.sendergroup : '';
let newdestgroup = myrecnotif.destgroup ? myrecnotif.destgroup : '';
// Controllare se devo modificare un Notif già esistente !
if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
@@ -811,9 +923,11 @@ sendNotifSchema.statics.createNewNotification = async function (req, res, params
myrecnotif.idrec = rec._id;
}
myrecnotif.typedir = typedir;
myrecnotif.typeid = typeid;
await SendNotif.sendToTheDestinations(myrecnotif, req, res);
return true;
@@ -854,6 +968,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
// Send only to the destination to reach:
const userlist = await User.find({
idapp: myrecnotifpass.idapp,
// username: 'SuryaArena2', //TOGLIERE
$or: [
{ deleted: { $exists: false } },
{ deleted: { $exists: true, $eq: false } }],
@@ -864,6 +979,9 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
lang: 1,
username: 1,
'profile.notifs': 1,
'profile.mycircuits': 1,
'profile.resid_province': 1,
'profile.resid_card': 1,
'profile.notif_idCities': 1,
'profile.notif_provinces': 1,
'profile.notif_regions': 1,
@@ -871,30 +989,38 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
'profile.notif_sector_goods': 1,
}).lean();
let arrcircuits = [];
let arrprovinces = [];
let arrregions = [];
let idSector = 0;
const mytable = globalTables.getTableByTableName(myrecnotifpass.tablerec);
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA || myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
if (myrectableorig) {
for (const city of myrectableorig.idCity) {
arrprovinces.push(await City.getProvinceByIdCity(city));
arrregions.push(await City.getRegionByIdCity(city));
if (myrecnotifpass.idrec && myrecnotifpass.idrec !== '0') {
// const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
const myrectableorig = await mytable.getCompleteRecord(myrecnotifpass.idapp, myrecnotifpass.idrec);
if (myrectableorig) {
for (const city of myrectableorig.idCity) {
const prov = await City.getProvinceByIdCity(city);
arrprovinces.push(await City.getProvinceByIdCity(city));
arrregions.push(await City.getRegionByIdCity(city));
arrcircuits.push(await City.getCircuitNameBystrProv(prov));
}
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
idSector = myrectableorig.idSectorGood;
} else {
idSector = myrectableorig.idSector;
}
}
myrecnotifpass.myrectableorig = myrectableorig;
}
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
idSector = myrectableorig.idSectorGood;
} else {
idSector = myrectableorig.idSector;
}
}
myrecnotifpass.myrectableorig = myrectableorig;
}
myrecnotifpass = await this.getDescrAndLinkByRecNotif(myrecnotifpass, req.user.username);
@@ -902,48 +1028,86 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
for (const user of userlist) {
const mycircuits = user.profile.mycircuits;
if (user.profile && user.profile.notifs) {
const usernotifprofile = user.profile.notifs.find((notif) => notif.dir === myrecnotifpass.typedir);
let send = false;
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
// Estrai la Città, la Provincia e la regione.
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_PROVINCE) &&
user.profile.notif_provinces && user.profile.notif_provinces.some(r => arrprovinces.indexOf(r) >= 0)) {
send = true;
}
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_REGION) &&
user.profile.notif_regions && user.profile.notif_regions.some(r => arrregions.indexOf(r) >= 0)) {
send = true;
}
if (idSector && usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_SECTOR)) {
// Controlla se è del settore selezionato
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
if (user.profile.notif_sector_goods) {
send = send && (user.profile.notif_sector_goods.includes(idSector));
}
} else if (user.profile.notif_sectors) {
send = send && (user.profile.notif_sectors.includes(idSector));
if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYBACHECAS) {
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_EVENTS_ATTEND)) {
send = true;
}
}
}
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
send = true;
if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_FAVORITE) {
if (shared_consts.TABLES_FAVORITE_BOOKMARK.includes(myrecnotifpass.tablerec)) {
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED)) {
send = true;
}
}
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA
|| myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS
|| myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS
) {
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec)
|| shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)
|| shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)
) {
// Estrai la Città, la Provincia e la regione.
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_YOUR_PROVINCE) &&
user.profile.resid_province && arrprovinces.indexOf(user.profile.resid_province) >= 0) {
send = true;
}
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_PROVINCE) &&
user.profile.notif_provinces && user.profile.notif_provinces.some(r => arrprovinces.indexOf(r) >= 0)) {
send = true;
}
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_REGION) &&
user.profile.notif_regions && user.profile.notif_regions.some(r => arrregions.indexOf(r) >= 0)) {
send = true;
}
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_MY_RIS_CIRCUIT) &&
user.profile.mycircuits && user.profile.mycircuits.some(r => arrcircuits.indexOf(r.circuitname) >= 0)) {
send = true;
}
if (idSector && usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_SECTOR)) {
// Controlla se è del settore selezionato
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
if (user.profile.notif_sector_goods) {
send = send && (user.profile.notif_sector_goods.includes(idSector));
}
} else if (user.profile.notif_sectors) {
send = send && (user.profile.notif_sectors.includes(idSector));
}
}
}
/*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
send = true;
}
}
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) {
send = true;
}
}*/
}
if (send) {
let myrecnotif = new SendNotif(myrecnotifpass);
myrecnotif.dest = user.username;
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, user);
await SendNotif.saveAndSendNotif(myrecnotif, req, res, user);
}
}
}
@@ -977,7 +1141,8 @@ sendNotifSchema.statics.sendToSingleUserDest = async function (myrecnotif, req,
};
sendNotifSchema.statics.getSumPendingTransactions = async function (idapp, username, circuitname, groupname) {
sendNotifSchema.statics.getSumPendingTransactionsMittente = async function (idapp, username, circuitname, groupname) {
const SendNotif = this;
try {
@@ -999,6 +1164,60 @@ sendNotifSchema.statics.getSumPendingTransactions = async function (idapp, usern
};
sendNotifSchema.statics.getSumPendingTransactionsDest = async function (idapp, username, circuitname, groupname) {
const SendNotif = this;
try {
const query = {
idapp,
sender: username,
sendergroup: groupname,
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
typeid: shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ,
status: 0,
'extrarec.circuitname': circuitname,
'extrarec.dest': username,
'extrarec.groupdest': groupname,
};
return await SendNotif.find(query).lean();
} catch (e) {
console.error('e', e);
}
};
sendNotifSchema.statics.updatePendingTransactions = async function (recnotif) {
const { Circuit } = require('../models/circuit');
const { Account } = require('../models/account');
try {
if (recnotif && recnotif.extrarec && recnotif.extrarec.circuitname) {
const circuit = await Circuit.getCircuitByName(recnotif.idapp, recnotif.extrarec.circuitname);
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(recnotif.idapp, recnotif.extrarec.dest, circuit._id, true, false, recnotif.extrarec.groupdest, recnotif.extrarec.contoComDest);
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(recnotif.idapp, recnotif.sender, circuit._id, true, true, recnotif.extrarec.grouporig, recnotif.extrarec.contoComOrig);
if (accountdestTable)
await accountdestTable.calcPending(false);
if (accountorigTable)
await accountorigTable.calcPending(true);
}
} catch (e) {
console.error(e);
}
};
sendNotifSchema.statics.checkIfAlreadyExist = async function (idapp, tag, idpost, numtab) {
};
const SendNotif = mongoose.model('SendNotif', sendNotifSchema);
module.exports = { SendNotif: SendNotif };

View File

@@ -62,6 +62,12 @@ const SiteSchema = new Schema({
telegram_key_test: {
type: String,
},
teleg_cfg: {
type: String,
},
teleg_cfg_test: {
type: String,
},
telegram_bot_name_test: {
type: String,
},
@@ -122,6 +128,7 @@ const SiteSchema = new Schema({
enableRegMultiChoice: { type: Boolean },
enableDebugOn: { type: Boolean },
enabledRegNeedTelegram: { type: Boolean },
showViewEventi: { type: Boolean },
showViewGroups: { type: Boolean },
showViewCircuits: { type: Boolean },
showViewUsers: { type: Boolean },
@@ -225,6 +232,7 @@ module.exports.findAllIdApp = async function (idapp) {
rec.email_pwd = '';
rec.telegram_key = '';
rec.telegram_key_test = '';
// rec.confsite = {};
return rec;
}

File diff suppressed because it is too large Load Diff

View File

@@ -89298,5 +89298,16 @@ module.exports = {
abitanti: '',
country: 'ONL',
},
{
_id: 8120,
istat: '',
comune: 'Italia',
prov: 'ITA',
reg: 'ITA',
pref: '',
cap: '',
abitanti: '',
country: 'ITA',
},
],
};

View File

@@ -62,5 +62,13 @@ module.exports = {
{_id: 60, idSectorGood: [17], descr: 'Per Imbiancare'},
{_id: 61, idSectorGood: [17], descr: 'Giardinaggio'},
{_id: 62, idSectorGood: [17], descr: 'Falegnameria'},
{_id: 63, idSectorGood: [7], descr: 'Pane'},
{_id: 64, idSectorGood: [7], descr: 'Pasta'},
{_id: 65, idSectorGood: [7], descr: 'Formaggi'},
{_id: 66, idSectorGood: [7], descr: 'Olio'},
{_id: 67, idSectorGood: [7], descr: 'Fervida'},
{_id: 68, idSectorGood: [7], descr: 'Fermentati'},
{_id: 69, idSectorGood: [7], descr: 'Marmellate'},
{_id: 70, idSectorGood: [7], descr: 'Salse'},
],
};

View File

@@ -1,124 +1,126 @@
module.exports = {
list: [
{_id: 1, reg: 'SIC', prov: 'AG', descr: 'Agrigento', link_grp: 'https://t.me/c/1614195634/562?thread=553'},
{_id: 2, reg: 'PIE', prov: 'AL', descr: 'Alessandria', link_grp: 'https://t.me/c/1614195634/513?thread=504'},
{_id: 3, reg: 'MAR', prov: 'AN', descr: 'Ancona', link_grp: 'https://t.me/c/1614195634/450?thread=446'},
{_id: 4, reg: 'VDA', prov: 'AO', descr: 'Aosta', link_grp: 'https://t.me/c/1614195634/521?thread=520'},
{_id: 5, reg: 'TOS', prov: 'AR', descr: 'Arezzo', link_grp: 'https://t.me/c/1614195634/583?thread=572'},
{_id: 6, reg: 'MAR', prov: 'AP', descr: 'Ascoli Piceno', link_grp: 'https://t.me/c/1614195634/451?thread=447'},
{_id: 7, reg: 'PIE', prov: 'AT', descr: 'Asti', link_grp: 'https://t.me/c/1614195634/514?thread=505'},
{_id: 8, reg: 'CAM', prov: 'AV', descr: 'Avellino', link_grp: 'https://t.me/c/1614195634/413?thread=409'},
{_id: 9, reg: 'PUG', prov: 'BA', descr: 'Bari', link_grp: 'https://t.me/c/1614195634/534?thread=528'},
{_id: 10, reg: 'PUG', prov: 'BT', descr: 'Barletta-Andria-Trani', link_grp: 'https://t.me/c/1614195634/535?thread=529'},
{_id: 11, reg: 'VEN', prov: 'BL', descr: 'Belluno', link_grp: 'https://t.me/c/1614195634/608?thread=599'},
{_id: 12, reg: 'CAM', prov: 'BN', descr: 'Benevento', link_grp: 'https://t.me/c/1614195634/415?thread=411'},
{_id: 13, reg: 'LOM', prov: 'BG', descr: 'Bergamo', link_grp: 'https://t.me/c/1614195634/491?thread=477'},
{_id: 14, reg: 'PIE', prov: 'BI', descr: 'Biella', link_grp: 'https://t.me/c/1614195634/515?thread=506'},
{_id: 15, reg: 'EMR', prov: 'BO', descr: 'Bologna', link_grp: 'https://t.me/c/1614195634/428?thread=419'},
{_id: 16, reg: 'TAA', prov: 'BZ', descr: 'Bolzano', link_grp: 'https://t.me/c/1614195634/596?thread=594'},
{_id: 17, reg: 'LOM', prov: 'BS', descr: 'Brescia', link_grp: 'https://t.me/c/1614195634/490?thread=478'},
{_id: 18, reg: 'PUG', prov: 'BR', descr: 'Brindisi', link_grp: 'https://t.me/c/1614195634/536?thread=530'},
{_id: 19, reg: 'SAR', prov: 'CA', descr: 'Cagliari', link_grp: 'https://t.me/c/1614195634/546?thread=541'},
{_id: 20, reg: 'SIC', prov: 'CL', descr: 'Caltanissetta', link_grp: 'https://t.me/c/1614195634/563?thread=554'},
{_id: 21, reg: 'MOL', prov: 'CB', descr: 'Campobasso', link_grp: 'https://t.me/c/1614195634/398?thread=396'},
{_id: 22, reg: 'SAR', prov: 'CI', descr: 'Carbonia-Iglesias', link_grp: ''},
{_id: 23, reg: 'CAM', prov: 'CE', descr: 'Caserta', link_grp: 'https://t.me/c/1614195634/414?thread=410'},
{_id: 24, reg: 'SIC', prov: 'CT', descr: 'Catania', link_grp: 'https://t.me/c/1614195634/564?thread=555'},
{_id: 25, reg: 'CAL', prov: 'CZ', descr: 'Catanzaro', link_grp: 'https://t.me/c/1614195634/378?thread=377'},
{_id: 26, reg: 'ABR', prov: 'CH', descr: 'Chieti', link_grp: 'https://t.me/c/1614195634/366?thread=365'},
{_id: 27, reg: 'LOM', prov: 'CO', descr: 'Como', link_grp: 'https://t.me/c/1614195634/492?thread=479'},
{_id: 28, reg: 'CAL', prov: 'CS', descr: 'Cosenza', link_grp: 'https://t.me/c/1614195634/381?thread=379'},
{_id: 29, reg: 'LOM', prov: 'CR', descr: 'Cremona', link_grp: 'https://t.me/c/1614195634/493?thread=480'},
{_id: 30, reg: 'CAL', prov: 'KR', descr: 'Crotone', link_grp: 'https://t.me/c/1614195634/382?thread=380'},
{_id: 31, reg: 'PIE', prov: 'CN', descr: 'Cuneo', link_grp: 'https://t.me/c/1614195634/516?thread=507'},
{_id: 32, reg: 'SIC', prov: 'EN', descr: 'Enna', link_grp: 'https://t.me/c/1614195634/565?thread=556'},
{_id: 33, reg: 'MAR', prov: 'FM', descr: 'Fermo', link_grp: 'https://t.me/c/1614195634/453?thread=448'},
{_id: 34, reg: 'EMR', prov: 'FE', descr: 'Ferrara', link_grp: 'https://t.me/c/1614195634/429?thread=420'},
{_id: 35, reg: 'TOS', prov: 'FI', descr: 'Firenze', link_grp: 'https://t.me/c/1614195634/584?thread=573'},
{_id: 36, reg: 'PUG', prov: 'FG', descr: 'Foggia', link_grp: 'https://t.me/c/1614195634/537?thread=531'},
{_id: 37, reg: 'EMR', prov: 'FC', descr: 'Forli-Cesena', link_grp: 'https://t.me/c/1614195634/430?thread=421'},
{_id: 38, reg: 'LAZ', prov: 'FR', descr: 'Frosinone', link_grp: 'https://t.me/c/1614195634/48?thread=44'},
{_id: 39, reg: 'LIG', prov: 'GE', descr: 'Genova', link_grp: 'https://t.me/c/1614195634/392?thread=388'},
{_id: 40, reg: 'FVG', prov: 'GO', descr: 'Gorizia', link_grp: 'https://t.me/c/1614195634/469?thread=465'},
{_id: 41, reg: 'TOS', prov: 'GR', descr: 'Grosseto', link_grp: 'https://t.me/c/1614195634/585?thread=574'},
{_id: 42, reg: 'LIG', prov: 'IM', descr: 'Imperia', link_grp: 'https://t.me/c/1614195634/393?thread=389'},
{_id: 43, reg: 'MOL', prov: 'IS', descr: 'Isernia', link_grp: 'https://t.me/c/1614195634/399?thread=397'},
{_id: 44, reg: 'LIG', prov: 'SP', descr: 'La Spezia', link_grp: 'https://t.me/c/1614195634/394?thread=390'},
{_id: 45, reg: 'ABR', prov: 'AQ', descr: 'L\'Aquila', link_grp: 'https://t.me/c/1614195634/364?thread=363'},
{_id: 46, reg: 'LAZ', prov: 'LT', descr: 'Latina', link_grp: 'https://t.me/c/1614195634/60?thread=46'},
{_id: 47, reg: 'PUG', prov: 'LE', descr: 'Lecce', link_grp: 'https://t.me/c/1614195634/538?thread=532'},
{_id: 48, reg: 'LOM', prov: 'LC', descr: 'Lecco', link_grp: 'https://t.me/c/1614195634/494?thread=482'},
{_id: 49, reg: 'TOS', prov: 'LI', descr: 'Livorno', link_grp: 'https://t.me/c/1614195634/586?thread=575'},
{_id: 50, reg: 'LOM', prov: 'LO', descr: 'Lodi', link_grp: 'https://t.me/c/1614195634/495?thread=483'},
{_id: 51, reg: 'TOS', prov: 'LU', descr: 'Lucca', link_grp: 'https://t.me/c/1614195634/587?thread=576'},
{_id: 52, reg: 'MAR', prov: 'MC', descr: 'Macerata', link_grp: 'https://t.me/c/1614195634/300?thread=162'},
{_id: 53, reg: 'LOM', prov: 'MN', descr: 'Mantova', link_grp: 'https://t.me/c/1614195634/497?thread=484'},
{_id: 54, reg: 'TOS', prov: 'MS', descr: 'Massa-Carrara', link_grp: 'https://t.me/c/1614195634/588?thread=577'},
{_id: 55, reg: 'BAS', prov: 'MT', descr: 'Matera', link_grp: 'https://t.me/c/1614195634/374?thread=373'},
{_id: 56, reg: 'SIC', prov: 'ME', descr: 'Messina', link_grp: 'https://t.me/c/1614195634/566?thread=557'},
{_id: 57, reg: 'LOM', prov: 'MI', descr: 'Milano', link_grp: 'https://t.me/c/1614195634/214?thread=173'},
{_id: 58, reg: 'EMR', prov: 'MO', descr: 'Modena', link_grp: 'https://t.me/c/1614195634/431?thread=422'},
{_id: 59, reg: 'LOM', prov: 'MB', descr: 'Monza e della Brianza', link_grp: 'https://t.me/c/1614195634/498?thread=485'},
{_id: 60, reg: 'CAM', prov: 'NA', descr: 'Napoli', link_grp: 'https://t.me/c/1614195634/407?thread=406'},
{_id: 61, reg: 'PIE', prov: 'NO', descr: 'Novara', link_grp: 'https://t.me/c/1614195634/517?thread=508'},
{_id: 62, reg: 'SAR', prov: 'NU', descr: 'Nuoro', link_grp: 'https://t.me/c/1614195634/548?thread=542'},
{_id: 63, reg: 'SAR', prov: 'OT', descr: 'Olbia-Tempio', link_grp: ''},
{_id: 64, reg: 'SAR', prov: 'OR', descr: 'Oristano', link_grp: 'https://t.me/c/1614195634/550?thread=543'},
{_id: 65, reg: 'VEN', prov: 'PD', descr: 'Padova', link_grp: 'https://t.me/c/1614195634/610?thread=600'},
{_id: 66, reg: 'SIC', prov: 'PA', descr: 'Palermo', link_grp: 'https://t.me/c/1614195634/568?thread=558'},
{_id: 67, reg: 'EMR', prov: 'PR', descr: 'Parma', link_grp: 'https://t.me/c/1614195634/432?thread=423'},
{_id: 68, reg: 'LOM', prov: 'PV', descr: 'Pavia', link_grp: 'https://t.me/c/1614195634/499?thread=486'},
{_id: 69, reg: 'UMB', prov: 'PG', descr: 'Perugia', link_grp: 'https://t.me/c/1614195634/403?thread=401'},
{_id: 70, reg: 'MAR', prov: 'PU', descr: 'Pesaro e Urbino', link_grp: 'https://t.me/c/1614195634/454?thread=449'},
{_id: 71, reg: 'ABR', prov: 'PE', descr: 'Pescara', link_grp: 'https://t.me/c/1614195634/368?thread=367'},
{_id: 72, reg: 'EMR', prov: 'PC', descr: 'Piacenza', link_grp: 'https://t.me/c/1614195634/433?thread=424'},
{_id: 73, reg: 'TOS', prov: 'PI', descr: 'Pisa', link_grp: 'https://t.me/c/1614195634/589?thread=578'},
{_id: 74, reg: 'TOS', prov: 'PT', descr: 'Pistoia', link_grp: 'https://t.me/c/1614195634/590?thread=579'},
{_id: 75, reg: 'FVG', prov: 'PN', descr: 'Pordenone', link_grp: 'https://t.me/c/1614195634/470?thread=466'},
{_id: 76, reg: 'BAS', prov: 'PZ', descr: 'Potenza', link_grp: 'https://t.me/c/1614195634/376?thread=375'},
{_id: 77, reg: 'TOS', prov: 'PO', descr: 'Prato', link_grp: 'https://t.me/c/1614195634/591?thread=580'},
{_id: 78, reg: 'SIC', prov: 'RG', descr: 'Ragusa', link_grp: 'https://t.me/c/1614195634/569?thread=559'},
{_id: 79, reg: 'EMR', prov: 'RA', descr: 'Ravenna', link_grp: 'https://t.me/c/1614195634/434?thread=425'},
{_id: 80, reg: 'CAL', prov: 'RC', descr: 'Reggio Calabria', link_grp: 'https://t.me/c/1614195634/385?thread=383'},
{_id: 81, reg: 'EMR', prov: 'RE', descr: 'Reggio Emilia', link_grp: 'https://t.me/c/1614195634/435?thread=426'},
{_id: 82, reg: 'LAZ', prov: 'RI', descr: 'Rieti', link_grp: 'https://t.me/c/1614195634/61?thread=45'},
{_id: 83, reg: 'EMR', prov: 'RN', descr: 'Rimini', link_grp: 'https://t.me/c/1614195634/436?thread=https://t.me/c/1614195634/64?thread=57427'},
{_id: 84, reg: 'LAZ', prov: 'RM', descr: 'Roma', link_grp: ''},
{_id: 85, reg: 'VEN', prov: 'RO', descr: 'Rovigo', link_grp: 'https://t.me/c/1614195634/611?thread=601'},
{_id: 86, reg: 'CAM', prov: 'SA', descr: 'Salerno', link_grp: 'https://t.me/c/1614195634/416?thread=412'},
{_id: 87, reg: 'SAR', prov: 'VS', descr: 'Medio Campidano', link_grp: ''},
{_id: 88, reg: 'SAR', prov: 'SS', descr: 'Sassari', link_grp: 'https://t.me/c/1614195634/551?thread=544'},
{_id: 89, reg: 'LIG', prov: 'SV', descr: 'Savona', link_grp: 'https://t.me/c/1614195634/395?thread=391'},
{_id: 90, reg: 'TOS', prov: 'SI', descr: 'Siena', link_grp: 'https://t.me/c/1614195634/592?thread=581'},
{_id: 91, reg: 'SIC', prov: 'SR', descr: 'Siracusa', link_grp: 'https://t.me/c/1614195634/570?thread=560'},
{_id: 92, reg: 'LOM', prov: 'SO', descr: 'Sondrio', link_grp: 'https://t.me/c/1614195634/500?thread=487'},
{_id: 93, reg: 'PUG', prov: 'TA', descr: 'Taranto', link_grp: 'https://t.me/c/1614195634/539?thread=533'},
{_id: 94, reg: 'ABR', prov: 'TE', descr: 'Teramo', link_grp: 'https://t.me/c/1614195634/370?thread=369'},
{_id: 95, reg: 'UMB', prov: 'TR', descr: 'Terni', link_grp: 'https://t.me/c/1614195634/404?thread=402'},
{_id: 96, reg: 'PIE', prov: 'TO', descr: 'Torino', link_grp: 'https://t.me/c/1614195634/518?thread=509'},
{_id: 97, reg: 'SAR', prov: 'OG', descr: 'Ogliastra', link_grp: ''},
{_id: 98, reg: 'SIC', prov: 'TP', descr: 'Trapani', link_grp: 'https://t.me/c/1614195634/571?thread=561'},
{_id: 99, reg: 'TAA', prov: 'TN', descr: 'Trento', link_grp: 'https://t.me/c/1614195634/597?thread=595'},
{_id: 100, reg: 'VEN', prov: 'TV', descr: 'Treviso', link_grp: 'https://t.me/c/1614195634/612?thread=602'},
{_id: 101, reg: 'FVG', prov: 'TS', descr: 'Trieste', link_grp: 'https://t.me/c/1614195634/471?thread=467'},
{_id: 102, reg: 'FVG', prov: 'UD', descr: 'Udine', link_grp: 'https://t.me/c/1614195634/472?thread=468'},
{_id: 103, reg: 'LOM', prov: 'VA', descr: 'Varese', link_grp: 'https://t.me/c/1614195634/501?thread=488'},
{_id: 104, reg: 'VEN', prov: 'VE', descr: 'Venezia', link_grp: 'https://t.me/c/1614195634/613?thread=603'},
{_id: 105, reg: 'PIE', prov: 'VB', descr: 'Verbano-Cusio-Ossola', link_grp: 'https://t.me/c/1614195634/519?thread=510 '},
{_id: 106, reg: 'PIE', prov: 'VC', descr: 'Vercelli', link_grp: 'https://t.me/c/1614195634/512?thread=511'},
{_id: 107, reg: 'VEN', prov: 'VR', descr: 'Verona', link_grp: 'https://t.me/c/1614195634/614?thread=604'},
{_id: 108, reg: 'CAL', prov: 'VV', descr: 'Vibo Valentia', link_grp: 'https://t.me/c/1614195634/386?thread=384'},
{_id: 109, reg: 'VEN', prov: 'VI', descr: 'Vicenza', link_grp: 'https://t.me/c/1614195634/615?thread=605'},
{_id: 110, reg: 'LAZ', prov: 'VT', descr: 'Viterbo', link_grp: 'https://t.me/c/1614195634/76?thread=74'},
{_id: 111, reg: 'RSM', prov: 'RSM', descr: 'Repubblica di San Marino', link_grp: 'https://t.me/+HSdNurm0IXY1MGI0'},
{_id: 112, reg: 'EST', prov: 'EST', descr: 'Estero', link_grp: ''},
{_id: 113, reg: 'ONL', prov: 'ONL', descr: 'On Line', link_grp: ''},
{_id: 114, reg: 'LAZ', prov: 'RM', descr: 'Roma Nord-Est', link_grp: 'https://t.me/c/1614195634/64?thread=57'},
{_id: 115, reg: 'LAZ', prov: 'RM', descr: 'Roma Sud-Est', link_grp: 'https://t.me/c/1614195634/65?thread=58'},
{_id: 116, reg: 'LAZ', prov: 'RM', descr: 'Roma Nord', link_grp: 'https://t.me/c/1614195634/75?thread=73'},
{_id: 117, reg: 'LAZ', prov: 'RM', descr: 'Roma Nord-Ovest', link_grp: 'https://t.me/c/1614195634/62?thread=47'},
{_id: 118, reg: 'LAZ', prov: 'RM', descr: 'Roma Sud e Litorale', link_grp: 'https://t.me/c/1614195634/67?thread=43'},
{_id: 119, reg: 'PUG', prov: 'VAL', descr: 'Valle D\'Itria', link_grp: 'https://t.me/progettoriso/7016?thread=7015'},
{_id: 120, reg: 'SAR', prov: 'SUS', descr: 'Sud Sardegna', link_grp: 'https://t.me/c/1614195634/552?thread=545'},
{_id: 1, reg: 'SIC', prov: 'AG', descr: 'Agrigento', link_grp: 'https://t.me/c/1614195634/562?thread=553', link_telegram: ''},
{_id: 2, reg: 'PIE', prov: 'AL', descr: 'Alessandria', link_grp: 'https://t.me/c/1614195634/513?thread=504', link_telegram: ''},
{_id: 3, reg: 'MAR', prov: 'AN', descr: 'Ancona', link_grp: 'https://t.me/c/1614195634/450?thread=446', link_telegram: ''},
{_id: 4, reg: 'VDA', prov: 'AO', descr: 'Aosta', link_grp: 'https://t.me/c/1614195634/521?thread=520', link_telegram: ''},
{_id: 5, reg: 'TOS', prov: 'AR', descr: 'Arezzo', link_grp: 'https://t.me/c/1614195634/583?thread=572', link_telegram: ''},
{_id: 6, reg: 'MAR', prov: 'AP', descr: 'Ascoli Piceno', link_grp: 'https://t.me/c/1614195634/451?thread=447', link_telegram: ''},
{_id: 7, reg: 'PIE', prov: 'AT', descr: 'Asti', link_grp: 'https://t.me/c/1614195634/514?thread=505', link_telegram: ''},
{_id: 8, reg: 'CAM', prov: 'AV', descr: 'Avellino', link_grp: 'https://t.me/c/1614195634/413?thread=409', link_telegram: ''},
{_id: 9, reg: 'PUG', prov: 'BA', descr: 'Bari', link_grp: 'https://t.me/c/1614195634/534?thread=528', link_telegram: ''},
{_id: 10, reg: 'PUG', prov: 'BT', descr: 'Barletta-Andria-Trani', link_grp: 'https://t.me/c/1614195634/535?thread=529', link_telegram: ''},
{_id: 11, reg: 'VEN', prov: 'BL', descr: 'Belluno', link_grp: 'https://t.me/c/1614195634/608?thread=599', link_telegram: ''},
{_id: 12, reg: 'CAM', prov: 'BN', descr: 'Benevento', link_grp: 'https://t.me/c/1614195634/415?thread=411', link_telegram: ''},
{_id: 13, reg: 'LOM', prov: 'BG', descr: 'Bergamo', link_grp: 'https://t.me/c/1614195634/491?thread=477', link_telegram: ''},
{_id: 14, reg: 'PIE', prov: 'BI', descr: 'Biella', link_grp: 'https://t.me/c/1614195634/515?thread=506', link_telegram: ''},
{_id: 15, reg: 'EMR', prov: 'BO', descr: 'Bologna', link_grp: 'https://t.me/c/1614195634/428?thread=419', link_telegram: ''},
{_id: 16, reg: 'TAA', prov: 'BZ', descr: 'Bolzano', link_grp: 'https://t.me/c/1614195634/596?thread=594', link_telegram: ''},
{_id: 17, reg: 'LOM', prov: 'BS', descr: 'Brescia', link_grp: 'https://t.me/c/1614195634/490?thread=478', link_telegram: ''},
{_id: 18, reg: 'PUG', prov: 'BR', descr: 'Brindisi', link_grp: 'https://t.me/c/1614195634/536?thread=530', link_telegram: ''},
{_id: 19, reg: 'SAR', prov: 'CA', descr: 'Cagliari', link_grp: 'https://t.me/c/1614195634/546?thread=541', link_telegram: ''},
{_id: 20, reg: 'SIC', prov: 'CL', descr: 'Caltanissetta', link_grp: 'https://t.me/c/1614195634/563?thread=554', link_telegram: ''},
{_id: 21, reg: 'MOL', prov: 'CB', descr: 'Campobasso', link_grp: 'https://t.me/c/1614195634/398?thread=396', link_telegram: ''},
{_id: 22, reg: 'SAR', prov: 'CI', descr: 'Carbonia-Iglesias', link_grp: '', link_telegram: ''},
{_id: 23, reg: 'CAM', prov: 'CE', descr: 'Caserta', link_grp: 'https://t.me/c/1614195634/414?thread=410', link_telegram: ''},
{_id: 24, reg: 'SIC', prov: 'CT', descr: 'Catania', link_grp: 'https://t.me/c/1614195634/564?thread=555', link_telegram: ''},
{_id: 25, reg: 'CAL', prov: 'CZ', descr: 'Catanzaro', link_grp: 'https://t.me/c/1614195634/378?thread=377', link_telegram: ''},
{_id: 26, reg: 'ABR', prov: 'CH', descr: 'Chieti', link_grp: 'https://t.me/c/1614195634/366?thread=365', link_telegram: ''},
{_id: 27, reg: 'LOM', prov: 'CO', descr: 'Como', link_grp: 'https://t.me/c/1614195634/492?thread=479', link_telegram: ''},
{_id: 28, reg: 'CAL', prov: 'CS', descr: 'Cosenza', link_grp: 'https://t.me/c/1614195634/381?thread=379', link_telegram: ''},
{_id: 29, reg: 'LOM', prov: 'CR', descr: 'Cremona', link_grp: 'https://t.me/c/1614195634/493?thread=480', link_telegram: ''},
{_id: 30, reg: 'CAL', prov: 'KR', descr: 'Crotone', link_grp: 'https://t.me/c/1614195634/382?thread=380', link_telegram: ''},
{_id: 31, reg: 'PIE', prov: 'CN', descr: 'Cuneo', link_grp: 'https://t.me/c/1614195634/516?thread=507', link_telegram: ''},
{_id: 32, reg: 'SIC', prov: 'EN', descr: 'Enna', link_grp: 'https://t.me/c/1614195634/565?thread=556', link_telegram: ''},
{_id: 33, reg: 'MAR', prov: 'FM', descr: 'Fermo', link_grp: 'https://t.me/c/1614195634/453?thread=448', link_telegram: ''},
{_id: 34, reg: 'EMR', prov: 'FE', descr: 'Ferrara', link_grp: 'https://t.me/c/1614195634/429?thread=420', link_telegram: ''},
{_id: 35, reg: 'TOS', prov: 'FI', descr: 'Firenze', link_grp: 'https://t.me/c/1614195634/584?thread=573', link_telegram: ''},
{_id: 36, reg: 'PUG', prov: 'FG', descr: 'Foggia', link_grp: 'https://t.me/c/1614195634/537?thread=531', link_telegram: ''},
{_id: 37, reg: 'EMR', prov: 'FC', descr: 'Forli-Cesena', link_grp: 'https://t.me/c/1614195634/430?thread=421', link_telegram: ''},
{_id: 38, reg: 'LAZ', prov: 'FR', descr: 'Frosinone', link_grp: 'https://t.me/c/1614195634/48?thread=44', link_telegram: ''},
{_id: 39, reg: 'LIG', prov: 'GE', descr: 'Genova', link_grp: 'https://t.me/c/1614195634/392?thread=388', link_telegram: ''},
{_id: 40, reg: 'FVG', prov: 'GO', descr: 'Gorizia', link_grp: 'https://t.me/c/1614195634/469?thread=465', link_telegram: ''},
{_id: 41, reg: 'TOS', prov: 'GR', descr: 'Grosseto', link_grp: 'https://t.me/c/1614195634/585?thread=574', link_telegram: ''},
{_id: 42, reg: 'LIG', prov: 'IM', descr: 'Imperia', link_grp: 'https://t.me/c/1614195634/393?thread=389', link_telegram: ''},
{_id: 43, reg: 'MOL', prov: 'IS', descr: 'Isernia', link_grp: 'https://t.me/c/1614195634/399?thread=397', link_telegram: ''},
{_id: 44, reg: 'LIG', prov: 'SP', descr: 'La Spezia', link_grp: 'https://t.me/c/1614195634/394?thread=390', link_telegram: ''},
{_id: 45, reg: 'ABR', prov: 'AQ', descr: 'L\'Aquila', link_grp: 'https://t.me/c/1614195634/364?thread=363', link_telegram: ''},
{_id: 46, reg: 'LAZ', prov: 'LT', descr: 'Latina', link_grp: 'https://t.me/c/1614195634/60?thread=46', link_telegram: ''},
{_id: 47, reg: 'PUG', prov: 'LE', descr: 'Lecce', link_grp: 'https://t.me/c/1614195634/538?thread=532', link_telegram: ''},
{_id: 48, reg: 'LOM', prov: 'LC', descr: 'Lecco', link_grp: 'https://t.me/c/1614195634/494?thread=482', link_telegram: ''},
{_id: 49, reg: 'TOS', prov: 'LI', descr: 'Livorno', link_grp: 'https://t.me/c/1614195634/586?thread=575', link_telegram: ''},
{_id: 50, reg: 'LOM', prov: 'LO', descr: 'Lodi', link_grp: 'https://t.me/c/1614195634/495?thread=483', link_telegram: ''},
{_id: 51, reg: 'TOS', prov: 'LU', descr: 'Lucca', link_grp: 'https://t.me/c/1614195634/587?thread=576', link_telegram: ''},
{_id: 52, reg: 'MAR', prov: 'MC', descr: 'Macerata', link_grp: 'https://t.me/c/1614195634/300?thread=162', link_telegram: ''},
{_id: 53, reg: 'LOM', prov: 'MN', descr: 'Mantova', link_grp: 'https://t.me/c/1614195634/497?thread=484', link_telegram: ''},
{_id: 54, reg: 'TOS', prov: 'MS', descr: 'Massa-Carrara', link_grp: 'https://t.me/c/1614195634/588?thread=577', link_telegram: ''},
{_id: 55, reg: 'BAS', prov: 'MT', descr: 'Matera', link_grp: 'https://t.me/c/1614195634/374?thread=373', link_telegram: ''},
{_id: 56, reg: 'SIC', prov: 'ME', descr: 'Messina', link_grp: 'https://t.me/c/1614195634/566?thread=557', link_telegram: ''},
{_id: 57, reg: 'LOM', prov: 'MI', descr: 'Milano', link_grp: 'https://t.me/c/1614195634/214?thread=173', link_telegram: ''},
{_id: 58, reg: 'EMR', prov: 'MO', descr: 'Modena', link_grp: 'https://t.me/c/1614195634/431?thread=422', link_telegram: ''},
{_id: 59, reg: 'LOM', prov: 'MB', descr: 'Monza e della Brianza', link_grp: 'https://t.me/c/1614195634/498?thread=485', link_telegram: ''},
{_id: 60, reg: 'CAM', prov: 'NA', descr: 'Napoli', link_grp: 'https://t.me/c/1614195634/407?thread=406', link_telegram: ''},
{_id: 61, reg: 'PIE', prov: 'NO', descr: 'Novara', link_grp: 'https://t.me/c/1614195634/517?thread=508', link_telegram: ''},
{_id: 62, reg: 'SAR', prov: 'NU', descr: 'Nuoro', link_grp: 'https://t.me/c/1614195634/548?thread=542', link_telegram: ''},
{_id: 63, reg: 'SAR', prov: 'OT', descr: 'Olbia-Tempio', link_grp: '', link_telegram: ''},
{_id: 64, reg: 'SAR', prov: 'OR', descr: 'Oristano', link_grp: 'https://t.me/c/1614195634/550?thread=543', link_telegram: ''},
{_id: 65, reg: 'VEN', prov: 'PD', descr: 'Padova', link_grp: 'https://t.me/c/1614195634/610?thread=600', link_telegram: ''},
{_id: 66, reg: 'SIC', prov: 'PA', descr: 'Palermo', link_grp: 'https://t.me/c/1614195634/568?thread=558', link_telegram: ''},
{_id: 67, reg: 'EMR', prov: 'PR', descr: 'Parma', link_grp: 'https://t.me/c/1614195634/432?thread=423', link_telegram: ''},
{_id: 68, reg: 'LOM', prov: 'PV', descr: 'Pavia', link_grp: 'https://t.me/c/1614195634/499?thread=486', link_telegram: ''},
{_id: 69, reg: 'UMB', prov: 'PG', descr: 'Perugia', link_grp: 'https://t.me/c/1614195634/403?thread=401', link_telegram: ''},
{_id: 70, reg: 'MAR', prov: 'PU', descr: 'Pesaro e Urbino', link_grp: 'https://t.me/c/1614195634/454?thread=449', link_telegram: ''},
{_id: 71, reg: 'ABR', prov: 'PE', descr: 'Pescara', link_grp: 'https://t.me/c/1614195634/368?thread=367', link_telegram: ''},
{_id: 72, reg: 'EMR', prov: 'PC', descr: 'Piacenza', link_grp: 'https://t.me/c/1614195634/433?thread=424', link_telegram: ''},
{_id: 73, reg: 'TOS', prov: 'PI', descr: 'Pisa', link_grp: 'https://t.me/c/1614195634/589?thread=578', link_telegram: ''},
{_id: 74, reg: 'TOS', prov: 'PT', descr: 'Pistoia', link_grp: 'https://t.me/c/1614195634/590?thread=579', link_telegram: ''},
{_id: 75, reg: 'FVG', prov: 'PN', descr: 'Pordenone', link_grp: 'https://t.me/c/1614195634/470?thread=466', link_telegram: ''},
{_id: 76, reg: 'BAS', prov: 'PZ', descr: 'Potenza', link_grp: 'https://t.me/c/1614195634/376?thread=375', link_telegram: ''},
{_id: 77, reg: 'TOS', prov: 'PO', descr: 'Prato', link_grp: 'https://t.me/c/1614195634/591?thread=580', link_telegram: ''},
{_id: 78, reg: 'SIC', prov: 'RG', descr: 'Ragusa', link_grp: 'https://t.me/c/1614195634/569?thread=559', link_telegram: ''},
{_id: 79, reg: 'EMR', prov: 'RA', descr: 'Ravenna', link_grp: 'https://t.me/c/1614195634/434?thread=425', link_telegram: ''},
{_id: 80, reg: 'CAL', prov: 'RC', descr: 'Reggio Calabria', link_grp: 'https://t.me/c/1614195634/385?thread=383', link_telegram: ''},
{_id: 81, reg: 'EMR', prov: 'RE', descr: 'Reggio Emilia', link_grp: 'https://t.me/c/1614195634/435?thread=426', link_telegram: ''},
{_id: 82, reg: 'LAZ', prov: 'RI', descr: 'Rieti', link_grp: 'https://t.me/c/1614195634/61?thread=45', link_telegram: ''},
{_id: 83, reg: 'EMR', prov: 'RN', descr: 'Rimini', link_grp: 'https://t.me/c/1614195634/436?thread=https://t.me/c/1614195634/64?thread=57427', link_telegram: ''},
{_id: 84, reg: 'LAZ', prov: 'RM', descr: 'Roma', link_grp: '', link_telegram: ''},
{_id: 85, reg: 'VEN', prov: 'RO', descr: 'Rovigo', link_grp: 'https://t.me/c/1614195634/611?thread=601', link_telegram: ''},
{_id: 86, reg: 'CAM', prov: 'SA', descr: 'Salerno', link_grp: 'https://t.me/c/1614195634/416?thread=412', link_telegram: ''},
{_id: 87, reg: 'SAR', prov: 'VS', descr: 'Medio Campidano', link_grp: '', link_telegram: ''},
{_id: 88, reg: 'SAR', prov: 'SS', descr: 'Sassari', link_grp: 'https://t.me/c/1614195634/551?thread=544', link_telegram: ''},
{_id: 89, reg: 'LIG', prov: 'SV', descr: 'Savona', link_grp: 'https://t.me/c/1614195634/395?thread=391', link_telegram: ''},
{_id: 90, reg: 'TOS', prov: 'SI', descr: 'Siena', link_grp: 'https://t.me/c/1614195634/592?thread=581', link_telegram: ''},
{_id: 91, reg: 'SIC', prov: 'SR', descr: 'Siracusa', link_grp: 'https://t.me/c/1614195634/570?thread=560', link_telegram: ''},
{_id: 92, reg: 'LOM', prov: 'SO', descr: 'Sondrio', link_grp: 'https://t.me/c/1614195634/500?thread=487', link_telegram: ''},
{_id: 93, reg: 'PUG', prov: 'TA', descr: 'Taranto', link_grp: 'https://t.me/c/1614195634/539?thread=533', link_telegram: ''},
{_id: 94, reg: 'ABR', prov: 'TE', descr: 'Teramo', link_grp: 'https://t.me/c/1614195634/370?thread=369', link_telegram: ''},
{_id: 95, reg: 'UMB', prov: 'TR', descr: 'Terni', link_grp: 'https://t.me/c/1614195634/404?thread=402', link_telegram: ''},
{_id: 96, reg: 'PIE', prov: 'TO', descr: 'Torino', link_grp: 'https://t.me/c/1614195634/518?thread=509', link_telegram: ''},
{_id: 97, reg: 'SAR', prov: 'OG', descr: 'Ogliastra', link_grp: '', link_telegram: ''},
{_id: 98, reg: 'SIC', prov: 'TP', descr: 'Trapani', link_grp: 'https://t.me/c/1614195634/571?thread=561', link_telegram: ''},
{_id: 99, reg: 'TAA', prov: 'TN', descr: 'Trento', link_grp: 'https://t.me/c/1614195634/597?thread=595', link_telegram: ''},
{_id: 100, reg: 'VEN', prov: 'TV', descr: 'Treviso', link_grp: 'https://t.me/c/1614195634/612?thread=602', link_telegram: ''},
{_id: 101, reg: 'FVG', prov: 'TS', descr: 'Trieste', link_grp: 'https://t.me/c/1614195634/471?thread=467', link_telegram: ''},
{_id: 102, reg: 'FVG', prov: 'UD', descr: 'Udine', link_grp: 'https://t.me/c/1614195634/472?thread=468', link_telegram: ''},
{_id: 103, reg: 'LOM', prov: 'VA', descr: 'Varese', link_grp: 'https://t.me/c/1614195634/501?thread=488', link_telegram: ''},
{_id: 104, reg: 'VEN', prov: 'VE', descr: 'Venezia', link_grp: 'https://t.me/c/1614195634/613?thread=603', link_telegram: ''},
{_id: 105, reg: 'PIE', prov: 'VB', descr: 'Verbano-Cusio-Ossola', link_grp: 'https://t.me/c/1614195634/519?thread=510 ', link_telegram: ''},
{_id: 106, reg: 'PIE', prov: 'VC', descr: 'Vercelli', link_grp: 'https://t.me/c/1614195634/512?thread=511', link_telegram: ''},
{_id: 107, reg: 'VEN', prov: 'VR', descr: 'Verona', link_grp: 'https://t.me/c/1614195634/614?thread=604', link_telegram: ''},
{_id: 108, reg: 'CAL', prov: 'VV', descr: 'Vibo Valentia', link_grp: 'https://t.me/c/1614195634/386?thread=384', link_telegram: ''},
{_id: 109, reg: 'VEN', prov: 'VI', descr: 'Vicenza', link_grp: 'https://t.me/c/1614195634/615?thread=605', link_telegram: ''},
{_id: 110, reg: 'LAZ', prov: 'VT', descr: 'Viterbo', link_grp: 'https://t.me/c/1614195634/76?thread=74', link_telegram: ''},
{_id: 111, reg: 'RSM', prov: 'RSM', descr: 'Repubblica di San Marino', link_grp: 'https://t.me/+HSdNurm0IXY1MGI0', link_telegram: ''},
{_id: 112, reg: 'EST', prov: 'EST', descr: 'Estero', link_grp: '', link_telegram: ''},
{_id: 113, reg: 'ONL', prov: 'ONL', descr: 'On Line', link_grp: '', link_telegram: ''},
{_id: 114, reg: 'LAZ', prov: 'RM', descr: 'Roma Nord-Est', card: 'NORD-EST', link_grp: 'https://t.me/c/1614195634/64?thread=57', link_telegram: ''},
{_id: 115, reg: 'LAZ', prov: 'RM', descr: 'Roma Sud-Est', card: 'SUD-EST', link_grp: 'https://t.me/c/1614195634/65?thread=58', link_telegram: ''},
{_id: 116, reg: 'LAZ', prov: 'RM', descr: 'Roma Nord', card: 'NORD', link_grp: 'https://t.me/c/1614195634/75?thread=73', link_telegram: ''},
{_id: 117, reg: 'LAZ', prov: 'RM', descr: 'Roma Nord-Ovest', card: 'NORD-OVEST', link_grp: 'https://t.me/c/1614195634/62?thread=47', link_telegram: ''},
{_id: 118, reg: 'LAZ', prov: 'RM', descr: 'Roma Sud e Litorale', card: 'SUD', link_grp: 'https://t.me/c/1614195634/67?thread=43', link_telegram: ''},
{_id: 119, reg: 'PUG', prov: 'VAL', descr: 'Valle D\'Itria', link_grp: 'https://t.me/progettoriso/7016?thread=7015', link_telegram: ''},
{_id: 120, reg: 'SAR', prov: 'SUS', descr: 'Sud Sardegna', link_grp: 'https://t.me/c/1614195634/552?thread=545', link_telegram: ''},
{_id: 121, reg: 'ITA', prov: 'ITA', descr: 'Italia', link_grp: '', link_telegram: ''},
{_id: 122, reg: 'LOM', prov: 'MI', card: 'EST', descr: 'Milano Est', link_grp: '', link_telegram: ''},
],
};

View File

@@ -42,7 +42,7 @@ module.exports = {
{_id: 40, idSector: [7], descr: 'Muratore'},
{_id: 41, idSector: [7], descr: 'Imbianchino'},
{_id: 42, idSector: [7], descr: 'Elettricista - TV'},
{_id: 43, idSector: [7], descr: 'Falegname e restauro'},
{_id: 43, idSector: [7], descr: 'Falegname'},
{_id: 44, idSector: [7], descr: 'Fabbro'},
{_id: 45, idSector: [7], descr: 'Arredamento'},
{_id: 46, idSector: [7], descr: 'Idraulico'},
@@ -122,7 +122,10 @@ module.exports = {
{_id: 127, idSector: [1], descr: 'Stanza in affitto'},
{_id: 128, idSector: [1], descr: 'Stanza in condivisione'},
{_id: 129, idSector: [3], descr: 'Home Restaurant'},
{_id: 130, idSector: [7], descr: 'Pompe di calore'},
{_id: 131, idSector: [7], descr: 'Impianti Fotovoltaici'},
{_id: 130, idSector: [7], descr: 'Pannelli Solari'},
{_id: 131, idSector: [7], descr: 'Pompe di calore'},
{_id: 132, idSector: [7], descr: 'Impianti Fotovoltaici'},
{_id: 133, idSector: [7], descr: 'Restauro'},
{_id: 134, idSector: [7], descr: 'Altro'},
],
};

View File

@@ -30,17 +30,20 @@ const Cart = require('../models/cart');
const OrdersCart = require('../models/orderscart');
//GET cart
router.get('/:userId', authenticate, function (req, res, next) {
let userId = req.body.userId
let idapp = req.body.idapp
Cart.getCartByUserId(userId, idapp, function (err, cart) {
if (err) return next(err)
router.get('/:userId', authenticate, async function (req, res, next) {
let userId = req.params.userId
let idapp = req.user.idapp
return await Cart.getCartByUserId(userId, idapp)
.then((cart) => {
if (cart)
return res.send({ code: server_constants.RIS_CODE_OK, cart });
else
return res.status(400).send(e);
}).catch((err) => {
console.error('Err', err);
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null });
});
if (cart)
res.send({ code: server_constants.RIS_CODE_OK, cart });
else
res.status(400).send(e);
})
})
//POST cart
@@ -51,46 +54,54 @@ router.post('/:userId', authenticate, async function (req, res, next) {
let subqty = req.body.subqty;
let order = req.body.order;
const mycart = await Cart.getCartByUserId(userId, idapp);
try {
// const myorder = Order.getOrderByID(order._id);
if (!addqty && !subqty)
order._id = await Order.createOrder(order);
const mycart = await Cart.getCartByUserId(userId, idapp);
let cart = null;
// no cart save empty cart to database then return response
let myqty = 0;
if (!mycart) {
let oldCart = new CartClass(order)
cart = await Cart.createCart(oldCart.generateModel());
} else {
let newCart = CartClass.constructByCart(mycart);
if (addqty) {
myqty = await newCart.addqty(order);
} else if (subqty) {
myqty = await newCart.subqty(order);
// const myorder = Order.getOrderByID(order._id);
if (!addqty && !subqty)
order._id = await Order.createOrder(order);
let cart = null;
// no cart save empty cart to database then return response
let myqty = 0;
if (!mycart) {
let oldCart = new CartClass(order)
cart = await Cart.createCart(oldCart.generateModel());
} else {
const ind = newCart.addItem(order);
let newCart = CartClass.constructByCart(mycart);
if (addqty) {
myqty = await newCart.addqty(order);
} else if (subqty) {
myqty = await newCart.subqty(order);
} else {
const ind = newCart.addItem(order);
}
cart = await Cart.updateCartByCartId(mycart._id, newCart.generateModel());
}
cart = await Cart.updateCartByCartId(mycart._id, newCart.generateModel());
}
if (cart) {
const carttot = await Cart.getCartByUserId(userId, idapp);
return res.send({ code: server_constants.RIS_CODE_OK, cart: carttot, qty: myqty });
} else {
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null });
if (cart) {
const carttot = await Cart.getCartByUserId(userId, idapp);
return res.send({ code: server_constants.RIS_CODE_OK, cart: carttot, qty: myqty });
} else {
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null });
}
/*
Cart.updateCartByUserId(
userId,
newCart,
function (err, result) {
if (err) return next(err)
return res.status(200).json({ cart: result })
})
*/
} catch (e) {
return res.send({ code: server_constants.RIS_CODE_ERR, cart: 0 });
}
/*
Cart.updateCartByUserId(
userId,
newCart,
function (err, result) {
if (err) return next(err)
return res.status(200).json({ cart: result })
})
*/
})
router.delete('/:userId', authenticate, async function (req, res) {
@@ -122,47 +133,56 @@ router.delete('/:userId', authenticate, async function (req, res) {
//PUT cart
router.put('/:userId', authenticate, function (req, res, next) {
router.put('/:userId', authenticate, async function (req, res, next) {
let userId = req.params.userId
let requestProduct = req.body
let { productId, color, size } = requestProduct.product
Cart.getCartByUserId(userId, function (err, c) {
if (err) return next(err)
let oldCart = new CartClass(c[0] || {})
Product.getProductByID(productId, function (err, p) {
if (err) return next(err)
let newCart = oldCart.add(p, productId, { color, size })
try {
//exist cart in databse
if (c.length > 0) {
Cart.updateCartByUserId(
userId,
{
await Cart.getCartByUserId(userId, function (err, c) {
if (err) return next(err)
let oldCart = new CartClass(c[0] || {})
Product.getProductByID(productId, function (err, p) {
if (err) return next(err)
let newCart = oldCart.add(p, productId, { color, size })
//exist cart in databse
if (c.length > 0) {
Cart.updateCartByUserId(
userId,
{
items: newCart.items,
totalQty: newCart.totalQty,
totalPrice: newCart.totalPrice,
userId: userId
},
function (err, result) {
if (err) return next(err)
res.json(result)
})
} else {
//no cart in database
newCart = new Cart({
items: newCart.items,
totalQty: newCart.totalQty,
totalPrice: newCart.totalPrice,
userId: userId
},
function (err, result) {
if (err) return next(err)
res.json(result)
})
} else {
//no cart in database
newCart = new Cart({
items: newCart.items,
totalQty: newCart.totalQty,
totalPrice: newCart.totalPrice,
userId: userId
})
Cart.createCart(newCart, function (err, resultCart) {
if (err) return next(err)
res.status(201).json(resultCart)
})
}
Cart.createCart(newCart, function (err, resultCart) {
if (err) return next(err)
res.status(201).json(resultCart)
})
}
})
})
})
return res.send({ code: server_constants.RIS_CODE_OK });
} catch (e) {
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
}
})
//POST cart

View File

@@ -5,6 +5,8 @@ const tools = require('../tools/general');
const server_constants = require('../tools/server_constants');
const shared_consts = require('../tools/shared_nodejs');
const { authenticate } = require('../middleware/authenticate');
const mongoose = require('mongoose').set('debug', false);
@@ -19,11 +21,17 @@ const { ObjectID } = require('mongodb');
async function getCircuitRecAdminsInfo(idapp, data) {
if (data && data.admins) {
for (const admin of data.admins) {
const myuser = await User.findOne({ idapp, username: admin.username }, { 'profile.img': 1 }).lean();
admin.profile = { img: myuser.profile.img };
try {
if (data && data.admins) {
for (const admin of data.admins) {
const myuser = await User.findOne({ idapp, username: admin.username }, { 'profile.img': 1 }).lean();
if (myuser && myuser.profile)
admin.profile = { img: myuser.profile.img };
}
}
} catch (e) {
console.error(e);
return data;
}
return data;
@@ -73,10 +81,11 @@ router.post('/load', authenticate, async (req, res) => {
}
if (data) {
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, '', data.path);
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, false, '', data.path);
}
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp);
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
/// E' QUIIII !!!!
const useraccounts = await Account.getUserAccounts(idapp, req.user.username);
await User.setLastCircuitOpened(idapp, req.user.username, path);

View File

@@ -66,6 +66,7 @@ const Cart = require('../models/cart');
const OrdersCart = require('../models/orderscart');
const Storehouse = require('../models/storehouse');
const Department = require('../models/department');
const { Category } = require('../models/category');
const Group = require('../models/group');
const tools = require('../tools/general');
@@ -270,6 +271,7 @@ router.get('/test1', authenticate_noerror, async (req, res) => {
router.post('/settable', authenticate, async (req, res) => {
const params = req.body;
const mytable = globalTables.getTableByTableName(params.table);
let mydata = req.body.data;
let extrarec = {};
if (mydata && mydata.hasOwnProperty('extrarec')) {
@@ -277,6 +279,11 @@ router.post('/settable', authenticate, async (req, res) => {
delete mydata['extrarec'];
}
if (mydata === undefined) {
console.error('MYDATA VUOTO !');
return res.status(400).send('Mydata VUOTO');
}
const fieldsvalue = { 'ALL': 1 };
mydata.idapp = req.user.idapp;
@@ -354,7 +361,7 @@ router.post('/settable', authenticate, async (req, res) => {
const mytablestrutt = globalTables.getTableByTableName(params.table);
if (mydata['_id'] !== undefined && mydata['_id'] !== 0) {
if (mydata['_id'] !== undefined && mydata['_id'] !== 0 && mydata['_id'] !== '') {
mytablerec.isNew = false;
}
@@ -364,9 +371,10 @@ router.post('/settable', authenticate, async (req, res) => {
} else if (params.table === 'hours') {
} else {
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined)) {
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined || mytablerec._id === '0')) {
mytablerec._id = new ObjectID();
mydata._id = new ObjectID();
mytablerec.isNew = true;
}
}
@@ -413,8 +421,22 @@ router.post('/settable', authenticate, async (req, res) => {
resolve(mytablerec._id && mytable.findById(mytablerec._id))
});
// Controlla se esiste già questo record:
if (shared_consts.TABLES_FIELDS_DESCR_AND_CITY_AND_USER.includes(params.table)) {
if (mytablerec.isNew) {
const trovatoDuplicato = await mytable.findOne({ idapp: mytablerec.idapp, descr: mytablerec.descr, idCity: mytablerec.idCity, userId: mytablerec.userId }).lean();
if (trovatoDuplicato) {
// trovatoDuplicato
return res.status(200).send({ code: server_constants.RIS_CODE_REC_DUPLICATED_DESCR_CITY_USER, msg: '' });
}
}
}
return await myPromise
.then(async (doupdate) => {
if (doupdate)
return mytable.updateOne({ _id: mytablerec._id }, mydata, { new: true })
else
@@ -448,9 +470,12 @@ router.post('/settable', authenticate, async (req, res) => {
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
typeid = (params.table === shared_consts.TABLES_MYGOODS)
? shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD
: shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE;
if (params.table === shared_consts.TABLES_MYGOODS)
typeid = shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD
else if (params.table === shared_consts.TABLES_MYSKILLS)
typeid = shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE
else if (params.table === shared_consts.TABLES_MYHOSPS)
typeid = shared_consts.TypeNotifs.ID_BACHECA_NEW_HOSP
setnotif = true;
}
@@ -466,16 +491,18 @@ router.post('/settable', authenticate, async (req, res) => {
groupnameDest = myrec ? myrec.groupname : '';
setnotif = true;
}
if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(params.table)) {
/*if (shared_consts.TABLES_CIRCUITS_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
circuitnameDest = myrec ? myrec.name : '';
setnotif = (myrec.visibility === 0); // Not send a notification to others if the Circuit is HIDDEN or PRIVATE
}
}*/
}
if (setnotif) {
await SendNotif.createNewNotification(req, res, { groupnameDest, circuitnameDest }, params.table, myrec, typedir, typeid);
const myreq = { ...req };
const myres = { ...res };
SendNotif.createNewNotification(myreq, myres, { groupnameDest, circuitnameDest }, params.table, myrec, typedir, typeid);
}
if (params.table === 'circuits') {
@@ -589,7 +616,7 @@ router.post('/gettable', authenticate, (req, res) => {
const params = req.body;
let idapp = req.user ? req.user.idapp : params.idapp;
const mytable = globalTables.getTableByTableName(params.table);
// console.log('mytable', mytable);
//console.log('mytable', mytable);
if (!mytable) {
console.log(`Table ${params.table} not found`);
return res.status(400).send({});
@@ -601,7 +628,9 @@ router.post('/gettable', authenticate, (req, res) => {
User.setOnLine(req.user.idapp, req.user.username);
}
return mytable.executeQueryTable(idapp, params, req.user).then(ris => {
// console.log('ris=', ris);
return res.send(ris);
}).catch((e) => {
@@ -780,13 +809,17 @@ router.patch('/chval', authenticate, async (req, res) => {
const fieldsvalue = mydata.fieldsvalue;
const unset = mydata.unset;
const { Account } = require('../models/account');
// tools.mylogshow('PATCH CHVAL: ', id, fieldsvalue);
// If I change my record...
if ((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) &&
if (((!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm) &&
!User.isEditor(req.user.perm) && !User.isFacilitatore(req.user.perm)) &&
(req.user._id.toString() !== id) &&
!tools.ModificheConsentite(mydata.table, fieldsvalue)) {
(!tools.ModificheConsentite(mydata.table, fieldsvalue)))
&& !((mydata.table === 'accounts') && await Account.canEditAccountAdmins(req.user.username, mydata.id))
) {
// If without permissions, exit
return res.status(404).
send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
@@ -921,8 +954,9 @@ router.patch('/chval', authenticate, async (req, res) => {
if (mydata.table === 'users') {
if ('profile.resid_province' in fieldsvalue) {
const card = fieldsvalue.hasOwnProperty('profile.resid_card') ? fieldsvalue['profile.resid_card'] : '';
// Controlla se esiste il Circuito di questa provincia, se non esiste lo crea!
await Circuit.createCircuitIfNotExist(req, idapp, fieldsvalue['profile.resid_province']);
await Circuit.createCircuitIfNotExist(req, idapp, fieldsvalue['profile.resid_province'], card);
}
if (camporequisiti) {
@@ -1249,11 +1283,11 @@ router.post('/duprec/:table/:id', authenticate, async (req, res) => {
send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
if (!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) {
/* if (!User.isAdmin(req.user.perm) && !User.isManager(req.user.perm)) {
// If without permissions, exit
return res.status(404).
send({ code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: '' });
}
} */
return await mytable.findById(id).then(async (mydata) => {
@@ -1346,6 +1380,9 @@ function load(req, res, version) {
const permissions = Permission.findAllIdApp();
// const versionstr = User....
// let version = tools.getVersionint(versionstr);
let newstosent = Promise.resolve([]);
let mailinglist = Promise.resolve([]);
let mypage;
@@ -1368,6 +1405,7 @@ function load(req, res, version) {
let workers = User.getusersWorkersList(idapp);
let storehouses = Storehouse.findAllIdApp(idapp);
let departments = Department.findAllIdApp(idapp);
let categories = Category.findAllIdApp(idapp);
// SKILLS:
let levels = Level.findAllIdApp(idapp);
@@ -1406,7 +1444,7 @@ function load(req, res, version) {
let myuserextra = null;
if (req.user) {
// askedfriends = User.getAskedFriendsByUsername(idapp, req.user.username);
myuserextra = User.addExtraInfo(idapp, req.user._doc, req.user);
myuserextra = User.addExtraInfo(idapp, req.user._doc, req.user, version);
}
return Promise.all([
@@ -1451,6 +1489,7 @@ function load(req, res, version) {
mygroups,
listcircuits, // 37
myelems, // 38
categories, // 39
]).then((arrdata) => {
// console.table(arrdata);
let myuser = req.user;
@@ -1532,7 +1571,10 @@ function load(req, res, version) {
mygroups: arrdata[36],
listcircuits: arrdata[37],
myelems: arrdata[38],
categories: arrdata[39],
});
const prova = 1;
}
}).catch((e) => {
@@ -1849,10 +1891,14 @@ function deleteFile(req, res, version) {
const relativefile = req.query.filename;
const idapp = req.user.idapp;
if (!relativefile || relativefile.endsWith('/')) {
res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
}
try {
let dirmain = '';
if (version > 0) {
if (tools.sulServer() !== 1) {
if (!tools.sulServer()) {
dirmain = '/public';
}
}

View File

@@ -5,60 +5,76 @@ const router = express.Router();
const tools = require('../tools/general');
var server_constants = require('../tools/server_constants');
var {authenticate, auth_default} = require('../middleware/authenticate');
var { authenticate, authenticate_noerror, auth_default } = require('../middleware/authenticate');
var mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const _ = require('lodash');
const {MyBacheca} = require('../models/mybacheca');
var {User} = require('../models/user');
const { MyBacheca } = require('../models/mybacheca');
var { User } = require('../models/user');
const { Reaction } = require('../models/reaction');
const globalTables = require('../tools/globalTables');
const {ObjectID} = require('mongodb');
const { ObjectID } = require('mongodb');
//GET orders
router.post('/page', authenticate, function(req, res, next) {
router.post('/page', authenticate_noerror, function (req, res, next) {
const {SendNotif} = require('../models/sendnotif');
const { SendNotif } = require('../models/sendnotif');
try {
let table = req.body.table;
let id = req.body.id;
let idapp = req.body.idapp;
const username = req.user.username ? req.user.username : '';
let username = ''
if (req.user)
username = req.user.username ? req.user.username : '';
// Check if ìs a Notif to read
const idnotif = req.body.idnotif ? req.body.idnotif : '';
SendNotif.setNotifAsRead(idapp, username, idnotif);
if (username) {
// Check if ìs a Notif to read
const idnotif = req.body.idnotif ? req.body.idnotif : '';
SendNotif.setNotifAsRead(idapp, username, idnotif);
}
let mytable = null;
if (shared_consts.TABLES_ENABLE_GETREC_BYID.includes(table)) {
mytable = globalTables.getTableByTableName(table);
}
if (mytable) {
return mytable.getMyRecById(idapp, id).
then((ris) => {
then(async (ris) => {
if (ris) {
res.send(ris);
// Se è un record singolo di tipo Reaction,
// allora gli devo passare anche le liste degli utenti :
if (globalTables.isTableReaction(table)) {
// ...
// const myreaction = await Reaction.find({idapp, idrec: id}).lean();
// ris.myreaction = myreaction;
} else {
res.status(400).send();
}
}).catch((e) => {
console.error('Err', e);
res.status(400).send(e);
})
};
if (ris) {
res.send(ris);
} else {
res.status(400).send();
}
}).catch((e) => {
console.error('Err', e);
res.status(400).send(e);
})
}
}catch (e) {
} catch (e) {
console.error('/page', e);
}

View File

@@ -59,7 +59,7 @@ router.post('/load', authenticate, async (req, res) => {
for (let i = 0; i < data.mycircuits.length; i++) {
const mycirc = await Circuit.findOne({ idapp, name: data.mycircuits[i].circuitname }).lean();
if (mycirc)
data.mycircuits[i].account = await Account.getAccountByUsernameAndCircuitId(idapp, '', mycirc._id, true, groupname);
data.mycircuits[i].account = await Account.getAccountByUsernameAndCircuitId(idapp, '', mycirc._id, true, true, groupname);
}
}

View File

@@ -0,0 +1,127 @@
const express = require('express');
const router = express.Router();
const { Reaction } = require('../models/reaction');
const { User } = require('../models/user');
const Hours = require('../models/hours');
const { ObjectID } = require('mongodb');
const sendemail = require('../sendemail');
const { Settings } = require('../models/settings');
const { SendNotif } = require('../models/sendnotif');
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
const server_constants = require('../tools/server_constants');
const telegrambot = require('../telegram/telegrambot');
const _ = require('lodash');
const reg = require('../reg/registration');
const { authenticate, authenticate_noerror } = require('../middleware/authenticate');
const TypedError = require('../modules/ErrorHandler');
const globalTables = require('../tools/globalTables');
const mongoose = require('mongoose').set('debug', false);
router.post('/cmd', authenticate_noerror, async (req, res) => {
const mydata = req.body.mydata;
const idapp = req.body.idapp;
const cmd = req.body.cmd;
const id = req.body.id;
const tab = req.body.tab;
const num = req.body.num;
const value = req.body.value;
try {
const table = tools.getTableByNumTab(tab);
const mytable = globalTables.getTableByTableName(table);
let username = '';
if (req.user) {
username = req.user.username;
} else {
return res.send({ state: 0, record: null });
}
let ris = null;
let record = null;
const { User } = require('../models/user');
let objtoupdate = {};
if (cmd === shared_consts.CMD_REACTION.SET_FAVORITE) {
if (tab) {
if (value) {
ris = await Reaction.addFavorite(req, idapp, username, id, tab);
} else {
ris = await Reaction.removeFavorite(idapp, username, id, tab);
}
}
} else if (cmd === shared_consts.CMD_REACTION.SET_BOOKMARK) {
if (tab) {
if (value)
ris = await Reaction.addBookmark(req, idapp, username, id, tab);
else
ris = await Reaction.removeBookmark(idapp, username, id, tab);
}
} else if (cmd === shared_consts.CMD_REACTION.SET_ATTEND) {
if (tab) {
if (value)
ris = await Reaction.addAttend(req, idapp, username, id, tab, num);
else
ris = await Reaction.removeAttend(idapp, username, id, tab);
}
} else if (cmd === shared_consts.CMD_REACTION.SET_SEEN) {
if (tab) {
if (value) {
ris = await Reaction.addSeen(req, idapp, username, id, tab);
}
const tabtofind = tools.getNumTabByTable('mybachecas');
if (tab === tabtofind) {
const { MyBacheca } = require('../models/mybacheca');
record = await MyBacheca.getCompleteRecord(idapp, id);
}
}
}
let state = (value && ris && ris.ok === 1) ? 1 : ((!value && ris && ris.ok === 1) ? -1 : 0);
const risreac = await Reaction.calcReactions(idapp, id, tab);
if (risreac) {
delete risreac._id;
objtoupdate = risreac;
}
if (mytable) {
ris = await mytable.updateOne({ _id: id }, {
$set: objtoupdate,
})
}
return res.send({ state, record });
} catch (e) {
res.status(400).send();
res.send({ code: server_constants.RIS_CODE_ERR, msg: e, state: null, record: null });
console.log(e.message);
}
});
module.exports = router;

View File

@@ -10,7 +10,7 @@ const { User } = require('../models/user');
const { Operator } = require('../models/operator');
const { SendMsg } = require('../models/sendmsg');
const {SendNotif} = require('../models/sendnotif');
const { SendNotif } = require('../models/sendnotif');
const { ObjectID } = require('mongodb');
@@ -35,7 +35,7 @@ router.post('/', authenticate, (req, res) => {
User.setOnLine(req.user.idapp, req.user.username);
}
const check = tools.checkUserOk(myrecmsg.origin.username, req.user.username, res);
const check = tools.checkUserOk(myrecmsg.origin, req.user.username, res);
if (check.exit) return check.ret;
// console.log('fieldtochange', fieldtochange);
@@ -49,26 +49,37 @@ router.post('/', authenticate, (req, res) => {
return SendMsg.findById(idobj)
.then(async (recmsg) => {
const myrecsend = new SendNotif(
{
title: recmsg.source.infoevent,
sender: recmsg.origin,
dest: recmsg.dest,
openUrl: '',
});
// Add this field because I don't want to add into the database
recmsg.source.infoevent = body.source.infoevent;
// myrecsend.source.infoevent = body.source.infoevent;
recmsg.typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS;
recmsg.typeid = shared_consts.TypeNotifs.ID_EVENTS_REMOVE_REC;
myrecsend.typedir = shared_consts.TypeNotifs.TYPEDIR_EVENTS;
myrecsend.typeid = shared_consts.TypeNotifs.ID_EVENTS_SEND_MSG;
myrecsend.msg = recmsg.message;
let myid = recmsg._id;
// ##Todo !! DA SISTEMARE !!!
return await SendNotif.saveAndSendNotif(recmsg, req, res).then((out) => {
return await SendNotif.saveAndSendNotif(myrecsend, req, res).then((out) => {
if (out)
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: myid });
else
return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
})
});
}).catch((e) => {
console.log(e.message);
console.error(e.message);
// res.status(400).send(e);
return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
// return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
})
let fine = '';
});
router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {

View File

@@ -144,7 +144,7 @@ router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
return res.status(404).send({code: server_constants.RIS_CODE_NOT_MY_USERNAME});
}
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp).then(async (arrnotif) => {
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp, shared_consts.LIMIT_NOTIF_FOR_USER).then(async (arrnotif) => {
// const wait = new Promise((resolve, reject) => {
// setTimeout(() => {

View File

@@ -59,7 +59,7 @@ router.post('/load', authenticate, async (req, res) => {
for (let i = 0; i < data.mycircuits.length; i++) {
const mycirc = await Circuit.findOne({ idapp, name: data.mycircuits[i].circuitname }).lean();
if (mycirc)
data.mycircuits[i].account = await Account.getAccountByUsernameAndCircuitId(idapp, '', mycirc._id, true, groupname);
data.mycircuits[i].account = await Account.getAccountByUsernameAndCircuitId(idapp, '', mycirc._id, true, true, groupname);
}
}

View File

@@ -28,7 +28,8 @@ const _ = require('lodash');
const reg = require('../reg/registration');
const { authenticate } = require('../middleware/authenticate');
const { authenticate, authenticate_noerror } = require('../middleware/authenticate');
const Cart = require('../models/cart');
const CartClass = require('../modules/Cart');
@@ -428,7 +429,7 @@ router.post('/receiveris', authenticate, (req, res) => {
};
});
router.post('/profile', (req, res) => {
router.post('/profile', authenticate_noerror, (req, res) => {
const usernameOrig = req.user ? req.user.username : '';
const perm = req.user ? req.user.perm : tools.Perm.PERM_NONE;
const username = req.body['username'];
@@ -447,8 +448,16 @@ router.post('/profile', (req, res) => {
then((ris) => {
return User.getFriendsByUsername(idapp, usernameOrig).
then((friends) => {
res.send({ user: ris, friends });
then(async (friends) => {
if (username === usernameOrig) {
const userprofile = await User.getExtraInfoByUsername(idapp, username);
ris.profile = userprofile;
}
return { ris, friends };
}).then(tot => {
return res.send({ user: tot.ris, friends: tot.friends });
});
}).catch((e) => {
@@ -705,6 +714,33 @@ router.post('/circuits', authenticate, (req, res) => {
});
router.post('/updatesaldo', authenticate, async (req, res) => {
const username = req.user.username;
idapp = req.body.idapp;
locale = req.body.locale;
circuitId = req.body.circuitId;
groupname = req.body.groupname;
const lastdr = req.body['lastdr'] ? req.body['lastdr'] : '';
try {
const userprofile = await User.getExtraInfoByUsername(idapp, username);
let ris = {
userprofile
}
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
ris.arrrecnotif = arrrecnotif;
return res.send({ ris });
} catch (e) {
tools.mylog('ERRORE IN updatesaldo: ' + e);
res.status(400).send();
};
});
router.post('/friends/cmd', authenticate, async (req, res) => {
const usernameLogged = req.user.username;
const idapp = req.body.idapp;
@@ -741,6 +777,29 @@ router.post('/friends/cmd', authenticate, async (req, res) => {
});
router.post('/sendcmd', authenticate, async (req, res) => {
const usernameLogged = req.user.username;
const idapp = req.body.idapp;
const locale = req.body.locale;
let usernameOrig = req.body.usernameOrig;
let usernameDest = req.body.usernameDest;
const cmd = req.body.cmd;
const value = req.body.value;
usernameOrig = await User.getRealUsernameByUsername(idapp, usernameOrig);
usernameDest = await User.getRealUsernameByUsername(idapp, usernameDest);
return User.sendCmd(req, idapp, usernameOrig, usernameDest, cmd, value).
then((ris) => {
res.send(ris);
}).
catch((e) => {
tools.mylog('ERRORE IN sendcmd: ' + e.message);
res.status(400).send();
});
});
router.post('/groups/cmd', authenticate, (req, res) => {
const usernameLogged = req.user.username;
const idapp = req.body.idapp;
@@ -813,6 +872,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
const populate = require('../populate/populate');
const globalTables = require('../tools/globalTables');
const { Reaction } = require('../models/reaction');
let mystr = '';
@@ -1127,11 +1187,6 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
if (User.isAdmin(req.user.perm)) {
ris = globalTables.replaceUsername(req.body.idapp, mydata.search_username, mydata.replace_username);
}
} else if (mydata.dbop === 'ReplaceCircuitName') {
if (User.isAdmin(req.user.perm)) {
ris = globalTables.ReplaceCircuitName(req.body.idapp, mydata.search_username, mydata.replace_username);
}
} else if (mydata.dbop === 'copyFrom1To14') {
const idapporig = 1;
@@ -1171,6 +1226,21 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
console.log('e', e);
}
} else if (mydata.dbop === 'removeRecordsFav') {
// Passa le tabelle da users sulle nuove tabelle:
await User.removerecordsFavorite();
} else if (mydata.dbop === 'updateReactionsCounts') {
await Reaction.updateReactionsCounts();
} else if (mydata.dbop === 'newRecordsFav') {
// Passa le tabelle da users sulle nuove tabelle:
await User.moverecordsFavorite(1);
await User.moverecordsFavorite(2);
await User.moverecordsFavorite(3);
await User.moverecordsFavorite(4);
await User.moverecordsFavorite(5);
} else if (mydata.dbop === 'emptyTabCatServiziBeni') {
const { Sector } = require('../models/sector');
@@ -1246,6 +1316,48 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
await City.remove({});
await Province.remove({});
} else if (mydata.dbop === 'ConvTablesFromIntToString') {
const { MySkill } = require('../models/myskill');
const { MyBacheca } = require('../models/mybacheca');
const { MyHosp } = require('../models/myhosp');
const { MyGood } = require('../models/mygood');
const { MyGroup } = require('../models/mygroup');
console.log('INIZIO - Conversioni');
// 'myskills',
// 'mybachecas',
// 'myhosps',
// 'mygoods',
// 'mygroups'
await ConvertiDaIntAStr(MySkill);
await ConvertiDaIntAStr(MyBacheca);
await ConvertiDaIntAStr(MyHosp);
await ConvertiDaIntAStr(MyGood);
await ConvertiDaIntAStr(MyGroup);
console.log('FINE - Conversioni');
} else if (mydata.dbop === 'Removeinteger') {
const { MySkill } = require('../models/myskill');
const { MyBacheca } = require('../models/mybacheca');
const { MyHosp } = require('../models/myhosp');
const { MyGood } = require('../models/mygood');
const { MyGroup } = require('../models/mygroup');
console.log('INIZIO - Rimozione');
await RimuoviInteri(MySkill);
await RimuoviInteri(MyBacheca);
await RimuoviInteri(MyHosp);
await RimuoviInteri(MyGood);
await RimuoviInteri(MyGroup);
console.log('FINE - Rimozione');
} else if (mydata.dbop === 'createAllCircuits') {
const { Province } = require('../models/province');
@@ -1256,7 +1368,11 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
} else if (mydata.dbop === 'ImpostaMinMaxPersonali') {
await Account.SetMinMaxPersonali(idapp, mydata.valmin, mydata.valmax);
await Account.SetMinMaxPersonali(idapp, mydata.valmin, mydata.valmax, '');
} else if (mydata.dbop === 'ImpostaMinMaxPersonaliCircuito') {
await Account.SetMinMaxPersonali(idapp, mydata.valmin, mydata.valmax, mydata.circuitId);
} else if (mydata.dbop === 'ImpostaMinMaxComunitari') {
@@ -1268,20 +1384,28 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
} else if (mydata.dbop === 'ImpostaDefMinMaxPersonali') {
await Circuit.SetDefMinMaxPersonali(idapp, mydata.valmin, mydata.valmax);
await Circuit.SetDefMinMaxPersonali(idapp, mydata.valmin, mydata.valmax, mydata.circuitId);
} else if (mydata.dbop === 'ImpostaDefMinMaxCollettivi') {
await Circuit.SetDefMinMaxCollettivi(idapp, mydata.valmin, mydata.valmax);
await Circuit.SetDefMinMaxCollettivi(idapp, mydata.valmin, mydata.valmax, mydata.circuitId);
} else if (mydata.dbop === 'ReplaceAllCircuits') {
} else if (mydata.dbop === 'AbilitaTuttiCircuiti') {
await Circuit.replaceAllCircuits(idapp);
await Circuit.AbilitaTuttiCircuiti(idapp);
} else if (mydata.dbop === 'AzzeraRegolamentiTuttiCircuiti') {
await Circuit.AzzeraRegolamentiTuttiCircuiti(idapp);
} else if (mydata.dbop === 'setstrProvByIdCityCircuits') {
await Circuit.setstrProvByIdCityCircuits(idapp);
} else if (mydata.dbop === 'updateSaldoAndTransato_AllAccounts') {
await Account.updateSaldoAndTransato_AllAccounts(idapp);
/*} else if (mydata.dbop === 'visuNave') {
mystr = await Nave.getNavePos(idapp, parseInt(mydata.riga), parseInt(mydata.col));
@@ -1318,6 +1442,77 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
}
};
async function ConvertiDaIntAStr(mytable) {
try {
console.log('INIZIO - ConvertiDaIntAStr ', mytable.modelName);
return await mytable.find({ '_id': { $type: 16 } })
.then(async (arr) => {
console.log('num record ', arr.length)
let ind = 0;
for (let x of arr) {
const idnew = x._id;
if (idnew < 10000) {
const idint = parseInt(x._id, 10) + 10000;
const myrec = new mytable(x._doc);
myrec._doc.date_created = x._doc.date_created;
myrec._doc.date_updated = x._doc.date_updated;
if (!myrec._doc.date_updated) {
if (myrec.hasOwnProperty('date_created'))
myrec._doc.date_updated = myrec._doc.date_created;
}
if ((myrec.hasOwnProperty('date_updated') && !myrec._doc.date_created))
myrec._doc.date_created = myrec._doc.date_updated;
myrec._doc._id = idint + '';
let ris = await myrec.save((async function (err, doc) {
if (doc) {
ind++;
//await mytable.findOneAndRemove({ _id: parseInt(doc._id, 10) });
console.log('++Add (', ind, ')', doc._id);
} else {
const myid = parseInt(err.keyValue._id, 10) + 0;
const canc = await mytable.findOneAndRemove({ _id: myid });
if (canc)
console.log('err', err.message, 'canc', canc._doc._id);
}
}));
}
}
console.log('FINE - ConvertiDaIntAStr ', mytable.modelName);
});
} catch (err) {
console.error(err);
}
}
async function RimuoviInteri(mytable) {
try {
console.log('INIZIO - RimuoviInteri ', mytable.modelName);
const arr = await mytable.find({ '_id': { $lte: 10000 } })
console.log(' search interi...', arr.length);
const ris = await mytable.deleteMany({ '_id': { $lte: 10000 } })
console.log('FINE - RimuoviInteri ', mytable.modelName, ris);
} catch (err) {
console.error(err);
}
}
async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
let ris = await User.DbOp(idapp, mydata);
@@ -1336,7 +1531,7 @@ async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
for (const mycirc of allcirc) {
// Il Conto Comunitario prende il nome del circuito !
await Account.createAccount(idapp, '', mycirc.name, '', mycirc.path);
await Account.createAccount(idapp, '', mycirc.name, true, '', mycirc.path);
}
@@ -1349,6 +1544,9 @@ async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
} else if (mydata.dbop === 'noCircuit') {
await User.findOneAndUpdate({ _id: mydata._id },
{ $set: { 'profile.noCircuit': mydata.value } });
} else if (mydata.dbop === 'noCircIta') {
await User.findOneAndUpdate({ _id: mydata._id },
{ $set: { 'profile.noCircIta': mydata.value } });
} else if (mydata.dbop === 'noFoto') {
await User.findOneAndUpdate({ _id: mydata._id },
{ $set: { 'profile.noFoto': mydata.value } });
@@ -1436,4 +1634,5 @@ router.post('/mgt', authenticate, async (req, res) => {
});
module.exports = router;

View File

@@ -27,6 +27,8 @@ const shared_consts = require('./tools/shared_nodejs');
const {User} = require('./models/user');
const { MsgTemplate } = require('./models/msg_template');
const transport_preview = nodemailer.createTransport({
jsonTransport: true,
});
@@ -168,6 +170,9 @@ module.exports = {
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
// ++ estrai l'html da mettere sulla email:
// const msghtml = await MsgTemplate.getMsgByLang(idapp, user, shared_consts.TypeMsgTemplate.MSG_BENV_REGISTRATO, user.lang);
let mylocalsconf = {
idapp,
dataemail: await this.getdataemail(idapp),
@@ -195,7 +200,7 @@ module.exports = {
let aportador = mylocalsconf.aportador_solidario ? ' (da ' + mylocalsconf.aportador_solidario + ')' : '';
const numutenti = await User.getNumUsers(mylocalsconf.idapp);
tools.sendNotifToAdmin('++ [' + numutenti + '] ' + nometot + aportador);
tools.sendNotifToAdmin(mylocalsconf.idapp, true, '++Reg [' + numutenti + '] ' + nometot + aportador);
}
// if (tools.isManagAndAdminDifferent(idapp)) {
@@ -227,7 +232,7 @@ module.exports = {
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_CONACREIS, mylocalsconf, 'MSG_ISCRITTO_CONACREIS');
tools.sendNotifToAdmin('Iscrizione Conacreis : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
tools.sendNotifToAdmin(idapp, true, 'Iscrizione Conacreis : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/iscrizione_conacreis/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
@@ -260,7 +265,7 @@ module.exports = {
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_ARCADEI, mylocalsconf, 'MSG_ISCRITTO_ARCADEI');
tools.sendNotifToAdmin('Iscrizione Arcadei : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
tools.sendNotifToAdmin(idapp, true, 'Iscrizione Arcadei : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
if (tools.isManagAndAdminDifferent(idapp)) {
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
@@ -299,6 +304,7 @@ module.exports = {
locale: lang,
nomeapp: tools.getNomeAppByIdApp(idapp),
emailto: emailto,
msgbooking: '',
participants: '',
participantsLunch: '',
participantsDinner: '',
@@ -347,6 +353,10 @@ module.exports = {
msgtelegram += '\n';
if (recbooking.msgbooking) {
mylocalsconf.msgbooking = 'Messaggio: ' + recbooking.msgbooking.toString()
msgtelegram += mylocalsconf.msgbooking + '\n';
}
if (recbooking.numpeople > 0) {
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
msgtelegram += mylocalsconf.participants + '\n';

View File

@@ -112,6 +112,7 @@ myLoad().then(ris => {
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');
@@ -177,6 +178,7 @@ myLoad().then(ris => {
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);

File diff suppressed because it is too large Load Diff

View File

@@ -132,6 +132,7 @@ const textlang = {
'CREATO_NUOVO_GRUPPO': '✅ Hai appena creato un nuovo Gruppo chiamato %s',
'ACCETTATO_NOTIFICA_ADMINS': '✅ l\'utente %s è stato accettato a far parte del Gruppo %s (da parte di %s)',
'GROUP_REQUEST': 'Richiesta di entrare nel Gruppo %s da parte di %s',
"CLICCA_QUI": "CLICCA QUI",
},
si: {},
es: {
@@ -416,7 +417,7 @@ module.exports = {
AYNI: '7',
CNM: '10',
RISO: '13',
ARCADEI: '15',
FIOREDELLAVITA: '15',
HELP_CHAT: '',
TYPECONF_ZOOM: 'zoom',
@@ -678,7 +679,9 @@ module.exports = {
return [
'idapp',
'userId',
'username',
'id_bookedevent',
'tableType',
'numpeople',
'numpeopleLunch',
'numpeopleDinner',
@@ -883,7 +886,7 @@ module.exports = {
};
},
sendNotificationByUsername: async function (idapp, username, cmd, telegram, usernameOrig) {
sendNotificationByUsername: async function (idapp, username, cmd, telegram, usernameOrig, recObjCreator) {
var { User } = require('../models/user');
const { SendNotif } = require('../models/sendnotif');
@@ -904,6 +907,7 @@ module.exports = {
let openUrl = '/';
let tag = '';
let actions = [];
let domanda = '';
if (cmd) {
if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), usernameOrig);
@@ -919,22 +923,12 @@ module.exports = {
}
} else if (cmd === shared_consts.FRIENDSCMD.SETHANDSHAKE) {
descr = printf(this.get__('RICHIESTA_HANDSHAKE', lang), usernameOrig);
openUrl = '/my/' + usernameOrig;
tag = 'reqhandshake';
const userrecDest = await User.getUserShortDataByUsername(idapp, usernameOrig);
const foundIfAlreadyHandShake = await User.isMyHandShake(idapp, username, usernameOrig);
if (userrecDest) {
sendmynotif = false; // non lo rimandare 2 volte !
if (!foundIfAlreadyHandShake) {
// SEND TELEGRAM NOTIFICATION
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_HANDSHAKE, userrecDest, username, usernameOrig);
}
const foundIfAlready = await User.isMyHandShake(idapp, username, usernameOrig);
if (!foundIfAlready) {
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_HANDSHAKE, userrecDest, username, usernameOrig);
}
}
}
@@ -947,7 +941,7 @@ module.exports = {
const idtelegram = await User.TelegIdByUsername(idapp, username);
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr);
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr + domanda, undefined, undefined, true, keyb);
}
},
@@ -1089,6 +1083,11 @@ module.exports = {
let typeid = 0;
let onlysave = false;
let numuserincircuit = await User.countUsersInCircuit(idapp, circuitname);
const mycircuit = await Circuit.findOne({ name: circuitname }).lean();
if (mycircuit) {
extrarec.fido_scoperto_default = mycircuit.fido_scoperto_default;
extrarec.fido_scoperto_default_grp = mycircuit.fido_scoperto_default_grp;
}
if (cmd) {
if (cmd === shared_consts.CIRCUITCMD.SET) {
@@ -1105,11 +1104,13 @@ module.exports = {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER;
// paramsObj.options = MessageOptions.Notify_OnlyToNotifinApp + MessageOptions.Notify_ByBotTelegram;
const myuserdata = await User.getUserShortDataByUsername(idapp, username_action);
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_CIRCUIT, myuserdata, usernameDest, circuitname,
telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_FIDO, myuserdata, usernameDest, circuitname,
myreccircuit._id, '', extrarec.groupname);
onlysave = false;
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN;
} else if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO;
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN;
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
@@ -1284,13 +1285,13 @@ module.exports = {
let ris = false;
let inviato = false;
let arrris = [];
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ || cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT || cmd ===
shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
groupOrig = extrarec.grouporig
let arrris = [];
let recnotif = null;
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
@@ -1370,6 +1371,19 @@ module.exports = {
}
}
if (inviato) {
if (arrris && arrris.length > 0) {
for (const notif of arrris) {
await SendNotif.updatePendingTransactions(notif);
}
} else {
if (ris) {
await SendNotif.updatePendingTransactions(ris.recnotif);
}
}
}
return { ris: ris.recnotif, inviato };
} catch (e) {
@@ -1433,31 +1447,42 @@ module.exports = {
},
*/
sendNotifToAdmin(title, msg, tag = '') {
const { User } = require('../models/user');
sendNotifToAdmin(idapp, alsotelegram, title, msg, tag = '') {
try {
const { User } = require('../models/user');
// console.log('nomeapp 1: ' , this.getNomeAppByIdApp(1));
// console.log('nomeapp 2: ' , this.getNomeAppByIdApp(2));
const queryadmins = { username: 'paoloar77', idapp };
User.find({ username: 'paoloar77', idapp: '1' }).then(async (arrusers) => {
if (arrusers !== null) {
for (const user of arrusers) {
await this.sendNotificationToUser(user._id, title, msg, '/', '', tag, []).
then(ris => {
if (ris) {
if (idapp === 0)
idapp = '13';
} else {
// already sent the error on calling sendNotificationToUser
}
});
User.find(queryadmins).then(async (arrusers) => {
if (arrusers !== null) {
for (const user of arrusers) {
if (alsotelegram) {
this.sendMsgTelegramToAdmin(idapp, title + ' ' + msg);
}
await this.sendNotificationToUser(user._id, title, msg, '/', '', tag, []).
then(ris => {
if (ris) {
} else {
// already sent the error on calling sendNotificationToUser
}
});
}
}
}
});
});
} catch (e) {
console.error(e);
}
},
checkUserOk(userpassed, userauth, res) {
this.mylog('checkUserOk', userpassed, userauth);
// this.mylog('checkUserOk', userpassed, userauth);
if (String(userpassed) !== String(userauth)) {
// I'm trying to write something not mine!
this.mylog('I\'m trying to write something not mine!: userId = ', userpassed, 'req.user._id', userauth);
@@ -1469,8 +1494,9 @@ module.exports = {
} else {
return {
exit: true,
ret: res.status(404).
send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER }),
ret: false,
// ret: res.status(404).
// send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER }),
};
}
} else {
@@ -1508,6 +1534,74 @@ module.exports = {
return msg;
},
htmlToTelegramText(html) {
try {
const withMarkdown = html
.replace(/<strong>(.*?)<\/strong>/g, '*$1*')
.replace(/<b>(.*?)<\/b>/g, '*$1*')
.replace(/<em>(.*?)<\/em>/g, '_$1_')
.replace(/<u>(.*?)<\/u>/g, '__$1__');
// Remove other HTML tags
const plainText = withMarkdown.replace(/<[^>]*>/g, '');
// Replace HTML entities with their equivalent Markdown or plain text representations
const replacements = [
{ pattern: /&amp;/g, replacement: '&' },
{ pattern: /&lt;/g, replacement: '<' },
{ pattern: /&gt;/g, replacement: '>' },
{ pattern: /&quot;/g, replacement: '"' },
{ pattern: /&#39;/g, replacement: "'" },
];
let telegramText = plainText;
replacements.forEach((replacement) => {
telegramText = telegramText.replace(replacement.pattern, replacement.replacement);
});
return telegramText;
} catch (e) {
console.error(e);
};
},
htmlToTelegramText(html) {
try {
const withMarkdown = html
.replace(/<strong>(.*?)<\/strong>/g, '*$1*')
.replace(/<b>(.*?)<\/b>/g, '*$1*')
.replace(/<em>(.*?)<\/em>/g, '_$1_')
.replace(/<u>(.*?)<\/u>/g, '__$1__');
// Remove other HTML tags
const plainText = withMarkdown.replace(/<[^>]*>/g, '');
// Replace HTML entities with their equivalent Markdown or plain text representations
const replacements = [
{ pattern: /&amp;/g, replacement: '&' },
{ pattern: /&lt;/g, replacement: '<' },
{ pattern: /&gt;/g, replacement: '>' },
{ pattern: /&quot;/g, replacement: '"' },
{ pattern: /&#39;/g, replacement: "'" },
];
let telegramText = plainText;
replacements.forEach((replacement) => {
telegramText = telegramText.replace(replacement.pattern, replacement.replacement);
});
return telegramText;
} catch (e) {
console.error(e);
};
},
convertTexttoHtml(myhtml) {
// let msg = myhtml;
// msg = msg.replace('\n', '<br>');
@@ -1765,6 +1859,16 @@ module.exports = {
return myquery;
},
getNumTabByTable(table) {
const myrec = shared_consts.MYTABS.find((rec) => rec.table === table)
return myrec ? myrec.id : -1
},
getTableByNumTab(numtab) {
const myrec = shared_consts.MYTABS.find((rec) => rec.id === numtab)
return myrec ? myrec.table : ''
},
getGroupnameLookupPipeLine(params, proj) {
let myquery = [
@@ -1796,7 +1900,50 @@ module.exports = {
return myquery;
},
getLookup: function (params, num, pass_proj) {
getLookupStandardPipeline: function (params, num) {
const query = [];
if (!params)
return;
query.push(
{
$lookup: {
from: params.lk_tab,
let: { searchId: { $toObjectId: "$" + params.lk_LF } },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ["$" + params.lk_FF, "$$searchId"] },
],
},
},
},
{
$project: params.lk_proj
},
],
as: params.lk_as + num,
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
'$' + params.lk_as + num, 0],
}, '$$ROOT'],
},
},
}
)
return query;
},
getLookup: function (params, num, pass_proj, proj_add) {
const query = [];
if (!params)
@@ -1806,6 +1953,17 @@ module.exports = {
if (params.af_objId_tab) {
const myobj = {};
myobj['myId' + num] = { '$toObjectId': '$' + params.lk_LF };
if (params.lk_tab === 'users') {
myobj.namecomplete = {
$concat: [
{ $toLower: "$name" },
{ $toLower: "$surname" },
{ $toLower: "$username" },
],
};
}
query.push(
{ '$addFields': myobj },
);
@@ -1819,6 +1977,8 @@ module.exports = {
if (!!pass_proj) {
proj = pass_proj;
}
proj = Object.assign({}, proj, proj_add);
query.push(
{
$lookup: {
@@ -1827,18 +1987,33 @@ module.exports = {
foreignField: params.lk_FF, // field in the 'from' collection
as: params.lk_as,
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
'$' + params.lk_as, 0],
}, '$$ROOT'],
});
if (params.unwind) {
query.push({
$unwind: {
path: '$' + params.lk_as,
preserveNullAndEmptyArrays: true,
}
})
}
if (!params.noarray) {
query.push(
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
'$' + params.lk_as, 0],
}, '$$ROOT'],
},
},
},
},
});
}
query.push(
{ $project: proj },
);
}
@@ -1910,8 +2085,205 @@ module.exports = {
return myquery;
},
addNumFavoriteAndBookmarkToQuery(idapp, numtab) {
let query = [];
try {
/*
query =
[
{
$lookup: {
from: "reactions",
let: {
tab: numtab,
id: '$_id',
},
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$idrec', '$$id'] },
{ $eq: ['$tab', numtab] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{
$group: {
_id: "$idrec",
numseen: {
$sum: {
$cond: {
if: { $ifNull: ["$seen", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numfav: {
$sum: {
$cond: {
if: { $ifNull: ["$fav", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
numbook: {
$sum: {
$cond: {
if: { $ifNull: ["$book", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
}
},
},
],
as: 'myreact',
},
},
{
$unwind: {
path: "$myreact",
preserveNullAndEmptyArrays: true,
},
},
];
if (true) {
// RIMUOVI
// query = {};
}
if (true) {
// RIMUOVI
// query = {};
}
if (Object.keys(query).length > 0) {
const numtabbacheca = this.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
if (numtab === numtabbacheca) {
const queryadd = this.getQueryMyBacheca(idapp);
query = [...query, ...queryadd];
}
}
*/
proj = {
numseen: 1,
numfav: 1,
numbook: 1,
numattend: 1,
};
} catch (e) {
console.error(e);
}
return { query, proj };
},
getQueryMyBacheca: function (idapp) {
const arrquery = [{
$lookup: {
from: "bookings",
let: {
id: '$_id',
},
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$id_bookedevent', '$$id'] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{
$project: {
id_bookedevent: 1,
username: 1,
numpeople: 1,
numpeopleLunch: 1,
numpeopleDinner: 1,
infoevent: 1,
msgbooking: 1,
booked: 1,
datebooked: 1,
userId: 1,
}
},
],
as: 'mybookings',
},
},
/**
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$lookup: {
from: "users",
let: {
myid: { $toObjectId: "$mybookings.userId" },
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$_id",
"$$myid",
],
},
{
$eq: [
"$idapp",
"13",
],
},
],
},
},
},
{
$project: { _id: 1, username: 1 },
}
],
as: "myuser",
},
}**/
];
return arrquery;
},
getQueryTable: async function (idapp, params, user) {
const { Search } = require('../models/search');
if (typeof params.startRow !== 'number') {
throw new Error('startRow must be number');
} else if (typeof params.endRow !== 'number') {
@@ -2103,10 +2475,10 @@ module.exports = {
if (params.options) {
if (this.isBitActive(params.options,
shared_consts.OPTIONS_SEARCH_ONLY_FULL_WORDS)) {
}
}
if (params.filterextra) {
if (params.filterextra.length > 0)
query = [...query, ...params.filterextra]
@@ -2124,14 +2496,6 @@ module.exports = {
// console.log('QUERYMATCH', query[0].$match.or);
// console.log('filter', params.filter);
if (params.sortBy) {
// maybe we want to sort by blog title or something
const mysort = { $sort: params.sortBy };
// console.log('sortBy', params.sortBy);
// console.table(mysort);
query.push(mysort);
}
let numrowend = params.endRow - params.startRow;
if (numrowend < 0)
numrowend = 1;
@@ -2352,23 +2716,38 @@ module.exports = {
query.push({ $unwind: params.unwind0 });
}
const q1 = this.getLookup(params.lookup1, 1, proj);
let objadd = { query: [], proj: {} };
let numtab = this.getNumTabByTable(params.table);
const q1 = this.getLookup(params.lookup1, 1, proj, objadd.proj);
if (q1) query = [...query, ...q1];
if (params.unwind1) {
query.push({ $unwind: params.unwind1 });
}
const q2 = this.getLookup(params.lookup2, 2, proj);
if (params.lookupPipeline1) {
const q1p = this.getLookupStandardPipeline(params.lookupPipeline1, 1);
if (q1p) query = [...query, ...q1p];
}
const q2 = this.getLookup(params.lookup2, 2, proj, objadd.proj);
if (q2) query = [...query, ...q2];
const q3 = this.getLookup(params.lookup3, 3, proj);
if (params.lookupPipeline2) {
const q2p = this.getLookupStandardPipeline(params.lookupPipeline2, 2);
if (q2p) query = [...query, ...q2p];
}
const q3 = this.getLookup(params.lookup3, 3, proj, objadd.proj);
if (q3) query = [...query, ...q3];
const q4 = this.getLookup(params.lookup4, 4, proj);
const q4 = this.getLookup(params.lookup4, 4, proj, objadd.proj);
if (q4) query = [...query, ...q4];
const q5 = this.getLookup(params.lookup5, 5, proj);
const q5 = this.getLookup(params.lookup5, 5, proj, objadd.proj);
if (q5) query = [...query, ...q5];
if (params.filtersearch2) {
@@ -2377,6 +2756,7 @@ module.exports = {
}
}
let filteradmin = false;
if (params.filtercustom) {
let condition = {};
@@ -2480,12 +2860,19 @@ module.exports = {
}
}
if (params.filter && params.fieldsearch_last) {
const querytemp = this.getFilterParam(params.filter,
params.fieldsearch_last);
if (querytemp) {
query = [...query, ...querytemp];
}
// Save the search:
if (user._id) {
const mysearch = new Search({ idapp, userId: user._id, text: params.filter });
await mysearch.save();
}
}
if (params.table === 'mygroups' || params.table === 'circuits') {
@@ -2514,12 +2901,27 @@ module.exports = {
// }
}
if (params.options && this.isBitActive(params.options,
shared_consts.OPTIONS_ADD_COUNT_FAVORITE)) {
// objadd = this.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
// if (Object.keys(objadd.query).length > 0)
// query = [...query, ...objadd.query];
}
} else {
// VECCHIA VERSIONE
const q1 = this.getLookup(params, 1);
if (q1) query = [...query, ...q1];
}
if (params.sortBy) {
// maybe we want to sort by blog title or something
const mysort = { $sort: params.sortBy };
// console.log('sortBy', params.sortBy);
// console.table(mysort);
query.push(mysort);
}
query.push(
{
$group: {
@@ -2539,17 +2941,36 @@ module.exports = {
},
);
if (this.testing()) {
console.log('query', query);
}
// console.log('query', query);
return query;
},
startTimeLog(name) {
if (this.testing()) {
console.log('inizio', name);
console.time(name);
}
},
endTimeLog(name) {
if (this.testing()) {
console.log(' ... fine', name);
console.timeEnd(name);
}
},
async executeQueryTable(mythistable, idapp, params, user) {
let query = await this.getQueryTable(idapp, params, user);
try {
// console.log('query', query);
this.startTimeLog('Query 1');
const [ris] = await mythistable.aggregate(query);
if (ris) {
@@ -2564,6 +2985,8 @@ module.exports = {
}
}
this.endTimeLog('Query 1');
// console.table(ris.rows);
// console.log('ROW ', ris.count);
return ({ count: ris.count, rows: ris.rows });
@@ -2625,8 +3048,9 @@ module.exports = {
},
SetBit(myval, bit) {
myval = myval & bit;
return myval;
let myvalout = myval
myvalout |= bit
return myvalout
},
async snooze(ms) {
@@ -2880,6 +3304,19 @@ module.exports = {
}
},
getstrTime(mytimestamp) {
// Create a Date object with your desired date
const date = new Date(mytimestamp); // You can replace this with your specific date
// Get the hour and minute components from the date
const hours = date.getHours();
const minutes = date.getMinutes();
// Format the hour and minute components as HH:MM
const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
return formattedTime
},
getstrDateShort(mydate, lang) {
if (mydate) {
// console.log('getstrDate', mytimestamp)
@@ -3626,7 +4063,7 @@ module.exports = {
const linkuserprof = this.getHostByIdApp(idapp) + '/my/' +
myuser.username;
msg = `<br>👉🏻 <a href="${linkuserprof}">${name}</a> (email: ${myuser.email})`;
msg = `<br>👉🏻 <a href="${linkuserprof}">${name}</a><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')
@@ -3641,7 +4078,7 @@ module.exports = {
namesurnametg = ` [${name_tg} ${surname_tg}]`;;
if (u_tg) {
msg += `<br><br>https://t.me/${u_tg}`;
msg += `<br><br>Apri chat 👉🏻 https://t.me/${u_tg}`;
}
} catch (e) {
console.error('getUserInfoMsg', e);
@@ -3657,8 +4094,7 @@ module.exports = {
try {
const name = myuser.username +
(myuser.name ? ` (${myuser.name} ${myuser.surname})` : '');
const linkuserprof = this.getHostByIdApp(idapp) + '/my/' +
myuser.username;
const linkuserprof = this.getLinkUserProfile(idapp, myuser.username);
let u_tg = myuser.profile && myuser.profile.hasOwnProperty('username_telegram') ? myuser.profile.username_telegram : usernametelegram;
@@ -3739,7 +4175,7 @@ module.exports = {
},
updateQueryStringParameter(uri, key, value) {
if (uri === '')
if (uri === '' || !uri)
return '';
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
@@ -3763,6 +4199,16 @@ module.exports = {
let myhost = this.getHostByIdApp(params.idapp);
if (params.textaddTelegram) {
content = content + '\n' + params.textaddTelegram;
}
if (params.linkaddTelegram) {
if (params.openUrl)
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + params.linkaddTelegram + '</a>';
}
/*if (params.openUrl)
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + i18n.__('OPEN PAGE') + '</a>';
@@ -3776,4 +4222,87 @@ module.exports = {
return `<a href='${link}'>${username}</a>`;
},
firstchars(value, numchars) {
if (!value) {
return ''
}
try {
let mycar = value.substring(0, numchars)
if (value.length > numchars)
mycar += '...'
return mycar
} catch (e) {
return value
}
},
replaceStringAtEnd(inputString, searchString, replacement) {
// Create a regular expression that matches the searchString at the end of the inputString
const regex = new RegExp(searchString + '$');
// Use the replace method with the regular expression to replace the string
const result = inputString.replace(regex, replacement);
return result;
},
getstrDateTimeEvent(myevent) {
let mystr = '';
// is same day?
if (this.getstrDateShort(myevent.dateTimeStart) === this.getstrDateShort(myevent.dateTimeEnd)) {
mystr = i18n.__('DATEDAYONLY', this.getstrDateLong(myevent.dateTimeStart), this.getstrTime(myevent.dateTimeStart),
this.getstrTime(myevent.dateTimeEnd))
} else {
mystr = i18n.__('DATE_2DAYS', this.getstrDateLong(myevent.dateTimeStart), this.getstrTime(myevent.dateTimeStart),
this.getstrDateLong(myevent.dateTimeEnd), this.getstrTime(myevent.dateTimeEnd))
}
return '🗓 ' + mystr;
},
getDoveStrByEvent(myrec) {
let dove = '🏠 ';
if (myrec.mycities && myrec.mycities.length > 0) {
dove += myrec.mycities[0].comune + ' (' + myrec.mycities[0].prov + ')'
}
return dove;
},
async getDescrEstesaStrByEvent(myrec) {
let mystr = '';
mystr = await this.firstchars(this.replaceStringAtEnd(myrec.note, '</div>', ''), 400);
if (mystr)
mystr = ' ' + mystr
return mystr;
},
async getEventForTelegram(myrec, mydescr, userorig) {
try {
let datastr = this.getstrDateTimeEvent(myrec);
let dovestr = this.getDoveStrByEvent(myrec);
let descrestesa = await this.getDescrEstesaStrByEvent(myrec);
let organizedby = myrec.organisedBy;
let contributo = myrec.contribstr;
let newdescr = i18n.__('NEW_EVENT', userorig, datastr, mydescr, dovestr);
let newdescrtelegram = i18n.__('NEW_EVENT_TELEGRAM', datastr, mydescr, dovestr, descrestesa, userorig);
if (organizedby) {
newdescrtelegram += i18n.__('ORGANIZED_BY', organizedby);
}
if (contributo) {
newdescrtelegram += i18n.__('CONTRIB', contributo);
}
newdescrtelegram += i18n.__('ADDED_FROM', userorig);
return { newdescr, newdescrtelegram }
} catch (e) {
console.error('Error', e);
}
},
};

View File

@@ -16,6 +16,7 @@ const { Booking } = require('../models/booking');
const { Operator } = require('../models/operator');
const { Where } = require('../models/where');
const { MyEvent } = require('../models/myevent');
const { Reaction } = require('../models/reaction');
const { Contribtype } = require('../models/contribtype');
const { PaymentType } = require('../models/paymenttype');
const { Discipline } = require('../models/discipline');
@@ -60,6 +61,7 @@ const Cart = require('../models/cart');
const OrdersCart = require('../models/orderscart');
const Storehouse = require('../models/storehouse');
const Department = require('../models/department');
const { Category } = require('../models/category');
const ShareWithUs = require('../models/sharewithus');
const Site = require('../models/site');
const IscrittiConacreis = require('../models/iscrittiConacreis');
@@ -79,6 +81,10 @@ const shared_consts = require('./shared_nodejs');
module.exports = {
isTableReaction(tablename) {
return shared_consts.TABLES_REACTIONS.includes(tablename);
},
getTableByTableName(tablename) {
let mytable = '';
@@ -100,6 +106,8 @@ module.exports = {
mytable = Storehouse;
else if (tablename === 'departments')
mytable = Department;
else if (tablename === 'categorys')
mytable = Category;
else if (tablename === 'sharewithus')
mytable = ShareWithUs;
else if (tablename === 'sites')
@@ -210,6 +218,8 @@ module.exports = {
mytable = Account;
else if (tablename === 'movements')
mytable = Movement;
else if (tablename === 'reactions')
mytable = Reaction;
else if (shared_consts.TablePickup.includes(tablename))
mytable = Pickup;
//else if (shared_consts.TableCities.includes(tablename))
@@ -227,6 +237,8 @@ module.exports = {
const sendemail = require('../sendemail');
const { User } = require('../models/user');
/// ... rivedere il crea gruppo... notifiche...
try {
if (!recnotif.typesend) {
@@ -248,7 +260,10 @@ module.exports = {
usernameDest: recnotif.usernameDest ? recnotif.usernameDest : recnotif.dest,
tag: recnotif.tag ? recnotif.tag : '',
actions: recnotif.actions ? recnotif.actions : [],
id: recnotif._id
id: recnotif._id,
textaddTelegram: recnotif.textaddTelegram ? recnotif.textaddTelegram : '',
textcontent_Telegram: recnotif.textcontent_Telegram ? recnotif.textcontent_Telegram : '',
linkaddTelegram: recnotif.linkaddTelegram ? recnotif.linkaddTelegram : '',
};
if (tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByPushNotification) && this.checkifSendPushNotification) {
@@ -285,7 +300,9 @@ module.exports = {
SendMsgToParam: async function (idapp, params) {
try {
console.log('SendMsgToParam', params.typesend);
// console.log('SendMsgToParam', params.typesend, params.typemsg);
const { User } = require('../models/user');
let textsent = '';
@@ -365,6 +382,7 @@ module.exports = {
{
username: 1,
'profile.teleg_id': 1,
'profile.notifs': 1,
},
).lean();
@@ -372,49 +390,66 @@ module.exports = {
for (const user of arrusers) {
const mytitle = await tools.convertSpecialTags(user, params.title);
const mycontent = await tools.convertSpecialTags(user, params.content);
const mycontent = await tools.convertSpecialTags(user, params.textcontent_Telegram ? params.textcontent_Telegram : params.content);
let usernotifprofile = null;
if (user.profile.notifs)
usernotifprofile = user.profile.notifs.find((notif) => notif.dir === params.typenotif);
let risult = null;
if (params.sendreally) {
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
const myparam = { ...params };
risult = await tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag,
myparam.actions, myparam.id).
then(ris => {
}).
catch(e => {
console.error(e.message);
});
let sendmsg = false;
if (params.typenotif === shared_consts.TypeNotifs.TYPEDIR_FAVORITE) {
if (!usernotifprofile || (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.TypeNotifs.ID_FAVORITE_ADDED))) {
sendmsg = true;
}
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) {
const telegid = user.profile.teleg_id;
} else {
sendmsg = true;
}
text = tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM);
if (telegid > 0) {
risult = await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, text);
await tools.snooze(50);
if (sendmsg) {
if (params.sendreally) {
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
const myparam = { ...params };
risult = await tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag,
myparam.actions, myparam.id).
then(ris => {
textsent = risult.text;
}).
catch(e => {
console.error(e.message);
});
}
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) {
const telegid = user.profile.teleg_id;
text = tools.getContentNotifByParams(params, mycontent, shared_consts.TypeSend.TELEGRAM);
if (telegid > 0) {
risult = await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, text);
await tools.snooze(25);
textsent = risult.text;
}
}
}
}
numrec++;
if (params.sendreally && risult) {
nummsgsent++;
}
numrec++;
if (params.sendreally && risult) {
nummsgsent++;
}
if (nummsgsent > 0 && (nummsgsent % 100) === 0) {
console.log('Inviati ', nummsgsent, 'messaggi...');
if (nummsgsent > 0 && (nummsgsent % 100) === 0) {
console.log('Inviati ', nummsgsent, 'messaggi...');
}
}
}
}
if (nummsgsent > 0) {
console.log('FINE Invio Messaggi ! Inviati Totali: ', nummsgsent, 'su', numrec);
if (nummsgsent != numrec && (numrec !== 1))
console.log('FINE Invio Messaggi ! Inviati Totali: ', nummsgsent, 'su', numrec);
}
return {
@@ -535,69 +570,167 @@ module.exports = {
}
},
ReplaceCircuitName: async function (idapp, search_circuitname, replace_circuitname) {
const { SendNotif } = require('../models/sendnotif');
getNumFavoriteByIdObj: async function (idapp, numtab, id) {
if (!search_circuitname || !replace_circuitname) {
return false;
}
const { Reaction } = require('../models/reaction');
let query = [
{
$match: {
idapp,
idrec: id,
},
},
{
$group:
{
_id: null,
count: {
$sum: {
$cond: {
if: { $ifNull: ["$fav", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
}
},
{ $project: { _id: 0 } }
];
try {
let ris = null;
console.log('ReplaceCircuitName = ', search_circuitname, replace_circuitname);
const [result] = await Reaction.aggregate(query);
ris = await Circuit.findOneAndUpdate({ idapp, name: search_circuitname }, { $set: { name: replace_circuitname } });
console.log('Circuit result = ', ris);
if (ris) {
ris = await User.updateMany({ idapp, 'profile.mycircuits.circuitname': search_circuitname },
{
$set:
{ 'profile.mycircuits.$.circuitname': replace_circuitname }
});
ris = await MyGroup.updateMany({ idapp, 'mycircuits.circuitname': search_circuitname },
{
$set:
{ 'mycircuits.$.circuitname': replace_circuitname }
});
ris = await User.updateMany({ idapp, 'profile.last_circuitpath': search_circuitname },
{
$set:
{ 'profile.last_circuitpath': replace_circuitname }
});
ris = await SendNotif.updateMany({ idapp, 'extrarec.circuitname': search_circuitname },
{
$set:
{ 'extrarec.circuitname': replace_circuitname }
});
ris = await SendNotif.updateMany({ idapp, 'extrarec.name': search_circuitname },
{
$set:
{ 'extrarec.name': replace_circuitname }
});
ris = await SendNotif.updateMany({ idapp, 'extrafield': search_circuitname },
{
$set:
{ 'extrafield': replace_circuitname }
});
console.log(' ... done ' + replace_circuitname);
return true;
}
} catch (e) {
console.error(e);
return false;
return result ? result.count : 0;
} catch (err) {
return 0;
}
return 0;
},
getNumBookByIdObj: async function (idapp, numtab, id) {
const { Reaction } = require('../models/reaction');
let query = [
{
$match: {
idapp,
idrec: id,
},
},
{
$group:
{
_id: null,
count: {
$sum: {
$cond: {
if: { $ifNull: ["$book", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
}
},
}
},
{ $project: { _id: 0 } }
];
try {
const [result] = await Reaction.aggregate(query);
return result ? result.count : 0;
} catch (err) {
return 0;
}
return 0;
},
getNumAttendByIdObj: async function (idapp, numtab, id) {
const { Reaction } = require('../models/reaction');
let query = [
{
$match: {
idapp,
idrec: id,
},
},
{
$group:
{
_id: null,
count: {
$sum: {
$cond: {
if: { $ifNull: ["$attent", false] }, // Check if the field exists and is not null
then: 1, // Increment count by 1 if the field exists
else: 0, // Otherwise, keep the count unchanged
}
},
/*$sum:
{
$reduce: {
input: "$profile.attend",
initialValue: 0,
in: {
$add: ["$$value", "$$this.num"]
}
}
}*/
},
}
},
{ $project: { _id: 0 } }
];
try {
const [result] = await Reaction.aggregate(query);
return result ? result.count : 0;
} catch (err) {
return 0;
}
},
getUserCreatorByNumTabAndId: async function (idapp, id, numtab) {
try {
const table = tools.getTableByNumTab(numtab);
const mytable = this.getTableByTableName(table);
const { User } = require('../models/user');
if (mytable) {
const rec = await mytable.findOne({ _id: id, idapp }, { username: 1, lang: 1, userId: 1, descr: 1 });
if (rec) {
const recuser = await User.getUserById(idapp, rec.userId);
let numattend = await this.getNumAttendByIdObj(idapp, numtab, id);
let numfav = await this.getNumFavoriteByIdObj(idapp, numtab, id);
let numbook = await this.getNumBookByIdObj(idapp, numtab, id);
let exist = false;
if (table === shared_consts.TABLES_MYBACHECAS)
exist = numattend > 1;
else
exist = numfav > 1;
if (recuser)
return { userId: rec.userId, username: recuser.username, descr: rec.descr, id: rec._id, table, exist, numfav, numattend, numbook };
}
}
} catch (e) {
console.error('Err:', e);
}
return null;
},

View File

@@ -6,6 +6,7 @@ module.exports = Object.freeze({
RIS_CODE_EMAIL_ALREADY_VERIFIED: -5,
RIS_CODE_EMAIL_VERIFIED: 1,
RIS_CODE_REC_DUPLICATED_DESCR_CITY_USER: -110,
RIS_CODE_REC_ALREADY_EXIST_SYMBOL: -102,
RIS_CODE_REC_ALREADY_EXIST_CODE: -101,
RIS_CODE_REC_ALREADY_EXIST_NAME: -100,

View File

@@ -3,6 +3,7 @@ module.exports = {
CHECK_READ_GUIDELINES: 1,
CHECK_SEE_VIDEO_PRINCIPI: 2,
},
LIMIT_NOTIF_FOR_USER: 200,
QUERYTYPE_MYGROUP: 1,
QUERYTYPE_REFUSED_USER_GRP: 2,
@@ -46,6 +47,7 @@ module.exports = {
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
OPTIONS_SEARCH_USER_ALL_WORDS: 4,
OPTIONS_ADD_COUNT_FAVORITE: 8,
FRIENDSCMD: {
SETTRUST: 121,
@@ -80,6 +82,7 @@ module.exports = {
CREATE: 1001,
REQ: 2000,
SET: 2001,
SETFIDO: 2005,
REMOVE_FROM_MYLIST: 2144,
REFUSE_REQ: 2145,
CANCEL_REQ: 2146,
@@ -94,6 +97,10 @@ module.exports = {
SENDCOINS_REFUSE_SENT: 2222,
},
USERCMD: {
FAVORITE: 3001,
},
REPORT_FILT_RESP: 1,
REPORT_FILT_ATTIVITA: 2,
@@ -133,8 +140,33 @@ module.exports = {
TABLES_MYHOSPS: 'myhosps',
TABLES_MYGOODS: 'mygoods',
TABLES_MYEVENTS: 'myevents',
TABLES_CIRCUITS: 'circuits',
TABLES_MYGROUPS: 'mygroups',
MYTABS: [{ id: 0, table: 'none' },
{ id: 1, table: 'myskills' },
{ id: 2, table: 'mybachecas' },
{ id: 3, table: 'myhosps' },
{ id: 4, table: 'mygoods' },
{ id: 5, table: 'myevents' }],
CMD_REACTION: {
SET_FAVORITE: 1,
SET_BOOKMARK: 2,
SET_SEEN: 3,
SET_ATTEND: 4,
},
REACTIONS_FIELD:
{
numseen: 1,
numbook: 1,
numfav: 1,
numattend: 1,
},
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
TABLES_REACTIONS: ['mybachecas', 'myhosps', 'myskills', 'mygoods'],
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
@@ -142,6 +174,7 @@ module.exports = {
//++Todo: per abilitare gli utenti ad inserire un Circuito aggiungere 'circuits' alla lista TABLES_PERM_NEWREC
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
TABLES_FAVORITE_BOOKMARK: ['myskills', 'mygoods', 'mybachecas', 'myhosps'],
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'circuits'],
@@ -152,13 +185,13 @@ module.exports = {
TABLES_GROUPS_NOTIFICATION: ['mygroups'],
TABLES_CIRCUITS_NOTIFICATION: ['circuits'],
TABLES_NUM_AS_ID_NUMBER: [ ],
TABLES_NUM_AS_ID_NUMBER: [],
TABLES_ID_STRING: [
'circuits',
'accounts',
'movements',
],
'circuits',
'accounts',
'movements',
],
TABLES_ID_NUMBER: [
'permissions',
@@ -173,16 +206,18 @@ module.exports = {
'subskills',
'cities',
'provinces',
'myskills',
'mybachecas',
'myhosps',
'mygoods',
'mygroups'
// 'myskills',
// 'mybachecas',
// 'myhosps',
// 'mygoods',
// 'mygroups'
],
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
TABLES_CREATEDBY: ['mygroups', 'circuits'],
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits'],
TABLES_FIELDS_DESCR_AND_CITY_AND_USER: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
TABLES_PERM_CHANGE_FOR_USERS: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
TABLES_POPULATE_DATA: [
@@ -193,19 +228,19 @@ module.exports = {
table: 'adtypes',
key: 'descr',
},
{table: 'catgrps', key: 'descr'},
{ table: 'catgrps', key: 'descr' },
{
table: 'contribtypes',
key: 'descr',
},
{table: 'goods', key: 'descr'},
{table: 'levels', key: 'descr'},
{table: 'cities', key: 'comune'},
{table: 'provinces', key: 'descr'},
{table: 'sectorgoods', key: 'descr'},
{table: 'sectors', key: 'descr'},
{table: 'skills', key: 'descr'},
{table: 'statusSkills', key: 'descr'},
{ table: 'goods', key: 'descr' },
{ table: 'levels', key: 'descr' },
{ table: 'cities', key: 'comune' },
{ table: 'provinces', key: 'descr' },
{ table: 'sectorgoods', key: 'descr' },
{ table: 'sectors', key: 'descr' },
{ table: 'skills', key: 'descr' },
{ table: 'statusSkills', key: 'descr' },
],
VISIB_ALL: 0,
@@ -213,6 +248,12 @@ module.exports = {
VISIB_ONLY_MANAGER: 2,
VISIB_ONLY_ADMIN: 4,
CIRCUIT_CFG: {
MULT_FIDO_USER: 2.0,
MULT_FIDO_GROUP: 2.0,
},
Visibility_Group: {
PRIVATE: 1,
HIDDEN: 2,
@@ -224,6 +265,8 @@ module.exports = {
BOTTYPE_LINK: 2,
BOTTYPE_TEXT: 3,
BOTTYPE_MENU: 4,
BOTTYPE_MARKDOWN: 5,
BOTTYPE_BOTTONI_INLINE: 6,
RIS_OK: '👍🏻 OK',
@@ -283,6 +326,38 @@ module.exports = {
OPZ1_2: 2,
},
UNITS_OF_MEASURE: {
NESSUNO: 0,
GRAMMI: 1,
CHILI: 2,
LITRI: 3,
PEZZI: 4,
},
Units_Of_Measure_ListBox: [
{
label: '[Nessuno]',
value: 0,
},
{
label: 'Grammi (g)',
value: 1,
},
{
label: 'Chili (kg)',
value: 2,
},
{
label: 'Litri (l)',
value: 3,
},
{
label: 'Pezzi (p)',
value: 4,
},
],
CallFunz: {
SOSTITUISCI: 345,
AGGIUNGI_NUOVO_IMBARCO: 380,
@@ -296,6 +371,8 @@ module.exports = {
RICHIESTA_AMICIZIA: 15,
RICHIESTA_HANDSHAKE: 16,
RICHIESTA_CIRCUIT: 20,
RICHIESTA_FIDO: 25,
ENTRA_RIS_ITALIA: 30,
},
OrderStatus: {
@@ -321,6 +398,9 @@ module.exports = {
Notif_Reg_Bot_ToManagers: 1,
Notif_Reg_Push_Admin: 2,
Need_Aportador_On_DataReg_To_Verify_Reg: 4,
AskInvitantesulBot: 8,
AskUsernameSulBot: 16,
registerUserWithBot: 32,
},
MsgTeleg: {
@@ -331,6 +411,7 @@ module.exports = {
TypeMsgTemplate: {
MSG_BENVENUTO: 2010,
MS_SHARE_LINK: 2000,
MSG_BENV_REGISTRATO: 2020,
},
TypeSend: {
@@ -344,6 +425,7 @@ module.exports = {
NEW_ADV_MY_GROUPS: 8,
NEW_ADV_MY_RIS_CIRCUIT: 16,
NEW_ADV_SECTOR: 32,
NEW_ADV_YOUR_PROVINCE: 64,
},
StatusNotifs: {
@@ -386,10 +468,13 @@ module.exports = {
TYPEDIR_BACHECA: 1,
ID_BACHECA_NEW_GOOD: 1,
ID_BACHECA_NEW_SERVICE: 2,
ID_BACHECA_NEW_HOSP: 4,
TYPEDIR_EVENTS: 2,
ID_EVENTS_NEW_REC: 1,
ID_EVENTS_REMOVE_REC: 2,
ID_EVENTS_ATTEND: 4,
ID_EVENTS_SEND_MSG: 8,
TYPEDIR_FRIENDS: 3,
ID_FRIENDS_NEW_REC: 1,
@@ -426,6 +511,7 @@ module.exports = {
ID_CIRCUIT_SENDCOINSREQ_SENT: 4096,
ID_CIRCUIT_COINS_ACCEPTED_SENT: 8192,
ID_CIRCUIT_COINS_REFUSED_SENT: 16384,
ID_CIRCUIT_SETFIDO: 32768,
TYPEDIR_BOOKING: 6,
@@ -435,12 +521,15 @@ module.exports = {
TYPEDIR_HANDSHAKE: 10,
ID_HANDSHAKE_ACCEPTED: 2,
TYPEDIR_FAVORITE: 11,
ID_FAVORITE_ADDED: 1,
TYPEDIR_TEST: 444,
ID_TEST_NEW_REC: 1,
},
// Tipi di Notifiche:
// Tipi di Notifiche:
/*
Notif: {
UPDATE_APP: 1,
@@ -492,11 +581,11 @@ module.exports = {
DEFAULT_NOTIFS_USER: [
{
'dir': 1,
'value': 24
'value': 88
},
{
'dir': 2,
'value': 1
'value': 4
},
{
'dir': 3,
@@ -509,7 +598,15 @@ module.exports = {
{
'dir': 5,
'value': 1
}
},
{
'dir': 11,
'value': 1
},
{
'dir': 12,
'value': 1
},
],
CIRCUIT_STATUS: {
@@ -526,4 +623,225 @@ module.exports = {
SCOPERTO_MAX_CONTO_COMUNITARIO: 1000,
},
TABLETYPE: {
DefaultCal: 0,
MyBachecas: 1,
},
getProjectByTable(table, proj_add) {
let proj = {}
if (table === this.TABLES_MYGOODS) {
proj = {
'recGood': 1,
'sectorGood': 1,
'idSectorGood': 1,
'idGood': 1,
'idShipping': 1,
'idStatusGood': 1,
//**ADDFIELD_MYGOOD
}
} else if (table === this.TABLES_MYGROUPS) {
proj = {
groupname: 1,
title: 1,
descr: 1,
img: 1,
visibility: 1,
admins: 1,
idCatGrp: 1,
date_created: 1,
date_updated: 1,
photos: 1,
idCity: 1,
note: 1,
website: 1,
link_telegram: 1,
comune: 1,
mycities: 1,
sector: 1,
recCatGrp: 1,
}
} else if (table === this.TABLES_CIRCUITS) {
proj = {
_id: 1,
groupnameId: 1,
path: 1,
name: 1,
strProv: 1,
subname: 1,
longdescr: 1,
regulation: 1,
numMembers: 1,
totCircolante: 1,
totTransato: 1,
systemUserId: 1,
createdBy: 1,
date_created: 1,
date_updated: 1,
nome_valuta: 1,
fido_scoperto_default: 1,
deperimento: 1,
showAlways: 1,
status: 1,
transactionsEnabled: 1,
qta_max_default: 1,
fido_scoperto_default_grp: 1,
qta_max_default_grp: 1,
valuta_per_euro: 1,
symbol: 1,
idCity: 1,
pub_to_share: 1,
visibility: 1,
color: 1,
abbrev: 1,
data_costituz: 1,
photos: 1,
admins: 1,
req_users: 1,
refused_users: 1,
'mycities': 1,
//**ADDFIELD_CIRCUITS
}
} else if (table === this.TABLES_MYSKILLS) {
proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
myskill: 1,
idStatusSkill: 1,
idContribType: 1,
numLevel: 1,
adType: 1,
photos: 1,
note: 1,
website: 1,
//**ADDFIELD_MYSKILL
}
} else if (table === this.TABLES_MYHOSPS) {
proj = {
visibile: 1,
typeHosp: 1,
numMaxPeopleHosp: 1,
accomodation: 1,
preferences: 1,
idContribType: 1,
photos: 1,
idCity: 1,
note: 1,
website: 1,
link_maplocation: 1,
}
} else if (table === this.TABLES_MYBACHECAS) {
proj = {
recSkill: 1,
sector: 1,
idSector: 1,
idSkill: 1,
// 'idSubSkill': 1,
idStatusSkill: 1,
idContribType: 1,
dateTimeStart: 1,
dateTimeEnd: 1,
website: 1,
organisedBy: 1,
contact_phone: 1,
contact_telegram: 1,
address: 1,
min_partecip: 1,
max_partecip: 1,
contribstr: 1,
link_maplocation: 1,
'mygrp.groupname': 1,
'mygrp.title': 1,
'mygrp.photos': 1,
//**ADDFIELD_MYBACHECAS
}
}
if (proj_add)
proj = Object.assign({}, proj, proj_add);
return proj;
},
getProjectForAll(proj_add, table) {
let proj = {
idContribType: 1,
idCity: 1,
pub_to_share: 1,
adType: 1,
photos: 1,
note: 1,
descr: 1,
date_created: 1,
date_updated: 1,
userId: 1,
username: 1,
name: 1,
surname: 1,
groupname: 1,
lasttimeonline: 1,
comune: 1,
myreact: 1,
mycities: 1,
lang: 1,
verified_by_aportador: 1,
'profile.img': 1,
'profile.mygroups': 1,
'profile.mycircuits': 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
'profile.resid_card': 1,
'profile.username_telegram': 1,
'profile.favorite': 1,
'profile.bookmark': 1,
'profile.attend': 1,
'profile.seen': 1,
reported: 1,
date_report: 1,
username_who_report: 1,
namecomplete: 1,
date_reg: 1,
};
if (proj_add)
proj = Object.assign({}, proj, proj_add);
proj = {...proj, ...this.REACTIONS_FIELD};
if (table) {
let proj_add3 = this.getProjectByTable(table);
proj = Object.assign({}, proj, proj_add3);
}
return proj;
},
getDirectoryByTable(table, barre = false) {
let add = '';
if (barre)
add = '/';
if (table === 'myskills') {
return add + 'myservice' + add
} else if (table === 'mybachecas') {
return add + 'mypage' + add
} else if (table === 'myhosps') {
return add + 'myhosps' + add
} else if (table === 'mygoods') {
return add + 'mygood' + add
} else if (table === 'mygroups') {
return add + 'grp' + add
} else if (table === 'circuits') {
return add + 'circuit' + add
}
return ''
},
};

18368
yarn.lock

File diff suppressed because it is too large Load Diff