Compare commits
39 Commits
master
...
cambio_nom
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d1ad4132f | ||
|
|
e92edcbe78 | ||
|
|
561bab57a8 | ||
|
|
00e9aafd4c | ||
|
|
5993112a8e | ||
|
|
7482b65743 | ||
|
|
e705594294 | ||
|
|
6a4c270c91 | ||
|
|
39cc9b66d6 | ||
|
|
4effda98ec | ||
|
|
84ceed500d | ||
|
|
0076adac76 | ||
|
|
874114942a | ||
|
|
a81300e13d | ||
|
|
81d7d32b85 | ||
|
|
402a9c373e | ||
|
|
6e7eb31d38 | ||
|
|
022ad11747 | ||
|
|
7bf6f91a97 | ||
|
|
2d213b7020 | ||
|
|
aa9d27c8fd | ||
|
|
9a0f0a0cc6 | ||
|
|
5f3ce44a68 | ||
|
|
73aa780733 | ||
|
|
b9e4dbbaec | ||
|
|
8e7b9fb5bd | ||
|
|
f7d05eb856 | ||
|
|
e13fe84709 | ||
|
|
dd51982795 | ||
|
|
a4b42a1fc3 | ||
|
|
331c2e6780 | ||
|
|
399153f477 | ||
|
|
d1135f1151 | ||
|
|
d183a07bad | ||
|
|
f42a39d231 | ||
|
|
dd1c9d573f | ||
|
|
18b827f5f4 | ||
|
|
7a41e6a1d4 | ||
|
|
7e1407cbb1 |
25
.env.test.risosrv
Normal file
25
.env.test.risosrv
Normal file
@@ -0,0 +1,25 @@
|
||||
DATABASE=test_FreePlanet
|
||||
UDB=paofreeplanet
|
||||
PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
PORT=3001
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=test.freeplanet_server
|
||||
PORT_APP1="0"
|
||||
DOMAIN=mongodb://localhost:27018/
|
||||
SIGNCODE=abc123
|
||||
DEBUG=0
|
||||
LOCALE=0
|
||||
DELAY_SENDEMAIL=1000
|
||||
VAPI_KEY_SUBJECT="mailto:surya@riso.app"
|
||||
PUBLIC_VAPI_KEY="BGXRf1TgcqocqD6J7qnRgCG7AvM2lxAoW7peb7UEzB4SxBb6DxGRdJ0UvD9ewnrB9KrSrh0-aDCODXBm7sZ1DDs"
|
||||
PRIVATE_VAPI_KEY="St9UMzcS76Q9yKG6RInAuYydYjFRliqwHTJY3A5wjO0"
|
||||
GCM_API_KEY="AIzaSyD7w1jztfVV05mX1iyxoI-r1pZWxuxdUK8"
|
||||
PATH_CERT_KEY=key.pem
|
||||
PATH_SERVER_CRT=cert.pem
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"search.useIgnoreFiles": false
|
||||
}
|
||||
16
deploynodejs_on_risosrv_test.sh
Executable file
16
deploynodejs_on_risosrv_test.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./.env.test.risosrv
|
||||
|
||||
echo "Sincronizzazione in corso..."
|
||||
rsync -avz -e 'ssh -p 5522' css root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' docs root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' emails root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' images root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' plugins root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' sass root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' src root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' .env.test.risosrv root@risosrv:/var/www/$SERVERDIR_WEBSITE/.env.test
|
||||
rsync -avz -e 'ssh -p 5522' package.json root@risosrv:/var/www/$SERVERDIR_WEBSITE/package.json
|
||||
|
||||
echo "Sincronizzazione TERMINATA! - SERVER TEST!"
|
||||
@@ -19,3 +19,9 @@ entrando sul bot riso premi su avvia (o start) e segui le istruzioni
|
||||
|
||||
3️⃣ condividi il progetto ai tuoi amici ed aiuta così a far crescere questa rete e crescere insieme 💚 partecipa al cambiamento. riso sei anche tu.
|
||||
se hai bisogno di aiuto chiedi in questa chat: 👉🏻 chat riso help
|
||||
|
||||
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
|
||||
|
||||
7
logtrans.txt
Normal file
7
logtrans.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
Lun 06/02 ORE 23:13: Inviate Monete da paoloar77 a surya1977 1 RISTEST [] [Saldo 1: -50] [Saldo 2: 5]
|
||||
Lun 06/02 ORE 23:15: Inviate Monete da paoloar77 a surya1977 1 RISTEST [causale: ] [Saldo 1: -51 RISTEST] [Saldo 2: 6 RISTEST ]
|
||||
Lun 06/02 ORE 23:17: Inviate Monete da paoloar77 a surya1977 1 RISTEST [causale: ] [Saldo paoloar77: -52 RISTEST] [Saldo surya1977: 7 RISTEST]
|
||||
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]
|
||||
@@ -9,6 +9,7 @@
|
||||
"watch": "gulp watch",
|
||||
"test": "export NODE_ENV=development || SET NODE_ENV=development && mocha src/server/**/*.test.js",
|
||||
"start:prod": "NODE_ENV=production node src/server/server.js",
|
||||
"starttest": "NODE_ENV=test node src/server/server.js",
|
||||
"test-watch": "nodemon --exec 'npm test'"
|
||||
},
|
||||
"engines": {
|
||||
@@ -47,6 +48,7 @@
|
||||
"node-telegram-bot-api": "^0.59.0",
|
||||
"nodemailer": "^6.7.8",
|
||||
"npm-check-updates": "^16.1.0",
|
||||
"pem": "^1.14.6",
|
||||
"preview-email": "^3.0.7",
|
||||
"pug": "^3.0.2",
|
||||
"rate-limiter-flexible": "^2.3.9",
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"search.useIgnoreFiles": true,
|
||||
"search.useParentIgnoreFiles": true
|
||||
"search.useIgnoreFiles": false,
|
||||
"search.useParentIgnoreFiles": false,
|
||||
"files.exclude": {
|
||||
"": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"L'Email è già stata Verificata": "L'Email è già stata Verificata"
|
||||
"L'Email è già stata Verificata": "L'Email è già stata Verificata",
|
||||
"Email Verificata!": "Email Verificada! Cierre esta ventana y regrese a la otra.",
|
||||
"Nuova Registrazione": "Nuevo Registro",
|
||||
"Effettuata una Nuova Registrazione": "Se ha realizado un nuevo registro",
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
|
||||
"✅ %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 !",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
||||
"HANDSHAKE_SET": "<strong>%s</strong> ha comunicato che ti conosce personalmente e ha fiducia in te.",
|
||||
"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)",
|
||||
"GROUPS_EXIT_USER": "❌ l'utente %s è uscito dal Gruppo %s",
|
||||
@@ -34,7 +35,9 @@
|
||||
"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_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",
|
||||
@@ -44,18 +47,34 @@
|
||||
"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>.",
|
||||
"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.",
|
||||
@@ -64,5 +83,8 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,17 @@ const authenticate = (req, res, next) => {
|
||||
|
||||
// console.log('authenticate... ');
|
||||
|
||||
let noaut = false;
|
||||
|
||||
if (req.body.hasOwnProperty('noaut')) {
|
||||
noaut = req.body.noaut;
|
||||
}
|
||||
|
||||
if (noaut) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
const access = 'auth';
|
||||
|
||||
User.findByToken(token, access).then((user) => {
|
||||
|
||||
@@ -33,6 +33,12 @@ const AccountSchema = new Schema({
|
||||
username: {
|
||||
type: String,
|
||||
},
|
||||
groupname: { // For the Groups
|
||||
type: String,
|
||||
},
|
||||
contocom: { // For the Conto Comunitario dei Circuiti
|
||||
type: String,
|
||||
},
|
||||
circuitId: { // ----- REF TO Circuit
|
||||
type: String,
|
||||
},
|
||||
@@ -94,6 +100,9 @@ AccountSchema.pre('save', async function (next) {
|
||||
AccountSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'username', type: tools.FieldType.string },
|
||||
{ field: 'groupname', type: tools.FieldType.string },
|
||||
{ field: 'contocom', type: tools.FieldType.string },
|
||||
];
|
||||
|
||||
};
|
||||
@@ -192,7 +201,7 @@ AccountSchema.pre('save', async function (next) {
|
||||
next();
|
||||
});
|
||||
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist) {
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, groupname = '', contocom = "") {
|
||||
const Account = this;
|
||||
|
||||
try {
|
||||
@@ -203,11 +212,18 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
return false;
|
||||
|
||||
let myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
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) {
|
||||
@@ -218,14 +234,35 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
_id: new ObjectID().toString(),
|
||||
idapp,
|
||||
username,
|
||||
groupname,
|
||||
contocom,
|
||||
circuitId: mycircuit._id,
|
||||
deperibile: false,
|
||||
fidoConcesso: mycircuit.fido_scoperto_default,
|
||||
qta_maxConcessa: mycircuit.qta_max_default,
|
||||
importo_iniziale: 0,
|
||||
saldo: 0,
|
||||
fidoConcesso: 0,
|
||||
qta_maxConcessa: 0,
|
||||
});
|
||||
|
||||
if (contocom) {
|
||||
myaccount.fidoConcesso = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
|
||||
myaccount.qta_maxConcessa = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
|
||||
} else {
|
||||
if (!mycircuit.fido_scoperto_default_grp)
|
||||
mycircuit.fido_scoperto_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP;
|
||||
if (!mycircuit.qta_max_default_grp)
|
||||
mycircuit.qta_max_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP;
|
||||
|
||||
if (groupname) {
|
||||
myaccount.fidoConcesso = mycircuit.fido_scoperto_default_grp;
|
||||
myaccount.qta_maxConcessa = mycircuit.qta_max_default_grp;
|
||||
} else {
|
||||
myaccount.fidoConcesso = mycircuit.fido_scoperto_default;
|
||||
myaccount.qta_maxConcessa = mycircuit.qta_max_default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return await myaccount.save();
|
||||
}
|
||||
|
||||
@@ -239,14 +276,14 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.createAccount = async function (idapp, username, circuitName) {
|
||||
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, groupname = '', contocom = '') {
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
try {
|
||||
mycircuit = await Circuit.findOne({ name: circuitName }, {_id: 1});
|
||||
mycircuit = await Circuit.findOne({ name: circuitName }, { _id: 1 });
|
||||
if (mycircuit) {
|
||||
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true);
|
||||
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, groupname, contocom);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -323,6 +360,141 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: { idapp, groupname },
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'circuitId',
|
||||
foreignField: '_id',
|
||||
as: 'circuit',
|
||||
},
|
||||
},
|
||||
{ $unwind: '$circuit' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'sendnotifs',
|
||||
as: 'notifspending',
|
||||
let: {
|
||||
circuitname: '$circuit.name',
|
||||
groupname: '$groupname',
|
||||
idapp: '$idapp',
|
||||
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
|
||||
typeid: shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ,
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$typedir', '$$typedir'] },
|
||||
{ $eq: ['$typeid', '$$typeid'] },
|
||||
{ $eq: ['$status', 0] },
|
||||
{ $eq: ['$sendergroup', '$$groupname'] },
|
||||
{ $eq: ['$idapp', '$$idapp'] },
|
||||
{ $eq: ['$extrarec.circuitname', '$$circuitname'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return ris;
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||
AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valmax) {
|
||||
const Account = this;
|
||||
|
||||
ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fidoConcesso: valmin,
|
||||
qta_maxConcessa: valmax,
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Comunitari, i seguenti minimi e massimi
|
||||
AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valmax) {
|
||||
const Account = this;
|
||||
|
||||
ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fidoConcesso: valmin,
|
||||
qta_maxConcessa: valmax,
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
|
||||
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, valmin, valmax) {
|
||||
const Account = this;
|
||||
|
||||
ris = await Account.updateMany({ idapp, username: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fidoConcesso: valmin,
|
||||
qta_maxConcessa: valmax,
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.addToPeopleOfMyAccount = async function (idapp, username, circuitId, person_username, perm) {
|
||||
|
||||
return await Account.updateOne({ idapp, username, circuitId },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
people: {
|
||||
username: person_username,
|
||||
perm,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovi dagli Admin del Account
|
||||
AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, circuitId, person_username, perm) {
|
||||
|
||||
return await Circuit.updateOne({ idapp, username, circuitId },
|
||||
{ $pull: { people: { username: { $in: [person_username] } } } });
|
||||
};
|
||||
|
||||
|
||||
const Account = mongoose.model('Account', AccountSchema);
|
||||
|
||||
module.exports = { Account };
|
||||
|
||||
@@ -11,6 +11,9 @@ const { ObjectID } = require('mongodb');
|
||||
const { Movement } = require('../models/movement');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
const { Province } = require('../models/province');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
@@ -40,6 +43,9 @@ const CircuitSchema = new Schema({
|
||||
type: String,
|
||||
unique: true,
|
||||
},
|
||||
link_group: {
|
||||
type: String,
|
||||
},
|
||||
subname: {
|
||||
type: String,
|
||||
},
|
||||
@@ -47,6 +53,10 @@ const CircuitSchema = new Schema({
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
strProv:
|
||||
{
|
||||
type: String,
|
||||
},
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
@@ -106,6 +116,12 @@ const CircuitSchema = new Schema({
|
||||
qta_max_default: {
|
||||
type: Number,
|
||||
},
|
||||
fido_scoperto_default_grp: {
|
||||
type: Number,
|
||||
},
|
||||
qta_max_default_grp: {
|
||||
type: Number,
|
||||
},
|
||||
data_costituz: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -173,6 +189,18 @@ const CircuitSchema = new Schema({
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
req_groups: [
|
||||
{
|
||||
_id: false,
|
||||
groupname: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
refused_groups: [
|
||||
{
|
||||
_id: false,
|
||||
groupname: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -207,15 +235,14 @@ CircuitSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, '');
|
||||
|
||||
return await Circuit.find(myfind, whatToShow, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await Circuit.find(myfind, whatToShow).sort({ status: -1, numMembers: -1, name: 1 });
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'nome_circuito', type: tools.FieldType.string },
|
||||
{ field: 'sotto_nome', type: tools.FieldType.string },
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'subname', type: tools.FieldType.string },
|
||||
{ field: 'path', type: tools.FieldType.string },
|
||||
{ field: 'nome_valuta', type: tools.FieldType.string },
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
];
|
||||
@@ -245,13 +272,17 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
date_updated: 1,
|
||||
nome_valuta: 1,
|
||||
fido_scoperto_default: 1,
|
||||
qta_max_default: 1,
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
deperimento: 1,
|
||||
transactionsEnabled: 1,
|
||||
status: 1,
|
||||
qta_max_default: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
idCity: 1,
|
||||
strProv: 1,
|
||||
link_group: 1,
|
||||
pub_to_share: 1,
|
||||
visibility: 1,
|
||||
color: 1,
|
||||
@@ -261,6 +292,8 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
admins: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
req_groups: 1,
|
||||
refused_groups: 1,
|
||||
'mycities': 1,
|
||||
};
|
||||
|
||||
@@ -304,11 +337,15 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
totCircolante: 1,
|
||||
totTransato: 1,
|
||||
fido_scoperto_default: 1,
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
qta_max_default: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
color: 1,
|
||||
idCity: 1,
|
||||
strProv: 1,
|
||||
link_group: 1,
|
||||
pub_to_share: 1,
|
||||
visibility: 1,
|
||||
abbrev: 1,
|
||||
@@ -320,6 +357,8 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
date_updated: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
req_groups: 1,
|
||||
refused_groups: 1,
|
||||
transactionsEnabled: 1,
|
||||
status: 1,
|
||||
'mycities': 1,
|
||||
@@ -345,14 +384,14 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}).lean();
|
||||
}).sort({ status: -1, numMembers: -1, name: 1 }).lean();
|
||||
|
||||
let listcircuits = await Circuit.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({ status: -1, numMembers: -1, name: 1 }).lean();
|
||||
|
||||
let asked_circuits = await Circuit.find({
|
||||
idapp,
|
||||
@@ -362,7 +401,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({ status: -1 }).lean();
|
||||
|
||||
let refused_circuits = await Circuit.find({
|
||||
idapp,
|
||||
@@ -372,7 +411,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({ status: -1 }).lean();
|
||||
|
||||
return {
|
||||
listcircuits,
|
||||
@@ -430,6 +469,22 @@ CircuitSchema.statics.getCircuitByName = async function (idapp, name) {
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitByProvince = async function (idapp, strProv) {
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
strProv,
|
||||
};
|
||||
|
||||
try {
|
||||
return await Circuit.findOne(myfind);
|
||||
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitById = async function (circuitId) {
|
||||
|
||||
const myfind = {
|
||||
@@ -550,7 +605,8 @@ CircuitSchema.statics.getUsersSingleCircuit = async function (idapp, username, c
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
profile: 1, idapp: 1 /*, 'circuit.name': 1, 'circuit._id': 1*/
|
||||
profile: 1,
|
||||
idapp: 1 /*, 'circuit.name': 1, 'circuit._id': 1*/
|
||||
},
|
||||
|
||||
},
|
||||
@@ -620,8 +676,8 @@ 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);
|
||||
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true);
|
||||
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 circolantePrec = this.getCircolanteSingolaTransaz(accountorigTable, accountdestTable);
|
||||
|
||||
@@ -657,16 +713,30 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
};
|
||||
await Circuit.updateOne({ _id: circuittable }, { $set: paramstoupdate });
|
||||
|
||||
ris.result = true;
|
||||
console.log('Inviate Monete da', usernameOrig, extrarec.dest, myqty, extrarec.causal);
|
||||
|
||||
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
|
||||
|
||||
extrarec.saldoOrig = accountorigTable.saldo;
|
||||
extrarec.saldoDest = accountdestTable.saldo;
|
||||
|
||||
let orig = usernameOrig;
|
||||
if (extrarec.grouporig) {
|
||||
orig = extrarec.grouporig + ' (' + usernameOrig + ')'
|
||||
}
|
||||
if (extrarec.contoComOrig) {
|
||||
orig = extrarec.contoComOrig + ' (' + usernameOrig + ')'
|
||||
}
|
||||
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 + ']';
|
||||
console.log(msg);
|
||||
|
||||
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
|
||||
|
||||
tools.writeTransactionLog(msg);
|
||||
|
||||
tools.sendMsgTelegramToAdmin(idapp, msg);
|
||||
|
||||
} else {
|
||||
console.log('NON Inviate Monete da', usernameOrig, extrarec.dest, myqty, extrarec.causal);
|
||||
// console.log('NON Inviate Monete da', usernameOrig, extrarec.grouporig, extrarec.dest, extrarec.groupdest, myqty, extrarec.causal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,6 +758,13 @@ CircuitSchema.statics.removeReqCircuit = async function (idapp, username, name)
|
||||
{ $pull: { req_users: { username: { $in: [username] } } } });
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta del Gruppo sul Circuito
|
||||
CircuitSchema.statics.removeReqGroupCircuit = async function (idapp, groupname, name) {
|
||||
|
||||
return await Circuit.updateOne({ idapp, name },
|
||||
{ $pull: { req_groups: { groupname: { $in: [groupname] } } } });
|
||||
};
|
||||
|
||||
// Aggiungi agli utenti Rifiutati del Circuito
|
||||
|
||||
CircuitSchema.statics.refuseReqCircuit = async function (idapp, username, name) {
|
||||
@@ -705,6 +782,21 @@ CircuitSchema.statics.refuseReqCircuit = async function (idapp, username, name)
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.refuseReqGroupCircuit = async function (idapp, groupname, name) {
|
||||
|
||||
return await Circuit.updateOne({ idapp, name },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
refused_groups: {
|
||||
groupname,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.updateData = async function (idapp, circuitname) {
|
||||
|
||||
try {
|
||||
@@ -747,6 +839,186 @@ CircuitSchema.statics.setDeperimentoOff = async function () {
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getNameByCircuitId = async function (circuitId) {
|
||||
|
||||
let circuit = await Circuit.findOne({ _id: circuitId });
|
||||
if (circuit)
|
||||
return circuit.name;
|
||||
|
||||
return '';
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitByCircuitId = async function (circuitId) {
|
||||
|
||||
return await Circuit.findOne({ _id: circuitId });
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getListAdminsByCircuitPath = async function (idapp, circuitPath) {
|
||||
|
||||
let arr = await Circuit.findOne({
|
||||
idapp,
|
||||
path: circuitPath,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
return arr && arr.admins ? arr.admins : [];
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.setstrProvByIdCityCircuits = async function (idapp) {
|
||||
const { City } = require('../models/city');
|
||||
|
||||
const arrcircuits = await Circuit.find({ idapp }).lean();
|
||||
try {
|
||||
for (const rec of arrcircuits) {
|
||||
let recstrProv = await City.findOne({ _id: rec.idCity[0] });
|
||||
if (recstrProv) {
|
||||
let objProv = {}
|
||||
objProv['strProv'] = recstrProv.prov;
|
||||
await Circuit.updateOne({ _id: rec._id }, { $set: objProv });
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax) {
|
||||
|
||||
ris = await Circuit.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fido_scoperto_default: valmin,
|
||||
qta_max_default: valmax,
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax) {
|
||||
|
||||
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) {
|
||||
|
||||
const globalTables = require('../tools/globalTables');
|
||||
|
||||
const arrcircuit = await Circuit.find({ idapp }).lean();
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('*** Replaced Circuits ', num);
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const useradmin = tools.USER_ADMIN_CIRCUITS;
|
||||
|
||||
let myrec = null;
|
||||
try {
|
||||
const circuit = await this.getCircuitByProvince(idapp, province);
|
||||
|
||||
const nomeprovincia = await Province.getStrProvinceByProv(province);
|
||||
|
||||
if (!circuit && nomeprovincia) {
|
||||
const circ = new Circuit({
|
||||
idapp,
|
||||
name: 'Circuito RIS ' + nomeprovincia,
|
||||
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
|
||||
strProv: province,
|
||||
photos: [],
|
||||
admins: [],
|
||||
color: '#ff5500',
|
||||
deperimento: false,
|
||||
transactionsEnabled: false,
|
||||
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
|
||||
symbol: 'RIS',
|
||||
fido_scoperto_default: 100,
|
||||
qta_max_default: 200,
|
||||
fido_scoperto_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP,
|
||||
qta_max_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP,
|
||||
valuta_per_euro: 1,
|
||||
totTransato: 0,
|
||||
totCircolante: 0,
|
||||
date_created: new Date(),
|
||||
admins: [{ username: useradmin }],
|
||||
});
|
||||
|
||||
myrec = await circ.save();
|
||||
|
||||
if (myrec) {
|
||||
|
||||
// nuovo Circuito:
|
||||
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||
shared_consts.CIRCUITCMD.CREATE, true, useradmin, myrec).then((ris) => {
|
||||
|
||||
});
|
||||
|
||||
// aggiungi il creatore al Circuito stesso
|
||||
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, useradmin, myrec).then((ris) => {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
msg = 'Nuovo Circuito Creato in Automatico: ' + myrec.name + ' (da ' + req.user.username + ')';
|
||||
tools.sendMsgTelegramToAdmin(idapp, msg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error', e);
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||
|
||||
module.exports = { Circuit };
|
||||
|
||||
@@ -114,7 +114,7 @@ ExtraListSchema.statics.getTotInLista = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await ExtraList.count(myfind);
|
||||
return await ExtraList.countDocuments(myfind);
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.getRegDellaLista = async function (idapp) {
|
||||
@@ -122,7 +122,7 @@ ExtraListSchema.statics.getRegDellaLista = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, registered: true };
|
||||
|
||||
return await ExtraList.count(myfind);
|
||||
return await ExtraList.countDocuments(myfind);
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.getLastUser = function (idapp) {
|
||||
|
||||
@@ -138,7 +138,7 @@ GraduatoriaSchema.statics.findByAllRecByUsername = function (idapp, username) {
|
||||
GraduatoriaSchema.statics.getNumDaImbarcare = async function (idapp) {
|
||||
const Graduatoria = this;
|
||||
|
||||
return await Graduatoria.count({ idapp })
|
||||
return await Graduatoria. countDocuments({ idapp })
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ MailingListSchema.statics.getnumSent = async function (idapp, idmailinglist) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.count(myfind);
|
||||
return await MailingList.countDocuments(myfind);
|
||||
};
|
||||
|
||||
MailingListSchema.statics.isOk = async function (idapp, iduser, idmailinglist) {
|
||||
@@ -84,7 +84,7 @@ MailingListSchema.statics.isOk = async function (idapp, iduser, idmailinglist) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.count(myfind) > 0;
|
||||
return await MailingList.countDocuments(myfind) > 0;
|
||||
};
|
||||
|
||||
MailingListSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
@@ -6,8 +6,8 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const {Account} = require('../models/account');
|
||||
const { ObjectID } = require('mongodb');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -17,7 +17,7 @@ mongoose.plugin(schema => {
|
||||
const MovementSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
default: function() {
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
@@ -56,17 +56,17 @@ const MovementSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
MovementSchema.statics.findAllIdApp = async function(idapp) {
|
||||
MovementSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MyMovement = this;
|
||||
|
||||
const myfind = {idapp};
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyMovement.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
|
||||
MovementSchema.pre('save', async function(next) {
|
||||
MovementSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
|
||||
this.transactionDate = new Date();
|
||||
@@ -75,38 +75,38 @@ MovementSchema.pre('save', async function(next) {
|
||||
next();
|
||||
});
|
||||
|
||||
MovementSchema.statics.getFieldsForSearch = function() {
|
||||
MovementSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{field: 'causal', type: tools.FieldType.string},
|
||||
{field: 'amount', type: tools.FieldType.number},
|
||||
{ field: 'causal', type: tools.FieldType.string },
|
||||
{ field: 'amount', type: tools.FieldType.number },
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
MovementSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
MovementSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
MovementSchema.statics.addMov = async function(idapp, accountFromIdTable, accountToIdTable, amount, causal, notifId) {
|
||||
MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accountToIdTable, amount, causal, notifId) {
|
||||
|
||||
try {
|
||||
// Only positive values
|
||||
amount = Math.abs(amount);
|
||||
|
||||
let mymov = await Movement.create(
|
||||
{
|
||||
_id: new ObjectID().toString(),
|
||||
idapp,
|
||||
transactionDate: new Date(),
|
||||
accountFromId: accountFromIdTable._id,
|
||||
accountToId: accountToIdTable._id,
|
||||
amount,
|
||||
causal,
|
||||
residual: 0,
|
||||
notifId,
|
||||
// expiringDate:
|
||||
},
|
||||
{
|
||||
_id: new ObjectID().toString(),
|
||||
idapp,
|
||||
transactionDate: new Date(),
|
||||
accountFromId: accountFromIdTable._id,
|
||||
accountToId: accountToIdTable._id,
|
||||
amount,
|
||||
causal,
|
||||
residual: 0,
|
||||
notifId,
|
||||
// expiringDate:
|
||||
},
|
||||
);
|
||||
|
||||
if (mymov) {
|
||||
@@ -122,13 +122,13 @@ MovementSchema.statics.addMov = async function(idapp, accountFromIdTable, accoun
|
||||
}
|
||||
};
|
||||
|
||||
MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||
MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username, groupname, contocom, circuitId) {
|
||||
|
||||
try {
|
||||
if (!circuitId) {
|
||||
return [];
|
||||
}
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false);
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, groupname, contocom);
|
||||
|
||||
if (myaccount) {
|
||||
|
||||
@@ -137,8 +137,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
$match: {
|
||||
idapp,
|
||||
$or: [
|
||||
{accountFromId: myaccount._id},
|
||||
{accountToId: myaccount._id}],
|
||||
{ accountFromId: myaccount._id },
|
||||
{ accountToId: myaccount._id }],
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -149,30 +149,91 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
as: 'accfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accfrom'},
|
||||
{ $unwind: '$accfrom' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accfrom.username', idapp: '$accfrom.idapp'},
|
||||
let: { username: '$accfrom.username', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$userfrom'},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$userfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accfrom.groupname', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accfrom.contocom', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
@@ -181,66 +242,137 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
as: 'accto',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accto'},
|
||||
{ $unwind: '$accto' },
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'circuits',
|
||||
'localField': 'accfrom.circuitId',
|
||||
'foreignField': '_id',
|
||||
'as': 'circuitfrom',
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'accfrom.circuitId',
|
||||
foreignField: '_id',
|
||||
as: 'circuitfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$unwind': '$circuitfrom',
|
||||
$unwind: '$circuitfrom',
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'circuits',
|
||||
'localField': 'accto.circuitId',
|
||||
'foreignField': '_id',
|
||||
'as': 'circuitto',
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'accto.circuitId',
|
||||
foreignField: '_id',
|
||||
as: 'circuitto',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$unwind': '$circuitto',
|
||||
$unwind: '$circuitto',
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accto.username', idapp: '$accto.idapp'},
|
||||
let: { username: '$accto.username', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userto',
|
||||
},
|
||||
},
|
||||
{$unwind: '$userto'},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$userto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accto.groupname', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accto.contocom', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
},
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupfrom.title': 1,
|
||||
'groupfrom.photos': 1,
|
||||
'groupto.groupname': 1,
|
||||
'groupto.title': 1,
|
||||
'groupto.photos': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomfrom.name': 1,
|
||||
'contocomto.path': 1,
|
||||
'contocomto.name': 1,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
@@ -255,7 +387,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
return [];
|
||||
};
|
||||
|
||||
MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, circuitId) {
|
||||
|
||||
MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp, circuitId) {
|
||||
|
||||
try {
|
||||
if (!circuitId) {
|
||||
@@ -275,24 +408,24 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
as: 'accfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accfrom'},
|
||||
{ $unwind: '$accfrom' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accfrom.username', idapp: '$accfrom.idapp'},
|
||||
let: { username: '$accfrom.username', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userfrom',
|
||||
@@ -304,6 +437,62 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accfrom.groupname', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accfrom.contocom', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
@@ -319,7 +508,7 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {'accto.circuitId': circuitId},
|
||||
$match: { 'accto.circuitId': circuitId },
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -352,20 +541,20 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accto.username', idapp: '$accto.idapp'},
|
||||
let: { username: '$accto.username', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userto',
|
||||
@@ -378,19 +567,85 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accto.groupname', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accto.contocom', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupfrom.title': 1,
|
||||
'groupto.groupname': 1,
|
||||
'groupto.title': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomfrom.name': 1,
|
||||
'contocomfrom.title': 1,
|
||||
'contocomto.path': 1,
|
||||
'contocomto.name': 1,
|
||||
'contocomto.title': 1,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
@@ -404,10 +659,10 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
return [];
|
||||
};
|
||||
|
||||
MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||
MovementSchema.statics.getMovsByCircuitId = async function (idapp, username, circuitId) {
|
||||
const MyMovement = this;
|
||||
|
||||
const myquery = await MyMovement.getQueryMovsByCircuitId(idapp, username, circuitId);
|
||||
const myquery = await MyMovement.getQueryMovsByCircuitId(idapp, username, '', '', circuitId);
|
||||
|
||||
if (myquery && myquery.length > 0) {
|
||||
ris = await MyMovement.aggregate(myquery);
|
||||
@@ -418,11 +673,11 @@ MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circ
|
||||
return [];
|
||||
};
|
||||
|
||||
MovementSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
|
||||
const MyMovement = this;
|
||||
|
||||
try {
|
||||
const rec = await MyMovement.findOne({notifId}, {_id: 1});
|
||||
const rec = await MyMovement.findOne({ notifId }, { _id: 1 });
|
||||
|
||||
return !!rec;
|
||||
|
||||
@@ -436,4 +691,4 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
|
||||
const Movement = mongoose.model('Movement', MovementSchema);
|
||||
|
||||
module.exports = {Movement};
|
||||
module.exports = { Movement };
|
||||
|
||||
@@ -75,8 +75,9 @@ const MyGroupSchema = new Schema({
|
||||
},
|
||||
admins: [
|
||||
{
|
||||
username: {type: String},
|
||||
date: {type: Date},
|
||||
username: { type: String },
|
||||
perm: { type: Number },
|
||||
date: { type: Date },
|
||||
},
|
||||
],
|
||||
blocked: {
|
||||
@@ -97,34 +98,38 @@ const MyGroupSchema = new Schema({
|
||||
req_users: [
|
||||
{
|
||||
_id: false,
|
||||
username: {type: String},
|
||||
date: {type: Date},
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
refused_users: [
|
||||
{
|
||||
_id: false,
|
||||
username: {type: String},
|
||||
date: {type: Date},
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
circuits_list: [
|
||||
mycircuits: [
|
||||
{
|
||||
Num: { type: Number },
|
||||
inscription_date: {type: Date},
|
||||
_id: false,
|
||||
circuitname: { type: String },
|
||||
date: { type: Date },
|
||||
}],
|
||||
lastdate_reqRisGroup: {
|
||||
type: Date,
|
||||
},
|
||||
});
|
||||
|
||||
MyGroupSchema.statics.getFieldsForSearch = function() {
|
||||
return [{field: 'descr', type: tools.FieldType.string}];
|
||||
MyGroupSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'descr', type: tools.FieldType.string }];
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
MyGroupSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
|
||||
const {User} = require('./user');
|
||||
const { User } = require('./user');
|
||||
|
||||
if (params.options) {
|
||||
if (tools.isBitActive(params.options, shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) {
|
||||
@@ -137,9 +142,9 @@ MyGroupSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
MyGroupSchema.pre('save', async function(next) {
|
||||
MyGroupSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MyGroup.findOne().limit(1).sort({_id: -1});
|
||||
const myrec = await MyGroup.findOne().limit(1).sort({ _id: -1 });
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
@@ -156,71 +161,85 @@ MyGroupSchema.pre('save', async function(next) {
|
||||
next();
|
||||
});
|
||||
|
||||
MyGroupSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const myfind = {idapp};
|
||||
MyGroupSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyGroup.find(myfind);
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.findAllGroups = async function(idapp) {
|
||||
MyGroupSchema.statics.findAllGroups = async function (idapp) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, '');
|
||||
|
||||
return await MyGroup.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow);
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta del Gruppo
|
||||
MyGroupSchema.statics.removeReqGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.removeReqGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{$pull: {req_users: {username: {$in: [username]}}}});
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{ $pull: { req_users: { username: { $in: [username] } } } });
|
||||
};
|
||||
|
||||
// Aggiungi agli utenti Rifiutati del Gruppo
|
||||
MyGroupSchema.statics.refuseReqGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.refuseReqGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
$push:
|
||||
{
|
||||
refused_users: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
refused_users: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Aggiungi agli Admin del Gruppo
|
||||
MyGroupSchema.statics.addToAdminOfMyGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.addToAdminOfMyGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
$push:
|
||||
{
|
||||
admins: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
admins: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovi dagli Admin del Gruppo
|
||||
MyGroupSchema.statics.removeAdminOfMyGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.removeAdminOfMyGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{$pull: {admins: {username: {$in: [username]}}}});
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{ $pull: { admins: { username: { $in: [username] } } } });
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
MyGroupSchema.statics.getListAdminsByGroupName = async function (idapp, groupname) {
|
||||
|
||||
let arr = await MyGroup.findOne({
|
||||
idapp,
|
||||
groupname,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
return arr && arr.admins ? arr.admins : [];
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
// FOR ME, PERMIT ALL
|
||||
return {
|
||||
groupname: 1,
|
||||
@@ -242,12 +261,13 @@ MyGroupSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
createdBy: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
circuits_list: 1,
|
||||
mycircuits: 1,
|
||||
lastdate_reqRisGroup: 1,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
MyGroupSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
return {
|
||||
groupname: 1,
|
||||
title: 1,
|
||||
@@ -259,14 +279,15 @@ MyGroupSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
note: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
circuits_list: 1,
|
||||
mycircuits: 1,
|
||||
lastdate_reqRisGroup: 1,
|
||||
};
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function(
|
||||
idapp, groupname, field) {
|
||||
MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function (
|
||||
idapp, groupname, field) {
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const myobj = {};
|
||||
myobj[field + '.' + subfield] = 1;
|
||||
@@ -274,7 +295,7 @@ MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function(
|
||||
let arrrec = await User.findOne({
|
||||
idapp,
|
||||
groupname,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}, myobj).then((ris) => ris ? ris._doc[field] : []);
|
||||
|
||||
if (arrrec.length > 0) {
|
||||
@@ -284,7 +305,7 @@ MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function(
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname) {
|
||||
MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, groupname);
|
||||
|
||||
@@ -294,13 +315,13 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
};
|
||||
|
||||
const query = [
|
||||
{$match: myfind},
|
||||
{ $unwind: '$circuits_list' },
|
||||
{ $match: myfind },
|
||||
{ $unwind: '$mycircuits' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'circuits_list.Num',
|
||||
foreignField: 'Num',
|
||||
localField: 'mycircuits.circuitname',
|
||||
foreignField: 'name',
|
||||
as: 'mycircuits',
|
||||
},
|
||||
},
|
||||
@@ -319,7 +340,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
},
|
||||
},
|
||||
},
|
||||
{$project: whatToShow},
|
||||
{ $project: whatToShow },
|
||||
|
||||
];
|
||||
|
||||
@@ -336,15 +357,15 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.deleteGroup = async function(idapp, usernameOrig, groupname) {
|
||||
MyGroupSchema.statics.deleteGroup = async function (idapp, usernameOrig, groupname) {
|
||||
console.log('Gruppo ' + groupname + ' rimosso da ' + usernameOrig);
|
||||
return await MyGroup.findOneAndRemove({idapp, groupname});
|
||||
return await MyGroup.findOneAndRemove({ idapp, groupname });
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req) {
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function (idapp, username, req) {
|
||||
|
||||
try {
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, username);
|
||||
const whatToShow_Unknown = this.getWhatToShow_Unknown(idapp, username);
|
||||
@@ -353,17 +374,17 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
||||
|
||||
let listUsersGroup = await User.find({
|
||||
idapp,
|
||||
username: {$in: arrUsernameGroups},
|
||||
username: { $in: arrUsernameGroups },
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow);
|
||||
|
||||
let listgroups = await MyGroup.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown);
|
||||
|
||||
/*let listRequestUsersGroup = await User.find({
|
||||
@@ -379,21 +400,21 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
||||
let listSentRequestGroups = await MyGroup.find({
|
||||
idapp,
|
||||
'req_users': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
$elemMatch: { username: { $eq: username } },
|
||||
},
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown);
|
||||
|
||||
let listRefusedGroups = await MyGroup.find({
|
||||
idapp,
|
||||
'refused_users': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
$elemMatch: { username: { $eq: username } },
|
||||
},
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown);
|
||||
|
||||
return {
|
||||
@@ -418,12 +439,12 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
||||
};
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.extractCitiesName = async function(idapp, id) {
|
||||
MyGroupSchema.statics.extractCitiesName = async function (idapp, id) {
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {idapp, _id: id},
|
||||
$match: { idapp, _id: id },
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
@@ -459,13 +480,157 @@ MyGroupSchema.statics.extractCitiesName = async function(idapp, id) {
|
||||
ris = await this.aggregate(aggr1);
|
||||
|
||||
return ris;
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.ifCircuitAlreadyInGroup = async function (idapp, groupname, circuitname) {
|
||||
|
||||
// Controllo se è stato già inserito il circuito sul gruppo
|
||||
return await this.findOne({
|
||||
idapp,
|
||||
groupname,
|
||||
'mycircuits': {
|
||||
$elemMatch: { circuitname: { $eq: circuitname } },
|
||||
},
|
||||
}).lean();
|
||||
};
|
||||
|
||||
// aggiungo il Circuito all'interno del Gruppo
|
||||
MyGroupSchema.statics.addCircuitFromGroup = async function (idapp, groupname, circuitname) {
|
||||
return await this.updateOne({ idapp, groupname },
|
||||
{
|
||||
$push: {
|
||||
'mycircuits': {
|
||||
circuitname,
|
||||
date: new Date(),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovo il Circuito all'interno del Gruppo
|
||||
MyGroupSchema.statics.removeCircuitFromGroup = async function (idapp, groupname, circuitname) {
|
||||
return await this.updateOne({ idapp, groupname },
|
||||
{ $pull: { 'mycircuits': { circuitname: { $in: [circuitname] } } } });
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getQueryReceiveRISGroups = function (idapp, hours) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
'lastdate_reqRisGroup': { $gte: tools.IncDateNow(-(1000 * 60 * 60 * hours)) },
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: "$groupname",
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
{ $sort: { 'lastdate_reqRisGroup': -1 } },
|
||||
{ $limit: 30 },
|
||||
{
|
||||
$lookup: {
|
||||
from: "mygroups",
|
||||
let: {
|
||||
groupname: "$_id",
|
||||
idapp,
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$groupname",
|
||||
"$groupname",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "mygroup",
|
||||
},
|
||||
},
|
||||
{ $unwind: "$mygroup" },
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: ["$mygroup", "$$ROOT"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
groupname: 1,
|
||||
title: 1,
|
||||
descr: 1,
|
||||
visibility: 1,
|
||||
idCatGrp: 1,
|
||||
userId: 1,
|
||||
photos: 1,
|
||||
idCity: 1,
|
||||
website: 1,
|
||||
link_telegram: 1,
|
||||
note: 1,
|
||||
admins: 1,
|
||||
blocked: 1,
|
||||
req_users: 1,
|
||||
createdBy: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
lastdate_reqRisGroup: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
return query;
|
||||
};
|
||||
|
||||
|
||||
MyGroupSchema.statics.getReceiveRISGroups = async function (idapp) {
|
||||
|
||||
return await this.aggregate(this.getQueryReceiveRISGroups(idapp, 8)).then(ris => {
|
||||
return ris;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
|
||||
|
||||
return await this.findOneAndUpdate({
|
||||
idapp, groupname,
|
||||
},
|
||||
{ $set: { 'lastdate_reqRisGroup': new Date() } }, { new: false }).lean().then((record) => {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
||||
|
||||
module.exports = {MyGroup};
|
||||
module.exports = { MyGroup };
|
||||
|
||||
@@ -135,6 +135,7 @@ const MyPageSchema = new Schema({
|
||||
|
||||
MyPageSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'title', type: tools.FieldType.string },
|
||||
{ field: 'path', type: tools.FieldType.string },
|
||||
{ field: 'keywords', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
{ field: 'content', type: tools.FieldType.string }]
|
||||
|
||||
1
src/server/models/prova.htm
Normal file
1
src/server/models/prova.htm
Normal file
@@ -0,0 +1 @@
|
||||
<div class="landing" data-v-313f9fef=""><section data-v-313f9fef=""><div class="row justify-between items-start q-col-gutter-sm" data-v-313f9fef=""><div class="col-12" data-v-313f9fef=""><div class="feature-item" data-v-313f9fef="" style="margin-top: 0px !important;"><div class="text-big" data-v-313f9fef="" style="margin: 0px !important; padding: 2px !important;">Come posso sostenere il progetto <b>Riso.app</b>?</div><p class="feat-descr" data-v-313f9fef=""></p><ul class="mylist" style="padding-left: 20px;"><li>📱<b>Condividendo la APP</b> a tutti coloro che vogliono far parte insieme della crescita e sviluppo di una Nuova Era.</li><li>👥 Aiutando a creare Gruppi Territoriali nella vostra città, impegnandosi a realizzare progetti per il Bene Comune, in onore ai principi Amorevoli e di condivisione.</li><li>🌱 Sostenendo le persone attorno a voi, e rispettando la nostra vera Casa: Madre Natura e Tutti gli Esseri Viventi. ❤️</li><li>👨🏻💻 Con una <b>piccola donazione</b> per le spese dei Server, manutenzione e per i continui sviluppi e miglioramenti.</li></ul>1) Tramite <b><a href="https://paypal.me/paoloarena" target="_blank"><font size="4">Paypal</font></a></b><br>2) Tramite <b><a href="https://www.satispay.com/app/match/link/money-box/S6Y-SVN--62712D42-35B0-4BB9-8511-410C2AB8CD45" target="_blank"><font size="4">Satispay</font></a></b><br>In alternativa scegli tu una forma di scambio (auto-produzioni di cibo) da donare (per info: <a href="https://t.me/surya1977" target="_blank">Surya Paolo</a>)<br><span style="color: red; font-size: 2rem;">❤</span> <br>Grazie Mille per l'Aiuto ed il Supporto<br><p></p></div><div class="feature-item" data-v-313f9fef="" style="margin-top: 0px !important;"><br></div></div></div></section></div>
|
||||
@@ -46,7 +46,14 @@ ProvinceSchema.statics.getRegionByStrProvince = async function(strprovince) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ProvinceSchema.statics.getStrProvinceByProv = async function(prov) {
|
||||
const myrec = await Province.findOne({prov}).lean();
|
||||
if (myrec) {
|
||||
return myrec.descr;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
ProvinceSchema.statics.getFieldsForSearch = function() {
|
||||
return [
|
||||
@@ -91,7 +98,7 @@ ProvinceSchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
ProvinceSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const myfind = {};
|
||||
|
||||
return Province.find(myfind).sort({reg: 1, prov: 1});
|
||||
return Province.find(myfind).sort({descr: 1});
|
||||
};
|
||||
|
||||
const Province = mongoose.model('Province', ProvinceSchema);
|
||||
|
||||
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
@@ -39,10 +39,18 @@ const sendNotifSchema = new Schema({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
title: {
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
descr: {
|
||||
sendergroup: { // mittente
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
destgroup: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
openUrl: {
|
||||
@@ -90,23 +98,26 @@ const sendNotifSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
||||
sendNotifSchema.statics.setNotifAsRead = function (idapp, username, idnotif) {
|
||||
const SendNotif = this;
|
||||
|
||||
if (!username)
|
||||
return null;
|
||||
|
||||
try {
|
||||
|
||||
if (idnotif) {
|
||||
return SendNotif.findOneAndUpdate({
|
||||
$and: [
|
||||
{idapp},
|
||||
{dest: username},
|
||||
{'_id': idnotif},
|
||||
{ idapp },
|
||||
{ dest: username },
|
||||
{ '_id': idnotif },
|
||||
],
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
|
||||
}, {$set: {read: true}}, {new: false}).then((ret) => {
|
||||
}, { $set: { read: true } }, { new: false }).then((ret) => {
|
||||
return !!ret;
|
||||
}).catch((err) => {
|
||||
console.error('err', err);
|
||||
@@ -117,7 +128,7 @@ sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getRecNotif = function(id) {
|
||||
sendNotifSchema.statics.getRecNotif = function (id) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -128,16 +139,19 @@ sendNotifSchema.statics.getRecNotif = function(id) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function(username, lastdataread, idapp) {
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp) {
|
||||
const SendNotif = this;
|
||||
|
||||
if (!lastdataread)
|
||||
lastdataread = 0;
|
||||
|
||||
return SendNotif.find({
|
||||
$and: [
|
||||
{idapp},
|
||||
{'dest': username},
|
||||
{'datenotif': {$gt: new Date(lastdataread)}},
|
||||
{ idapp },
|
||||
{ 'dest': username },
|
||||
{ 'datenotif': { $gt: new Date(lastdataread) } },
|
||||
],
|
||||
}).lean().sort({datenotif: -1}).then(async (arrnotif) => {
|
||||
}).lean().sort({ datenotif: -1 }).then(async (arrnotif) => {
|
||||
// console.log('arrnotif', arrnotif.length);
|
||||
|
||||
return this.compileOtherFields(arrnotif);
|
||||
@@ -148,13 +162,13 @@ sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function(username, la
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, userorig) {
|
||||
|
||||
const numchars = 80;
|
||||
let newdescr = '';
|
||||
let mydescr = '';
|
||||
let myidrec = '';
|
||||
let userorig = recnotif.sender;
|
||||
let sender = recnotif.sender;
|
||||
let tag = '';
|
||||
|
||||
try {
|
||||
@@ -174,18 +188,18 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
tag = 'newservice';
|
||||
}
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC) {
|
||||
newdescr = i18n.__('<strong>%s</strong> asked you for Friendship', userorig, mydescr);
|
||||
newdescr = i18n.__('<strong>%s</strong> asked you for Friendship', sender, mydescr);
|
||||
tag = 'newfriend';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED) {
|
||||
newdescr = i18n.__('<strong>%s</strong> accepted your Friendship', userorig, mydescr);
|
||||
newdescr = i18n.__('<strong>%s</strong> accepted your Friendship', sender, mydescr);
|
||||
tag = 'acceptedfriend';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_ACCEPTED_MY_REQUEST) {
|
||||
newdescr = i18n.__('✅ You have accepted %s\' Friendship request!', userorig, mydescr);
|
||||
newdescr = i18n.__('✅ You have accepted %s\' Friendship request!', sender, mydescr);
|
||||
tag = 'acceptedfriend';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REFUSED) {
|
||||
newdescr = i18n.__('<strong>%s</strong> refused your Friendship', userorig, mydescr);
|
||||
newdescr = i18n.__('<strong>%s</strong> refused your Friendship', sender, mydescr);
|
||||
tag = 'refusedfriend';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_REPORTED) {
|
||||
tag = 'reportuser';
|
||||
@@ -193,173 +207,254 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
newdescr = i18n.__('FRIEND_REPORTED_YOU', recnotif.paramsObj.username_worked);
|
||||
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_worked;
|
||||
} else if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('FRIEND_REPORTED', recnotif.paramsObj.usernameDest, userorig);
|
||||
newdescr = i18n.__('FRIEND_REPORTED', recnotif.paramsObj.usernameDest, sender);
|
||||
recnotif.openUrl = '/my/' + recnotif.paramsObj.usernameDest;
|
||||
} else {
|
||||
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_action;
|
||||
newdescr = i18n.__('FRIEND_REPORTED_TO_ME', recnotif.paramsObj.username_action, recnotif.paramsObj.username_action);
|
||||
}
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED) {
|
||||
tag = 'unblockeduser';
|
||||
if (recnotif.paramsObj.usernameDest === recnotif.paramsObj.username_action) {
|
||||
newdescr = i18n.__('FRIEND_UNBLOCKED_YOU', recnotif.paramsObj.username_worked);
|
||||
recnotif.openUrl = '/my/' + recnotif.paramsObj.username_worked;
|
||||
} else if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('FRIEND_UNBLOCKED', recnotif.paramsObj.usernameDest, userorig);
|
||||
} else {
|
||||
newdescr = i18n.__('FRIEND_UNBLOCKED_TO_ME', recnotif.paramsObj.username_action, recnotif.paramsObj.username_action);
|
||||
}
|
||||
}
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE) {
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED) {
|
||||
newdescr = i18n.__('HANDSHAKE_SET', sender, mydescr);
|
||||
tag = 'acceptedhandshake';
|
||||
}
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
tag = 'group';
|
||||
recnotif.openUrl = '/grp/' + recnotif.paramsObj.groupnameDest;
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_NEW_REC) {
|
||||
newdescr = i18n.__('GROUP_CREATED', userorig, recnotif.paramsObj.groupnameDest);
|
||||
newdescr = i18n.__('GROUP_CREATED', sender, recnotif.paramsObj.groupnameDest);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ACCEPTED) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS', sender, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
} else {
|
||||
newdescr = i18n.__('GROUPS_ACCEPTED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('GROUPS_ACCEPTED', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
}
|
||||
tag = 'addgroup';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED) {
|
||||
if (recnotif.paramsObj.username_action === recnotif.paramsObj.usernameDest && userorig === recnotif.paramsObj.usernameDest) {
|
||||
if (recnotif.paramsObj.username_action === recnotif.paramsObj.usernameDest && sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('GROUPS_EXIT_USER_TO_ME', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
} else if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
} else if (sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('GROUPS_REMOVED_TO_ME', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
} else if (userorig === recnotif.paramsObj.username_action) {
|
||||
newdescr = i18n.__('GROUPS_EXIT_USER', userorig, recnotif.paramsObj.groupnameDest);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
} else if (sender === recnotif.paramsObj.username_action) {
|
||||
newdescr = i18n.__('GROUPS_EXIT_USER', sender, recnotif.paramsObj.groupnameDest);
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
} else {
|
||||
newdescr = i18n.__('GROUPS_REMOVED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('GROUPS_REMOVED', sender, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
}
|
||||
|
||||
tag = 'remgroup';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REFUSED) {
|
||||
newdescr = i18n.__('GROUPS_REFUSED', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('GROUPS_REFUSED', sender, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
tag = 'refgroup';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REQUEST_TO_ENTER) {
|
||||
newdescr = i18n.__('GROUP_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.singleadmin_username);
|
||||
newdescr = i18n.__('GROUP_REQUEST_TO_ENTER', sender, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.singleadmin_username);
|
||||
tag = 'reqgroups';
|
||||
// sendnotifPush = false; // non lo rimandare 2 volte !
|
||||
// telegrambot.askConfirmationUser(idapp, shared_consts.CallFunz.RICHIESTA_GRUPPO, myuser, singleadmin.username, groupname, group._id);
|
||||
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_BLOCK_USER) {
|
||||
newdescr = i18n.__('RICHIESTA_BLOCCO_GRUPPO', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.singleadmin_username);
|
||||
newdescr = i18n.__('RICHIESTA_BLOCCO_GRUPPO', sender, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.singleadmin_username);
|
||||
tag = 'blockgroups';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_DELETE_USER) {
|
||||
newdescr = i18n.__('GRUPPO_ELIMINATO', userorig, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('GRUPPO_ELIMINATO', sender, recnotif.paramsObj.username_action);
|
||||
tag = 'deletegroup';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_ADDED_ADMIN_OFMYGROUP) {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
if (sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('GROUPS_ADDED_ADMIN_GROUP_YOU', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('GROUPS_ADDED_ADMIN_GROUP', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
newdescr = i18n.__('GROUPS_ADDED_ADMIN_GROUP', sender, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
}
|
||||
tag = 'addadmingrp';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_GROUP_REMOVED_ADMIN_OFMYGROUP) {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
if (sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('GROUPS_REMOVED_ADMIN_GROUP_YOU', recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('GROUPS_REMOVED_ADMIN_GROUP', userorig, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
newdescr = i18n.__('GROUPS_REMOVED_ADMIN_GROUP', sender, recnotif.paramsObj.groupnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
}
|
||||
tag = 'removeadmingrp';
|
||||
}
|
||||
} 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 myorig = '';
|
||||
let mydest = '';
|
||||
let destinatario = '';
|
||||
let qty = '';
|
||||
let symbol = '';
|
||||
let username_action = '';
|
||||
let username_mittente = '';
|
||||
try {
|
||||
username_action = recnotif.paramsObj.username_action
|
||||
username_mittente = recnotif.paramsObj.sender ? recnotif.paramsObj.sender : username_action
|
||||
myorig = recnotif.paramsObj.extrarec.grouporig;
|
||||
mydest = recnotif.paramsObj.extrarec.groupdest ? recnotif.paramsObj.extrarec.groupdest : recnotif.paramsObj.extrarec.dest;
|
||||
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 : '';
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (groupOComdest) {
|
||||
destinatario += ' (' + username_mittente + ')'
|
||||
}
|
||||
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC) {
|
||||
newdescr = i18n.__('CIRCUIT_CREATED', userorig, recnotif.paramsObj.circuitnameDest);
|
||||
newdescr = i18n.__('CIRCUIT_CREATED', sender, recnotif.paramsObj.circuitnameDest);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest,
|
||||
username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT', sender, recnotif.paramsObj.circuitnameDest,
|
||||
username_action);
|
||||
}
|
||||
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
} else {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_ACCEPTED', recnotif.paramsObj.username_action, recnotif.paramsObj.circuitnameDest, tools.getHostByIdApp(recnotif.idapp) + recnotif.openUrl);
|
||||
if (sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_ACCEPTED', username_action, recnotif.paramsObj.circuitnameDest, tools.getHostByIdApp(recnotif.idapp) + recnotif.openUrl);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_ACCEPTED_YOU', recnotif.paramsObj.usernameDest, recnotif.paramsObj.circuitnameDest);
|
||||
}
|
||||
}
|
||||
tag = 'addcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED) {
|
||||
if (recnotif.paramsObj.username_action === recnotif.paramsObj.usernameDest && userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_EXIT_USER_TO_ME', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
} else if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED_TO_ME', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
} else if (userorig === recnotif.paramsObj.username_action) {
|
||||
newdescr = i18n.__('CIRCUIT_EXIT_USER', userorig, recnotif.paramsObj.circuitnameDest);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
if (username_action === recnotif.paramsObj.usernameDest && sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_EXIT_USER_TO_ME', recnotif.paramsObj.circuitnameDest, username_action);
|
||||
} else if (sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED_TO_ME', recnotif.paramsObj.circuitnameDest, username_action);
|
||||
} else if (sender === username_action) {
|
||||
newdescr = i18n.__('CIRCUIT_EXIT_USER', sender, recnotif.paramsObj.circuitnameDest);
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED', sender, recnotif.paramsObj.circuitnameDest, username_action);
|
||||
}
|
||||
|
||||
tag = 'remcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('CIRCUIT_REFUSED_TO_ME', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('CIRCUIT_REFUSED_TO_MYGROUP', recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest, username_action);
|
||||
}
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REFUSED', recnotif.paramsObj.username_action, recnotif.paramsObj.circuitnameDest);
|
||||
newdescr = i18n.__('CIRCUIT_REFUSED', username_action, recnotif.paramsObj.circuitnameDest);
|
||||
}
|
||||
tag = 'refcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER) {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP', recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.singleadmin_username);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', sender, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.singleadmin_username);
|
||||
}
|
||||
tag = 'reqcircuits';
|
||||
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
|
||||
newdescr = i18n.__('CIRCUIT_ELIMINATO', userorig, recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('CIRCUIT_ELIMINATO', sender, username_action);
|
||||
tag = 'deletecircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN) {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
if (sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
newdescr = i18n.__('CIRCUIT_ADDED_ADMIN', sender, recnotif.paramsObj.circuitnameDest, username_action);
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
}
|
||||
tag = 'addadmingrp';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN) {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
if (sender === recnotif.paramsObj.usernameDest) {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED_ADMIN_YOU', recnotif.paramsObj.circuitnameDest, username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED_ADMIN', userorig, recnotif.paramsObj.circuitnameDest, recnotif.paramsObj.username_action);
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
newdescr = i18n.__('CIRCUIT_REMOVED_ADMIN', sender, recnotif.paramsObj.circuitnameDest, username_action);
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
}
|
||||
tag = 'removeadmincircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', tools.getAhref(recnotif.paramsObj.username_action, await tools.getLinkUserTelegram(recnotif.idapp, recnotif.paramsObj.username_action)), recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol);
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_GROUP', tools.getAhref(username_action, await tools.getLinkUserTelegram(recnotif.idapp, username_action)), qty,
|
||||
symbol, strtipocontoDest, groupOComdest);
|
||||
} 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);
|
||||
} else if (groupOComorig) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, groupOComorig, username_action, qty, symbol, recnotif.paramsObj.extrarec.dest);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', tools.getAhref(username_action, await tools.getLinkUserTelegram(recnotif.idapp, username_action)), qty,
|
||||
symbol);
|
||||
}
|
||||
|
||||
tag = 'sendcoin';
|
||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_ME', recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.dest);
|
||||
|
||||
if (myorig) {
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP', strtipocontoOrig, myorig, username_action, qty, symbol, strtipocontoDest, groupOComdest);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, myorig, username_action, qty, symbol, mydest);
|
||||
}
|
||||
} else {
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_GROUP', qty, symbol, strtipocontoDest, groupOComdest);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_ME', qty, symbol, mydest);
|
||||
}
|
||||
}
|
||||
|
||||
tag = 'sendcoin';
|
||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest,
|
||||
recnotif.paramsObj.extrarec.symbol
|
||||
);
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', qty, symbol,
|
||||
username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol);
|
||||
|
||||
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);
|
||||
|
||||
} else {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU', qty, symbol, strtipocontoOrig, myorig, 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);
|
||||
} else {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU', qty, symbol, username_action)
|
||||
+ `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, symbol);
|
||||
}
|
||||
}
|
||||
|
||||
tag = 'sendcoin';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.extrarec.dest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig,
|
||||
recnotif.paramsObj.extrarec.symbol);
|
||||
if (!destinatario) {
|
||||
destinatario = username_action
|
||||
}
|
||||
let saldostr = i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig, symbol);
|
||||
if (groupOComorig) {
|
||||
saldostr = i18n.__('SALDO_UPDATE_WHO', groupOComorig, recnotif.paramsObj.extrarec.saldoOrig, symbol);
|
||||
}
|
||||
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_TO_ME', qty, symbol, destinatario)
|
||||
+ `\n` + saldostr;
|
||||
tag = 'sendcoin';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action);
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED', qty, symbol, username_action);
|
||||
tag = 'sendcoin';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.extrarec.dest);
|
||||
tag = 'sendcoin';ac
|
||||
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', qty, symbol, destinatario);
|
||||
tag = 'sendcoin';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,14 +472,14 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.compileOtherFields = async function(arrnotif) {
|
||||
sendNotifSchema.statics.compileOtherFields = async function (arrnotif) {
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
try {
|
||||
// Fill in the image profile of the semyinders !
|
||||
for (const notif of arrnotif) {
|
||||
let myimgprofile = await User.findOne({idapp: notif.idapp, username: notif.sender}, {'profile.img': 1}).lean();
|
||||
let myimgprofile = await User.findOne({ idapp: notif.idapp, username: notif.sender }, { 'profile.img': 1 }).lean();
|
||||
if (myimgprofile && myimgprofile.profile.img)
|
||||
notif.myimgsender = 'upload/profile/' + notif.sender + '/' + myimgprofile.profile.img;
|
||||
}
|
||||
@@ -398,7 +493,7 @@ sendNotifSchema.statics.compileOtherFields = async function(arrnotif) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function(username, idapp, limit) {
|
||||
sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function (username, idapp, limit) {
|
||||
const SendNotif = this;
|
||||
|
||||
return SendNotif.aggregate([
|
||||
@@ -408,9 +503,9 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function(username, idap
|
||||
dest: username,
|
||||
},
|
||||
},
|
||||
{$limit: limit},
|
||||
{ $limit: limit },
|
||||
{
|
||||
$sort: {datenotif: -1},
|
||||
$sort: { datenotif: -1 },
|
||||
},
|
||||
]).then(async (arrnotif) => {
|
||||
return this.compileOtherFields(arrnotif);
|
||||
@@ -421,14 +516,16 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function(username, idap
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.saveAndSendNotif = async function(myrecnotif, req, res, user) {
|
||||
sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res, user) {
|
||||
const SendNotif = this;
|
||||
|
||||
let idapp = req.body.idapp;
|
||||
const check = tools.checkUserOk(myrecnotif.sender, user ? myrecnotif.sender : req.user.username, res);
|
||||
let check = tools.checkUserOk(myrecnotif.sender, user ? myrecnotif.sender : req.user.username, res);
|
||||
if (!check)
|
||||
check = tools.checkUserOk(myrecnotif.sendergroup, user ? myrecnotif.sendergroup : req.user.username, res);
|
||||
if (check.exit) return check.ret;
|
||||
|
||||
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, false);
|
||||
const { myrecout, save } = await SendNotif.updateStatusAndDescr(myrecnotif, false, req.user.username);
|
||||
if (!myrecout)
|
||||
return null;
|
||||
|
||||
@@ -458,13 +555,13 @@ sendNotifSchema.statics.saveAndSendNotif = async function(myrecnotif, req, res,
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysave) {
|
||||
sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlysave, userorig) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
if (!myrecnotif.openUrl) {
|
||||
// If not exist, then I set openUrl and description
|
||||
myrecnotif = await this.getDescrAndLinkByRecNotif(myrecnotif);
|
||||
myrecnotif = await this.getDescrAndLinkByRecNotif(myrecnotif, userorig);
|
||||
}
|
||||
|
||||
let newstatus = 0;
|
||||
@@ -474,6 +571,8 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
|
||||
let sender = myrecnotif.sender;
|
||||
let newdest = myrecnotif.dest;
|
||||
let sendergroup = myrecnotif.sendergroup;
|
||||
let newdestgroup = myrecnotif.destgroup;
|
||||
|
||||
// Controllare se devo modificare un Notif già esistente !
|
||||
if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
||||
@@ -533,23 +632,31 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
|
||||
if (myrecnotif.paramsObj.extrarec.hasOwnProperty('notifIdToUpdate'))
|
||||
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifIdToUpdate;
|
||||
if (myrecnotif.paramsObj.extrarec.hasOwnProperty('idStatusToSent'))
|
||||
idnotiftosearch = myrecnotif.paramsObj.extrarec.idStatusToSent;
|
||||
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_ACCEPTED_SENT;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
|
||||
if (myrecnotif.paramsObj.extrarec.hasOwnProperty('notifIdToUpdate'))
|
||||
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifIdToUpdate;
|
||||
if (myrecnotif.paramsObj.extrarec.hasOwnProperty('idStatusToSent'))
|
||||
idnotiftosearch = myrecnotif.paramsObj.extrarec.idStatusToSent;
|
||||
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_REFUSED_SENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (newstatus) {
|
||||
const fields_to_update = {
|
||||
let fields_to_update = {
|
||||
status: newstatus,
|
||||
read: false,
|
||||
descr: myrecnotif.descr,
|
||||
datenotif: new Date(),
|
||||
sender,
|
||||
dest: newdest,
|
||||
sendergroup,
|
||||
destgroup: newdestgroup,
|
||||
};
|
||||
|
||||
let query = {
|
||||
@@ -566,17 +673,26 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
_id: idnotiftosearch,
|
||||
status: 0,
|
||||
};
|
||||
|
||||
fields_to_update = {
|
||||
status: newstatus,
|
||||
read: false,
|
||||
descr: myrecnotif.descr,
|
||||
datenotif: new Date(),
|
||||
};
|
||||
|
||||
|
||||
// Cerca il record e se lo trova lo aggiorna
|
||||
const myrec = await SendNotif.findOneAndUpdate(query, { $set: fields_to_update }, {
|
||||
new: false,
|
||||
returnNewDocument: true,
|
||||
});
|
||||
|
||||
if (myrec) {
|
||||
return { myrecout: myrec, save: true };
|
||||
}
|
||||
}
|
||||
|
||||
// Cerca il record e se lo trova lo aggiorna
|
||||
const myrec = await SendNotif.findOneAndUpdate(query, {$set: fields_to_update}, {
|
||||
new: true,
|
||||
returnNewDocument: true,
|
||||
});
|
||||
|
||||
if (myrec) {
|
||||
return {myrecout: myrec, save: false};
|
||||
}
|
||||
}
|
||||
|
||||
// myrecnotif._id = new ObjectID();
|
||||
@@ -584,19 +700,19 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
myrecnotif.status = newstatus;
|
||||
}
|
||||
|
||||
return {myrecout: myrecnotif, save: true};
|
||||
return { myrecout: myrecnotif, save: true };
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return {myrecout: null, save: false};
|
||||
return { myrecout: null, save: false };
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getStatus = async function(notifId) {
|
||||
sendNotifSchema.statics.getStatus = async function (notifId) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
return await SendNotif.findOne({_id: notifId}, {status: 1}).lean().then((rec) => rec.status);
|
||||
return await SendNotif.findOne({ _id: notifId }, { status: 1 }).lean().then((rec) => rec.status);
|
||||
|
||||
} catch (e) {
|
||||
return 0;
|
||||
@@ -604,7 +720,7 @@ sendNotifSchema.statics.getStatus = async function(notifId) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
sendNotifSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -612,7 +728,7 @@ sendNotifSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
|
||||
if (status !== null) {
|
||||
return (status === shared_consts.CircuitsNotif.STATUS_COINS_ACCEPTED) ||
|
||||
(status === shared_consts.CircuitsNotif.STATUS_COINS_REFUSED);
|
||||
(status === shared_consts.CircuitsNotif.STATUS_COINS_REFUSED);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -624,11 +740,11 @@ sendNotifSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
||||
sendNotifSchema.statics.saveNotif = async function (myrecnotif, req) {
|
||||
|
||||
const SendNotif = this;
|
||||
|
||||
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, true);
|
||||
const { myrecout, save } = await SendNotif.updateStatusAndDescr(myrecnotif, true, req.user.username);
|
||||
if (!myrecout)
|
||||
return null;
|
||||
|
||||
@@ -644,14 +760,16 @@ sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getDefaultRec = function(req) {
|
||||
sendNotifSchema.statics.getDefaultRec = function (req) {
|
||||
|
||||
return {
|
||||
idapp: req.body.idapp,
|
||||
typedir: '',
|
||||
typeid: '',
|
||||
sender: req.user ? req.user.username : '',
|
||||
sendergroup: '',
|
||||
dest: '',
|
||||
destgroup: '',
|
||||
descr: '',
|
||||
openUrl: '',
|
||||
datenotif: new Date(),
|
||||
@@ -663,7 +781,7 @@ sendNotifSchema.statics.getDefaultRec = function(req) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getExtraParam = function(myrecnotif, paramsObj) {
|
||||
sendNotifSchema.statics.getExtraParam = function (myrecnotif, paramsObj) {
|
||||
let out = myrecnotif;
|
||||
//if (myrecnotif._doc) {
|
||||
//out = myrecnotif._doc
|
||||
@@ -681,7 +799,7 @@ sendNotifSchema.statics.getExtraParam = function(myrecnotif, paramsObj) {
|
||||
return myrecnotif;
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.createNewNotification = async function(req, res, paramsObj, table, rec, typedir, typeid) {
|
||||
sendNotifSchema.statics.createNewNotification = async function (req, res, paramsObj, table, rec, typedir, typeid) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -705,7 +823,7 @@ sendNotifSchema.statics.createNewNotification = async function(req, res, paramsO
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, paramsObj, onlysave, typedir, typeid) {
|
||||
sendNotifSchema.statics.createNewNotifToSingleUser = async function (req, res, paramsObj, onlysave, typedir, typeid) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -723,13 +841,13 @@ sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, pa
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, req, res) {
|
||||
sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass, req, res) {
|
||||
const SendNotif = this;
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
const { City } = require('../models/city');
|
||||
const { Province } = require('../models/province');
|
||||
|
||||
try {
|
||||
|
||||
@@ -737,8 +855,8 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
const userlist = await User.find({
|
||||
idapp: myrecnotifpass.idapp,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
@@ -760,9 +878,9 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
const mytable = globalTables.getTableByTableName(myrecnotifpass.tablerec);
|
||||
|
||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
|
||||
const myrectableorig = await mytable.findOne({_id: myrecnotifpass.idrec}).lean();
|
||||
const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
||||
if (myrectableorig) {
|
||||
for (const city of myrectableorig.idCity) {
|
||||
arrprovinces.push(await City.getProvinceByIdCity(city));
|
||||
@@ -779,7 +897,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
myrecnotifpass.myrectableorig = myrectableorig;
|
||||
}
|
||||
|
||||
myrecnotifpass = await this.getDescrAndLinkByRecNotif(myrecnotifpass);
|
||||
myrecnotifpass = await this.getDescrAndLinkByRecNotif(myrecnotifpass, req.user.username);
|
||||
delete myrecnotifpass._doc['_id'];
|
||||
|
||||
for (const user of userlist) {
|
||||
@@ -790,16 +908,16 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
let send = false;
|
||||
|
||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
|
||||
shared_consts.TABLES_EVENTS_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)) {
|
||||
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)) {
|
||||
user.profile.notif_regions && user.profile.notif_regions.some(r => arrregions.indexOf(r) >= 0)) {
|
||||
send = true;
|
||||
}
|
||||
|
||||
@@ -836,18 +954,18 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, res, onlysave) {
|
||||
sendNotifSchema.statics.sendToSingleUserDest = async function (myrecnotif, req, res, onlysave) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
|
||||
myrecnotif.dest = myrecnotif.paramsObj && myrecnotif.paramsObj.usernameDest ? myrecnotif.paramsObj.usernameDest : '';
|
||||
myrecnotif.username_worked = myrecnotif.paramsObj && myrecnotif.paramsObj.username_worked
|
||||
? myrecnotif.paramsObj.username_worked
|
||||
: myrecnotif.dest;
|
||||
? myrecnotif.paramsObj.username_worked
|
||||
: myrecnotif.dest;
|
||||
|
||||
if (onlysave) {
|
||||
return await SendNotif.saveNotif(myrecnotif);
|
||||
return await SendNotif.saveNotif(myrecnotif, req);
|
||||
} else {
|
||||
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, null);
|
||||
}
|
||||
@@ -859,13 +977,14 @@ sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, r
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getSumPendingTransactions = async function(idapp, username, circuitname) {
|
||||
sendNotifSchema.statics.getSumPendingTransactions = 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,
|
||||
@@ -882,4 +1001,4 @@ sendNotifSchema.statics.getSumPendingTransactions = async function(idapp, userna
|
||||
|
||||
const SendNotif = mongoose.model('SendNotif', sendNotifSchema);
|
||||
|
||||
module.exports = {SendNotif: SendNotif};
|
||||
module.exports = { SendNotif: SendNotif };
|
||||
|
||||
@@ -132,6 +132,8 @@ const SiteSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
videoPromo: { type: String },
|
||||
PDFPromo: { type: String },
|
||||
},
|
||||
confsite: {
|
||||
options: { // ConfSite
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
98
src/server/models/userrequest.js
Executable file
98
src/server/models/userrequest.js
Executable file
@@ -0,0 +1,98 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = 'F';
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
});
|
||||
|
||||
const UserRequestSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
typeReq: {
|
||||
type: Number,
|
||||
},
|
||||
valueRequested: {
|
||||
type: Number,
|
||||
},
|
||||
strRequested: {
|
||||
type: String,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
},
|
||||
groupname: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
createdBy: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
processed: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
username_answered: {
|
||||
type: String,
|
||||
},
|
||||
state_requested: {
|
||||
type: Number,
|
||||
},
|
||||
msgout_answered: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
UserRequestSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'descr', type: tools.FieldType.string }];
|
||||
};
|
||||
|
||||
UserRequestSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
|
||||
const { User } = require('./user');
|
||||
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
UserRequestSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
UserRequestSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await UserRequest.find(myfind);
|
||||
};
|
||||
|
||||
|
||||
const UserRequest = mongoose.model('UserRequest', UserRequestSchema);
|
||||
|
||||
module.exports = { UserRequest };
|
||||
@@ -48,7 +48,7 @@ module.exports = {
|
||||
{_id: 46, idSector: [7], descr: 'Idraulico'},
|
||||
{_id: 47, idSector: [7], descr: 'Giardiniere'},
|
||||
{_id: 48, idSector: [7], descr: 'Canne fumarie e camini e stufe'},
|
||||
{_id: 49, idSector: [7], descr: 'Pannelli solari e pompe calore'},
|
||||
{_id: 49, idSector: [7], descr: 'Pannelli solari'},
|
||||
{_id: 50, idSector: [7], descr: 'Riparazioni varie'},
|
||||
{_id: 51, idSector: [7], descr: 'Tuttofare'},
|
||||
{_id: 52, idSector: [7], descr: 'Traslochi'},
|
||||
@@ -121,5 +121,8 @@ module.exports = {
|
||||
{_id: 126, idSector: [1], descr: 'Terreno'},
|
||||
{_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'},
|
||||
],
|
||||
};
|
||||
|
||||
54
src/server/router/accounts_router.js
Executable file
54
src/server/router/accounts_router.js
Executable file
@@ -0,0 +1,54 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
|
||||
const { User } = require('../models/user');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
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 };
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
router.post('/loadall', authenticate, async (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
|
||||
try {
|
||||
let listaccounts = []
|
||||
if (User.isAdmin(req.user.perm)) {
|
||||
|
||||
listaccounts = await Account.find({ idapp }).lean();
|
||||
|
||||
}
|
||||
|
||||
res.send({ listaccounts });
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error in Accounts', e);
|
||||
return res.status(400).send(e);
|
||||
}
|
||||
|
||||
const ris = null;
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -5,23 +5,24 @@ const tools = require('../tools/general');
|
||||
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
const { User } = require('../models/user');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
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};
|
||||
const myuser = await User.findOne({ idapp, username: admin.username }, { 'profile.img': 1 }).lean();
|
||||
admin.profile = { img: myuser.profile.img };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +36,16 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
|
||||
try {
|
||||
|
||||
const {SendNotif} = require('../models/sendnotif');
|
||||
const {Movement} = require('../models/movement');
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
const { Movement } = require('../models/movement');
|
||||
|
||||
// Check if ìs a Notif to read
|
||||
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
|
||||
const lastdr = req.body['lastdr'] ? req.body['lastdr'] : '';
|
||||
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
||||
|
||||
const whatshow = Circuit.getWhatToShow(idapp, req.user.username);
|
||||
let data = await Circuit.findOne({idapp, path}, whatshow).lean();
|
||||
let data = await Circuit.findOne({ idapp, path }, whatshow).lean();
|
||||
|
||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||
|
||||
@@ -70,7 +72,16 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
data.movements = await Movement.getMovsByCircuitId(idapp, usernameOrig, data._id);
|
||||
}
|
||||
|
||||
res.send({circuit: data, users_in_circuit});
|
||||
if (data) {
|
||||
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, '', data.path);
|
||||
}
|
||||
|
||||
const arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(req.user.username, lastdr, idapp);
|
||||
const useraccounts = await Account.getUserAccounts(idapp, req.user.username);
|
||||
|
||||
await User.setLastCircuitOpened(idapp, req.user.username, path);
|
||||
|
||||
res.send({ circuit: data, users_in_circuit, arrrecnotif, useraccounts });
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error in Circuits', e);
|
||||
|
||||
@@ -5,6 +5,8 @@ const router = express.Router(),
|
||||
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
const sharp = require('sharp');
|
||||
|
||||
const { authenticate, authenticate_noerror } = require(
|
||||
@@ -142,6 +144,8 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, async (req, res) => {
|
||||
const email = body.email.toLowerCase().trim();
|
||||
const codetocheck = body.codetocheck ? body.codetocheck.trim() : '';
|
||||
|
||||
console.log('Request Reset Pwd:', email, ' idapp=', idapp);
|
||||
|
||||
// Check if too many requests
|
||||
if (await User.tooManyReqPassword(idapp, email, true)) {
|
||||
console.log(process.env.LINK_REQUEST_NEWPASSWORD, 'TOO MANY REQUESTS !!! EXIT ', email);
|
||||
@@ -281,7 +285,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
if (req.user && req.user.username) {
|
||||
User.setOnLine(req.user.idapp, req.user.username);
|
||||
}
|
||||
|
||||
|
||||
let consentito = false;
|
||||
|
||||
try {
|
||||
@@ -362,6 +366,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
} else {
|
||||
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined)) {
|
||||
mytablerec._id = new ObjectID();
|
||||
mydata._id = new ObjectID();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,12 +402,31 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
|
||||
if (shared_consts.TABLES_UPDATE_LASTMODIFIED.includes(params.table)) {
|
||||
mytablerec.date_updated = new Date();
|
||||
mydata.date_updated = new Date();
|
||||
}
|
||||
|
||||
// console.log('mydata',mydata);
|
||||
// return await mytablerec.save().
|
||||
// then(async (rec) => {
|
||||
|
||||
return await mytablerec.save().
|
||||
then(async (rec) => {
|
||||
const myPromise = new Promise((resolve, reject) => {
|
||||
resolve(mytablerec._id && mytable.findById(mytablerec._id))
|
||||
});
|
||||
|
||||
return await myPromise
|
||||
.then(async (doupdate) => {
|
||||
if (doupdate)
|
||||
return mytable.updateOne({ _id: mytablerec._id }, mydata, { new: true })
|
||||
else
|
||||
return mytablerec.save()
|
||||
})
|
||||
.then(async (risult) => {
|
||||
let rec = null;
|
||||
if (risult && risult.ok === 1) {
|
||||
rec = await mytable.findById(mytablerec._id).lean();
|
||||
} else {
|
||||
rec = risult;
|
||||
}
|
||||
|
||||
if (shared_consts.TABLES_GETCOMPLETEREC.includes(params.table)) {
|
||||
return await mytablestrutt.getCompleteRecord(rec.idapp, rec._id);
|
||||
@@ -467,7 +491,12 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
return res.send({ rec: myrec, ris });
|
||||
});
|
||||
} else if (params.table === shared_consts.TAB_MYCIRCUITS && isnewrec) {
|
||||
// nuovo Record:
|
||||
// nuovo Circuito:
|
||||
await User.setCircuitCmd(mydata.idapp, req.user.username, myrec.name,
|
||||
shared_consts.CIRCUITCMD.CREATE, true, req.user.username, extrarec).then((ris) => {
|
||||
return res.send({ rec: myrec, ris });
|
||||
});
|
||||
|
||||
// aggiungi il creatore al Circuito stesso
|
||||
return await User.setCircuitCmd(mydata.idapp, req.user.username, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, req.user.username, extrarec).then((ris) => {
|
||||
@@ -558,7 +587,7 @@ router.post('/setsubrec', authenticate, (req, res) => {
|
||||
|
||||
router.post('/gettable', authenticate, (req, res) => {
|
||||
const params = req.body;
|
||||
let idapp = req.user.idapp;
|
||||
let idapp = req.user ? req.user.idapp : params.idapp;
|
||||
const mytable = globalTables.getTableByTableName(params.table);
|
||||
// console.log('mytable', mytable);
|
||||
if (!mytable) {
|
||||
@@ -668,12 +697,49 @@ router.post('/getpage', async (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
const mypath = params.path;
|
||||
|
||||
return await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
|
||||
return res.send({ mypage: ris });
|
||||
let found = await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
|
||||
if (ris)
|
||||
return res.send({ mypage: ris });
|
||||
else
|
||||
return null;
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
res.status(400).send(e);
|
||||
});
|
||||
if (!found) {
|
||||
// trova quelli con il :
|
||||
let regexp = new RegExp(`:`, 'ig')
|
||||
const searchpagesSpec = await MyPage.find({ idapp, path: { $regex: regexp } });
|
||||
|
||||
if (searchpagesSpec) {
|
||||
let arrsubpath = mypath.split('/');
|
||||
for (let i = 0; i < searchpagesSpec.length; i++) {
|
||||
let arrsubstr = searchpagesSpec[i].path.split('/');
|
||||
|
||||
if (arrsubpath.length === arrsubpath.length) {
|
||||
|
||||
let mypathbuild = '';
|
||||
|
||||
for (let j = 0; j < arrsubstr.length; j++) {
|
||||
if (arrsubstr[j].includes(':')) {
|
||||
mypathbuild += arrsubpath[j] + '/';
|
||||
} else {
|
||||
mypathbuild += arrsubstr[j] + '/';
|
||||
}
|
||||
}
|
||||
|
||||
if (mypath + '/' === mypathbuild) {
|
||||
return res.send({ mypage: searchpagesSpec[i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return await MyPage.findOne({ idapp, path: mypath }).then((ris) => {
|
||||
return res.send({ mypage: ris });
|
||||
});
|
||||
}
|
||||
return found;
|
||||
|
||||
});
|
||||
|
||||
@@ -795,6 +861,12 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
|
||||
}
|
||||
|
||||
let precRec = null
|
||||
|
||||
if (mydata.table === 'accounts') {
|
||||
precRec = await mytable.findById(id);
|
||||
}
|
||||
|
||||
return await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }).
|
||||
then(async (rec) => {
|
||||
// tools.mylogshow(' REC TO MODIFY: ', rec);
|
||||
@@ -821,14 +893,38 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
if (mydata.table === 'accounts') {
|
||||
let msg = '';
|
||||
if (rec.circuitId)
|
||||
circuit = await Circuit.getCircuitByCircuitId(rec.circuitId);
|
||||
|
||||
let dest = rec.groupname ? rec.groupname : rec.username;
|
||||
let valprec = 0
|
||||
|
||||
if ('saldo' in fieldsvalue) {
|
||||
msg = 'l\'utente ' + req.user.username + ' ha variato il Saldo di ' + rec.username + ' a ' + fieldsvalue.saldo;
|
||||
valprec = precRec && precRec.saldo ? precRec.saldo : 0
|
||||
msg = i18n.__('SALDO_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.saldo, circuit.symbol);
|
||||
} else if ('fidoConcesso' in fieldsvalue) {
|
||||
valprec = precRec && precRec.fidoConcesso ? precRec.fidoConcesso : 0
|
||||
msg = i18n.__('FIDOCONCESSO_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.fidoConcesso, circuit.symbol);
|
||||
} else if ('qta_maxConcessa' in fieldsvalue) {
|
||||
valprec = precRec && precRec.qta_maxConcessa ? precRec.qta_maxConcessa : 0
|
||||
msg = i18n.__('QTAMAX_VARIATO', circuit.name, req.user.username, dest, valprec, fieldsvalue.qta_maxConcessa, circuit.symbol);
|
||||
}
|
||||
|
||||
if (msg) {
|
||||
telegrambot.sendMsgTelegramToTheManagers(idapp, msg);
|
||||
telegrambot.sendMsgTelegramToTheAdminsOfCircuit(idapp, circuit.path, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mydata.table === 'users') {
|
||||
|
||||
if ('profile.resid_province' in fieldsvalue) {
|
||||
// Controlla se esiste il Circuito di questa provincia, se non esiste lo crea!
|
||||
await Circuit.createCircuitIfNotExist(req, idapp, fieldsvalue['profile.resid_province']);
|
||||
}
|
||||
|
||||
if (camporequisiti) {
|
||||
await User.checkIfSbloccatiRequisiti(idapp, allData, id);
|
||||
}
|
||||
@@ -1310,7 +1406,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);
|
||||
myuserextra = User.addExtraInfo(idapp, req.user._doc, req.user);
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
@@ -1748,6 +1844,7 @@ router.delete('/delfile', authenticate, (req, res) => {
|
||||
deleteFile(req, res, 0);
|
||||
});
|
||||
|
||||
|
||||
function deleteFile(req, res, version) {
|
||||
const relativefile = req.query.filename;
|
||||
const idapp = req.user.idapp;
|
||||
|
||||
@@ -5,23 +5,23 @@ const tools = require('../tools/general');
|
||||
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
const { User } = require('../models/user');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
async function getGroupRecAdminsInfo(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};
|
||||
const myuser = await User.findOne({ idapp, username: admin.username }, { 'profile.img': 1 }).lean();
|
||||
admin.profile = { img: myuser.profile.img };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,33 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
|
||||
try {
|
||||
|
||||
const {SendNotif} = require('../models/sendnotif');
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
// Check if ìs a Notif to read
|
||||
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
|
||||
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
||||
|
||||
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username);
|
||||
let data = await MyGroup.findOne({idapp, groupname}, whatshow).lean();
|
||||
let data = await MyGroup.findOne({ idapp, groupname }, whatshow).lean();
|
||||
|
||||
/*
|
||||
if (data.mycircuits) {
|
||||
for (let i = 0; i < data.mycircuits.length; i++) {
|
||||
const mycirc = await Circuit.findOne({ idapp, name: data.mycircuits[i].circuitname }).lean();
|
||||
data.mycircuits[i] = mycirc;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (data.mycircuits) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
let cities = [];
|
||||
if (data) {
|
||||
@@ -57,16 +76,16 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||
|
||||
const users_in_group = await User.find(
|
||||
{
|
||||
idapp,
|
||||
'profile.mygroups': {
|
||||
$elemMatch: {groupname: {$eq: groupname}},
|
||||
},
|
||||
{
|
||||
idapp,
|
||||
'profile.mygroups': {
|
||||
$elemMatch: { groupname: { $eq: groupname } },
|
||||
},
|
||||
whatshowUsers,
|
||||
},
|
||||
whatshowUsers,
|
||||
).lean();
|
||||
|
||||
res.send({mygroup: data, users_in_group, cities});
|
||||
res.send({ mygroup: data, users_in_group, cities });
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error in MyGroups', e);
|
||||
|
||||
@@ -47,13 +47,6 @@ const newsletter = [
|
||||
listUniqueId: '',
|
||||
mailchimpApiKey: ''
|
||||
},
|
||||
{
|
||||
name: 'MandalaSolidale',
|
||||
mailchimpInstance: '',
|
||||
listUniqueId: '',
|
||||
mailchimpApiKey: ''
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
async function AddMailingList(locale, idapp, user, settomailchimp, sendnews) {
|
||||
|
||||
@@ -7,6 +7,8 @@ const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
|
||||
const { User } = require('../models/user');
|
||||
@@ -50,6 +52,10 @@ router.post('/load', async (req, res) => {
|
||||
lastsonline: await User.getLastOnlineUsers(idapp),
|
||||
lastssharedlink: await User.getLastSharedLink(idapp),
|
||||
diffusorilist: await User.getDiffusoriUsers(idapp),
|
||||
receiveRislist: await User.getReceiveRISUsers(idapp),
|
||||
// receiveRislist: await User.find({idapp}).limit(20),
|
||||
receiveRislistgroup: await MyGroup.getReceiveRISGroups(idapp),
|
||||
strettelist: await User.getBestStretteDiManoUsers(idapp),
|
||||
checkuser: await User.checkUser(idapp, username),
|
||||
// navi_partite: await Nave.getNaviPartite(idapp),
|
||||
// navi_in_partenza: await Nave.getNaviInPartenza(idapp),
|
||||
|
||||
@@ -38,6 +38,8 @@ router.post('/', authenticate, async (req, res) => {
|
||||
subscriptionModel.access = req.body.others.access;
|
||||
subscriptionModel.browser = req.get('User-Agent');
|
||||
|
||||
// console.log('subscriptionModel.browser', subscriptionModel.browser);
|
||||
|
||||
// Find if already exist
|
||||
await Subscription.findOne({
|
||||
userId: subscriptionModel.userId,
|
||||
|
||||
99
src/server/router/userrequest_router.js
Executable file
99
src/server/router/userrequest_router.js
Executable file
@@ -0,0 +1,99 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
|
||||
const { User } = require('../models/user');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
async function getGroupRecAdminsInfo(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 };
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
router.post('/load', authenticate, async (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
const groupname = req.body.groupname;
|
||||
const usernameOrig = req.user.username;
|
||||
|
||||
try {
|
||||
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
// Check if ìs a Notif to read
|
||||
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
|
||||
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
||||
|
||||
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username);
|
||||
let data = await MyGroup.findOne({ idapp, groupname }, whatshow).lean();
|
||||
|
||||
/*
|
||||
if (data.mycircuits) {
|
||||
for (let i = 0; i < data.mycircuits.length; i++) {
|
||||
const mycirc = await Circuit.findOne({ idapp, name: data.mycircuits[i].circuitname }).lean();
|
||||
data.mycircuits[i] = mycirc;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (data.mycircuits) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
let cities = [];
|
||||
if (data) {
|
||||
cities = await MyGroup.extractCitiesName(idapp, data._id);
|
||||
if (cities && cities.length > 0) {
|
||||
cities = cities[0].mycities;
|
||||
}
|
||||
}
|
||||
|
||||
data = await getGroupRecAdminsInfo(idapp, data);
|
||||
|
||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||
|
||||
const users_in_group = await User.find(
|
||||
{
|
||||
idapp,
|
||||
'profile.mygroups': {
|
||||
$elemMatch: { groupname: { $eq: groupname } },
|
||||
},
|
||||
},
|
||||
whatshowUsers,
|
||||
).lean();
|
||||
|
||||
res.send({ mygroup: data, users_in_group, cities });
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error in MyGroups', e);
|
||||
return res.status(400).send(e);
|
||||
}
|
||||
|
||||
const ris = null;
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -159,14 +159,6 @@ module.exports = {
|
||||
transport_preview.sendMail(mailOptions).then(console.log).catch(console.error);
|
||||
}
|
||||
},
|
||||
// getHostByIdApp: function (idapp) {
|
||||
// if (idapp === 1) {
|
||||
// let siteport = (process.env.PORT_APP1 !== "0") ? (':' + process.env.PORT_APP1) : "";
|
||||
// return process.env.URLBASE_APP1 + siteport;
|
||||
// } else {
|
||||
// return ""
|
||||
// }
|
||||
// },
|
||||
|
||||
getlinkReg: function(idapp, idreg) {
|
||||
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINKVERIF_REG + `/?idapp=${idapp}&idlink=${idreg}`;
|
||||
@@ -279,6 +271,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
sendEmail_RequestNewPassword: async function(lang, user, emailto, idapp, tokenforgot, tokenforgot_code) {
|
||||
console.log('sendEmail_RequestNewPassword');
|
||||
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
require('./config/config');
|
||||
require('./config/config');
|
||||
|
||||
// console.log(" lodash");
|
||||
|
||||
console.log(process.versions);
|
||||
|
||||
const _ = require('lodash');
|
||||
// console.log(" cors");
|
||||
const cors = require('cors');
|
||||
@@ -9,6 +12,8 @@ const cors = require('cors');
|
||||
// console.log(" 2) fs");
|
||||
const fs = require('fs');
|
||||
|
||||
const NUOVO_METODO_TEST = true;
|
||||
|
||||
const server_constants = require('./tools/server_constants');
|
||||
|
||||
//const throttle = require('express-throttle-bandwidth');
|
||||
@@ -23,49 +28,33 @@ const bodyParser = require('body-parser');
|
||||
const path = require('path');
|
||||
|
||||
const cron = require('node-cron');
|
||||
console.log('Starting mongoose...');
|
||||
|
||||
require('./db/mongoose');
|
||||
|
||||
const {Settings} = require('./models/settings');
|
||||
// console.log('Starting pem...');
|
||||
|
||||
// const pem = require('pem')
|
||||
|
||||
const { Settings } = require('./models/settings');
|
||||
|
||||
// test
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
let credentials = null;
|
||||
|
||||
// OBTAIN
|
||||
// https://www.psclistens.com/insight/blog/enabling-a-nodejs-ssl-webserver-using-let-s-encrypt-pem-certificates/
|
||||
|
||||
if ((process.env.NODE_ENV === 'production') ||
|
||||
(process.env.NODE_ENV === 'test')) {
|
||||
var privateKey = fs.readFileSync(process.env.PATH_CERT_KEY, 'utf8');
|
||||
var certificate = fs.readFileSync(process.env.PATH_SERVER_CRT, 'utf8');
|
||||
var credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
ca: [
|
||||
fs.readFileSync(process.env.PATH_SSL_ROOT_PEM, 'utf8'),
|
||||
fs.readFileSync(process.env.PATH_SSL_CHAIN_PEM, 'utf8'),
|
||||
],
|
||||
};
|
||||
var https = require('https');
|
||||
} else {
|
||||
if (process.env.HTTPS_LOCALHOST === "true") {
|
||||
var privateKey = fs.readFileSync(process.env.PATH_CERT_KEY, 'utf8');
|
||||
var certificate = fs.readFileSync(process.env.PATH_SERVER_CRT, 'utf8');
|
||||
var credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
ciphers: 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384',
|
||||
honorCipherOrder: true,
|
||||
secureProtocol: 'TLSv1_2_method',
|
||||
};
|
||||
var https = require('https');
|
||||
|
||||
} else {
|
||||
var http = require('http');
|
||||
}
|
||||
if ((process.env.NODE_ENV === 'production')) {
|
||||
console.log('*** AMBIENTE DI PRODUZIONE !!!!')
|
||||
} else if (process.env.NODE_ENV === 'test') {
|
||||
console.log('*** ### AMBIENTE DI TEST ')
|
||||
}
|
||||
|
||||
|
||||
console.log('DB: ' + process.env.DATABASE);
|
||||
// console.log("PORT: " + port);
|
||||
// console.log("MONGODB_URI: " + process.env.MONGODB_URI);
|
||||
@@ -82,17 +71,17 @@ var mongoose = require('mongoose').set('debug', false);
|
||||
|
||||
mongoose.set('debug', false);
|
||||
|
||||
const {CfgServer} = require('./models/cfgserver');
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { CfgServer } = require('./models/cfgserver');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const populate = require('./populate/populate');
|
||||
const {Circuit} = require('./models/circuit');
|
||||
const { Circuit } = require('./models/circuit');
|
||||
|
||||
const printf = require('util').format;
|
||||
|
||||
myLoad().then(ris => {
|
||||
|
||||
const {User} = require('./models/user');
|
||||
const { User } = require('./models/user');
|
||||
|
||||
require('./models/todo');
|
||||
require('./models/project');
|
||||
@@ -125,6 +114,7 @@ myLoad().then(ris => {
|
||||
const users_router = require('./router/users_router');
|
||||
const mygroups_router = require('./router/mygroups_router');
|
||||
const circuits_router = require('./router/circuits_router');
|
||||
const accounts_router = require('./router/accounts_router');
|
||||
const iscrittiConacreis_router = require('./router/iscrittiConacreis_router');
|
||||
const iscrittiArcadei_router = require('./router/iscrittiArcadei_router');
|
||||
const site_router = require('./router/site_router');
|
||||
@@ -136,18 +126,18 @@ myLoad().then(ris => {
|
||||
const mygoods_router = require('./router/mygoods_router');
|
||||
const mygen_router = require('./router/mygen_router');
|
||||
|
||||
const {MyEvent} = require('./models/myevent');
|
||||
const { MyEvent } = require('./models/myevent');
|
||||
|
||||
app.use(express.static('views'));
|
||||
|
||||
// app.use(express.static(path.join(__dirname, 'client')));
|
||||
// app.use(express.static(path.join(__dirname, 'client')));
|
||||
|
||||
app.use(bodyParser.json());
|
||||
|
||||
// app.set('view engine', 'pug');
|
||||
// app.set('view engine', 'pug');
|
||||
|
||||
// Set static folder
|
||||
// app.use(express.static(path.join(__dirname, 'public')));
|
||||
// Set static folder
|
||||
// app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
i18n.configure({
|
||||
locales: ['it', 'enUs', 'es', 'fr', 'pt', 'si'],
|
||||
@@ -166,10 +156,13 @@ myLoad().then(ris => {
|
||||
|
||||
app.use(bodyParser.json());
|
||||
|
||||
// app.use(express.cookieParser());
|
||||
// app.use(express.cookieParser());
|
||||
app.use(i18n.init);
|
||||
|
||||
// Use Routes
|
||||
console.log('Use Routes \...');
|
||||
|
||||
|
||||
// Use Routes
|
||||
app.use('/', index_router);
|
||||
app.use('/subscribe', subscribe_router);
|
||||
app.use('/sendmsg', sendmsg_router);
|
||||
@@ -186,6 +179,7 @@ myLoad().then(ris => {
|
||||
app.use('/users', users_router);
|
||||
app.use('/mygroup', mygroups_router);
|
||||
app.use('/circuit', circuits_router);
|
||||
app.use('/account', accounts_router);
|
||||
app.use('/iscritti_conacreis', iscrittiConacreis_router);
|
||||
app.use('/iscritti_arcadei', iscrittiArcadei_router);
|
||||
app.use('/report', report_router);
|
||||
@@ -198,24 +192,24 @@ myLoad().then(ris => {
|
||||
app.use('/mygoods', mygoods_router);
|
||||
app.use('/mygen', mygen_router);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
// app.use(function (req, res, next) {
|
||||
// var err = new Error('Not Found');
|
||||
// err.status = 404;
|
||||
// next(err);
|
||||
// });
|
||||
// catch 404 and forward to error handler
|
||||
// app.use(function (req, res, next) {
|
||||
// var err = new Error('Not Found');
|
||||
// err.status = 404;
|
||||
// next(err);
|
||||
// });
|
||||
|
||||
// app.set('views', path.join(__dirname, 'views'));
|
||||
// app.set('view engine', 'pug');
|
||||
// app.set('views', path.join(__dirname, 'views'));
|
||||
// app.set('view engine', 'pug');
|
||||
|
||||
// development error handler
|
||||
// will print stacktrace
|
||||
// development error handler
|
||||
// will print stacktrace
|
||||
if (app.get('env') === 'development') {
|
||||
|
||||
app.use(function(err, req, res, next) {
|
||||
app.use(function (err, req, res, next) {
|
||||
console.log('Server Error: ', err.message);
|
||||
// console.trace();
|
||||
res.status(err.status || 500).send({error: err.message});
|
||||
res.status(err.status || 500).send({ error: err.message });
|
||||
// res.render('error', {
|
||||
// message: err.message,
|
||||
// error: err
|
||||
@@ -224,28 +218,86 @@ myLoad().then(ris => {
|
||||
|
||||
}
|
||||
|
||||
// require('./telegram/telegrambot');
|
||||
// require('./telegram/telegrambot');
|
||||
|
||||
// *** DB CONNECTIONS ***
|
||||
// mysql_func.mySqlConn_Shen.connect((err) => {
|
||||
// if (!err)
|
||||
// console.log('DB connection to Shen Database succeded.');
|
||||
// else
|
||||
// console.log('DB connection to Shen Database FAILED \n Error: ' + JSON.stringify(err, undefined, 2));
|
||||
// });
|
||||
// *** DB CONNECTIONS ***
|
||||
// mysql_func.mySqlConn_Shen.connect((err) => {
|
||||
// if (!err)
|
||||
// console.log('DB connection to Shen Database succeded.');
|
||||
// else
|
||||
// console.log('DB connection to Shen Database FAILED \n Error: ' + JSON.stringify(err, undefined, 2));
|
||||
// });
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
console.log('*** PRODUCTION! ');
|
||||
}
|
||||
|
||||
if ((process.env.NODE_ENV === 'production') ||
|
||||
(process.env.NODE_ENV === 'test') || process.env.HTTPS_LOCALHOST === "true") {
|
||||
var httpsServer = https.createServer(credentials, app);
|
||||
console.log('httpsServer: port ', port);
|
||||
httpsServer.listen(port);
|
||||
(process.env.NODE_ENV === 'test')) {
|
||||
|
||||
const keyStream = path.resolve(`./${process.env.PATH_CERT_KEY}`);
|
||||
const certificateStream = path.resolve(`./${process.env.PATH_SERVER_CRT}`);
|
||||
|
||||
const privateKey = fs.readFileSync(keyStream, "utf8");
|
||||
const certificate = fs.readFileSync(certificateStream, "utf8");
|
||||
|
||||
|
||||
if (NUOVO_METODO_TEST) {
|
||||
credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
};
|
||||
} else {
|
||||
credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
ca: [
|
||||
fs.readFileSync(process.env.PATH_SSL_ROOT_PEM, 'utf8'),
|
||||
fs.readFileSync(process.env.PATH_SSL_CHAIN_PEM, 'utf8'),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
var https = require('https');
|
||||
} else {
|
||||
if (process.env.HTTPS_LOCALHOST === "true") {
|
||||
var privateKey = fs.readFileSync(process.env.PATH_CERT_KEY, 'utf8');
|
||||
var certificate = fs.readFileSync(process.env.PATH_SERVER_CRT, 'utf8');
|
||||
credentials = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
ciphers: 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384',
|
||||
honorCipherOrder: true,
|
||||
secureProtocol: 'TLSv1_2_method',
|
||||
};
|
||||
var https = require('https');
|
||||
|
||||
} else {
|
||||
var http = require('http');
|
||||
}
|
||||
}
|
||||
|
||||
if ((process.env.NODE_ENV === 'production') ||
|
||||
(process.env.NODE_ENV === 'test') || process.env.HTTPS_LOCALHOST === "true") {
|
||||
|
||||
if (false) {
|
||||
/*pem.createCertificate({ days: 1, selfSigned: true }, (err, keys) => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
const httpsServer = https.createServer({ key: keys.clientKey, cert: keys.certificate }, (req, res) => {
|
||||
res.end('o hai!')
|
||||
}).listen(port)
|
||||
}) */
|
||||
} else {
|
||||
const httpsServer = https.createServer(credentials, app);
|
||||
|
||||
console.log('httpsServer: port ', port);
|
||||
httpsServer.listen(port);
|
||||
}
|
||||
} else {
|
||||
console.log('httpServer: port ', port);
|
||||
var httpServer = http.createServer(app);
|
||||
const httpServer = http.createServer(app);
|
||||
httpServer.listen(port);
|
||||
}
|
||||
|
||||
@@ -304,17 +356,17 @@ async function mystart() {
|
||||
|
||||
faitest();
|
||||
|
||||
// ----------------- MAILCHIMP -----
|
||||
// ----------------- MAILCHIMP -----
|
||||
const querystring = require('querystring');
|
||||
const mailchimpClientId = 'xxxxxxxxxxxxxxxx';
|
||||
|
||||
app.get('/mailchimp/auth/authorize', function(req, res) {
|
||||
app.get('/mailchimp/auth/authorize', function (req, res) {
|
||||
res.redirect('https://login.mailchimp.com/oauth2/authorize?' +
|
||||
querystring.stringify({
|
||||
'response_type': 'code',
|
||||
'client_id': mailchimpClientId,
|
||||
'redirect_uri': 'http://127.0.0.1:3000/mailchimp/auth/callback',
|
||||
}));
|
||||
querystring.stringify({
|
||||
'response_type': 'code',
|
||||
'client_id': mailchimpClientId,
|
||||
'redirect_uri': 'http://127.0.0.1:3000/mailchimp/auth/callback',
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
@@ -350,7 +402,7 @@ async function mycron_30min() {
|
||||
let enablecrontab = false;
|
||||
|
||||
enablecrontab = await Settings.getValDbSettings(app.idapp,
|
||||
tools.ENABLE_CRONTAB, false);
|
||||
tools.ENABLE_CRONTAB, false);
|
||||
|
||||
if (enablecrontab) {
|
||||
// ...
|
||||
@@ -359,22 +411,22 @@ async function mycron_30min() {
|
||||
}
|
||||
|
||||
function testmsgwebpush() {
|
||||
const {User} = require('./models/user');
|
||||
const { User } = require('./models/user');
|
||||
|
||||
// console.log('nomeapp 1: ' , tools.getNomeAppByIdApp(1));
|
||||
// console.log('nomeapp 2: ' , tools.getNomeAppByIdApp(2));
|
||||
|
||||
User.find({username: 'paoloar77', idapp: '1'}).then(async (arrusers) => {
|
||||
User.find({ username: 'paoloar77', idapp: '1' }).then(async (arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
await tools.sendNotificationToUser(user._id, 'Server',
|
||||
'Il Server è Ripartito', '/', '', 'server', []).then(ris => {
|
||||
if (ris) {
|
||||
'Il Server è Ripartito', '/', '', 'server', []).then(ris => {
|
||||
if (ris) {
|
||||
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -402,16 +454,16 @@ cron.schedule('*/60 * * * *', async () => {
|
||||
|
||||
async function resetProcessingJob() {
|
||||
|
||||
const {Newstosent} = require('./models/newstosent');
|
||||
const { Newstosent } = require('./models/newstosent');
|
||||
|
||||
arrrec = await Newstosent.find({});
|
||||
|
||||
for (const rec of arrrec) {
|
||||
rec.processing_job = false;
|
||||
await Newstosent.findOneAndUpdate({_id: rec.id}, {$set: rec}, {new: false}).
|
||||
then((item) => {
|
||||
await Newstosent.findOneAndUpdate({ _id: rec.id }, { $set: rec }, { new: false }).
|
||||
then((item) => {
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,13 +477,13 @@ async function inizia() {
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
await telegrambot.sendMsgTelegram(tools.FREEPLANET,
|
||||
telegrambot.ADMIN_USER_SERVER,
|
||||
`Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}!`);
|
||||
telegrambot.ADMIN_USER_SERVER,
|
||||
`Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}!`);
|
||||
|
||||
await telegrambot.sendMsgTelegramByIdTelegram(tools.FREEPLANET,
|
||||
telegrambot.ADMIN_IDTELEGRAM_SERVER,
|
||||
`Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}\n` +
|
||||
`🔅 Il Server ${process.env.DATABASE} è appena ripartito!`);
|
||||
telegrambot.ADMIN_IDTELEGRAM_SERVER,
|
||||
`Ciao ${telegrambot.ADMIN_USER_NAME_SERVER}\n` +
|
||||
`🔅 Il Server ${process.env.DATABASE} è appena ripartito!`);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -445,7 +497,7 @@ async function inizia() {
|
||||
|
||||
*/
|
||||
|
||||
console.log(process.versions);
|
||||
|
||||
|
||||
} catch (e) {
|
||||
|
||||
@@ -468,7 +520,7 @@ async function inizia() {
|
||||
// }
|
||||
|
||||
async function estraiImmagini(table) {
|
||||
const {User} = require('./models/user');
|
||||
const { User } = require('./models/user');
|
||||
|
||||
let idapp = '13';
|
||||
|
||||
@@ -483,7 +535,7 @@ async function estraiImmagini(table) {
|
||||
|
||||
console.log('INIZIO - estraiImmagini', table);
|
||||
|
||||
arrlist = await mytable.find({idapp}).lean();
|
||||
arrlist = await mytable.find({ idapp }).lean();
|
||||
|
||||
let file = '';
|
||||
let filetocheck = '';
|
||||
@@ -498,7 +550,7 @@ async function estraiImmagini(table) {
|
||||
}
|
||||
|
||||
for (const rec of arrlist) {
|
||||
const myuser = await User.findOne({idapp, _id: rec.userId}).lean();
|
||||
const myuser = await User.findOne({ idapp, _id: rec.userId }).lean();
|
||||
if (myuser) {
|
||||
const myphotos = rec.photos;
|
||||
|
||||
@@ -527,7 +579,7 @@ async function estraiImmagini(table) {
|
||||
|
||||
if (photo.imagefile) {
|
||||
file = dir + 'profile/' + myuser.username + '/' + table + '/' +
|
||||
photo.imagefile;
|
||||
photo.imagefile;
|
||||
filefrom = dir + 'profile/undefined/' + table + '/' + photo.imagefile;
|
||||
filefrom2 = dir + 'profile/' + myuser.username + '/' + photo.imagefile;
|
||||
|
||||
@@ -587,7 +639,7 @@ async function faitest() {
|
||||
}
|
||||
|
||||
if (testfind) {
|
||||
const {City} = require('./models/city');
|
||||
const { City } = require('./models/city');
|
||||
|
||||
let miacity = 'roma';
|
||||
const ris = await City.findByCity(miacity);
|
||||
@@ -595,7 +647,7 @@ async function faitest() {
|
||||
console.log('ris', ris);
|
||||
}
|
||||
|
||||
const {User} = require('./models/user');
|
||||
const { User } = require('./models/user');
|
||||
|
||||
if (false) {
|
||||
let myuser = await User.findOne({
|
||||
@@ -617,13 +669,13 @@ async function faitest() {
|
||||
});
|
||||
|
||||
await sendemail.sendEmail_Registration('it', 'paolo@arcodiluce.it', user,
|
||||
'12', '');
|
||||
'12', '');
|
||||
|
||||
}
|
||||
|
||||
if (false) {
|
||||
|
||||
const {User} = require('./models/user');
|
||||
const { User } = require('./models/user');
|
||||
|
||||
const idapp = tools.FREEPLANET;
|
||||
const idreg = 0;
|
||||
@@ -653,12 +705,12 @@ async function faitest() {
|
||||
};
|
||||
|
||||
await telegrambot.notifyToTelegram(telegrambot.phase.REGISTRATION,
|
||||
mylocalsconf);
|
||||
mylocalsconf);
|
||||
} catch (e) {
|
||||
console.log('error ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {app};
|
||||
module.exports = { app };
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@ const CryptoJS = require('crypto-js');
|
||||
|
||||
const Url = require('url-parse');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
const { ObjectID, ObjectId } = require('mongodb');
|
||||
|
||||
const shared_consts = require('./shared_nodejs');
|
||||
|
||||
@@ -32,9 +32,11 @@ const webpush = require('web-push');
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
|
||||
const FILELOG = 'filelog.txt';
|
||||
const FILEEVENTS = 'logevents.txt';
|
||||
const FILEMANAGERS = 'logmanagers.txt';
|
||||
const FILETRANSACTION = 'logtrans.txt';
|
||||
const FILEERRLOGIN = 'errlogin.txt';
|
||||
const FILESOSTITUZIONI = 'log_sostituzioni.txt';
|
||||
const FILEIP_TO_BAN = 'log_iptoban.txt';
|
||||
@@ -125,6 +127,7 @@ const textlang = {
|
||||
'MSG_SEND_FROM': 'Msg Inviato da',
|
||||
'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!',
|
||||
'RICHIESTA_AMICIZIA': '🌈 Richiesta d\'Amicizia da parte di %s',
|
||||
'RICHIESTA_HANDSHAKE': '🌈 %s ha comunicato che ti conosce personalmente e ha fiducia in te.',
|
||||
'ACCETTATO_SUL_GRUPPO': '✅ Sei stato accettato da %s a far parte del Gruppo %s',
|
||||
'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)',
|
||||
@@ -423,6 +426,8 @@ module.exports = {
|
||||
|
||||
SEP: '|',
|
||||
|
||||
USER_ADMIN_CIRCUITS: 'paoloar77',
|
||||
|
||||
TYPE_PROJECT: 1,
|
||||
TYPE_TODO: 2,
|
||||
|
||||
@@ -836,8 +841,10 @@ module.exports = {
|
||||
}).catch(async (err) => {
|
||||
console.error('err Push', err.body);
|
||||
|
||||
// Cancella dal DB la notifica Push, visto che da errore! (sarà scaduto)
|
||||
const ris = await Subscription.deleteOne({ _id: subscription._id });
|
||||
if (err.body) {
|
||||
// Cancella dal DB la notifica Push, visto che da errore! (sarà scaduto)
|
||||
const ris = await Subscription.deleteOne({ _id: subscription._id });
|
||||
}
|
||||
|
||||
reject({
|
||||
status: false,
|
||||
@@ -864,13 +871,14 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
getReqByPar(idapp, usernameOrig) {
|
||||
getReqByPar(idapp, usernameOrig, groupOrig) {
|
||||
return {
|
||||
body: {
|
||||
idapp: idapp,
|
||||
},
|
||||
user: {
|
||||
username: usernameOrig,
|
||||
groupOrig,
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -910,6 +918,23 @@ module.exports = {
|
||||
telegrambot.askConfirmationUserFriend(idapp, shared_consts.CallFunz.RICHIESTA_AMICIZIA, userrecDest, username, usernameOrig);
|
||||
}
|
||||
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,6 +952,15 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendMsgTelegramToAdmin: async function (idapp, msg) {
|
||||
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
const idtelegram = telegrambot.ADMIN_IDTELEGRAM_SERVER;
|
||||
|
||||
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, msg);
|
||||
},
|
||||
|
||||
sendNotifAndMsgTelegram: async function (idapp, userId, objmsg, telegram, msgextrateleg) {
|
||||
|
||||
if (userId) {
|
||||
@@ -1014,84 +1048,183 @@ module.exports = {
|
||||
},
|
||||
|
||||
sendNotifCircuitByUsername: async function (
|
||||
cmd, idapp, usernameOrig, usernameDest, username_action,
|
||||
cmd, idapp, usernameOrig, groupOrig, usernameDest, groupDest, username_action,
|
||||
circuitname, path, myreccircuit, isAdmin, username_worked, extrarec) {
|
||||
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
const { User } = require('../models/user');
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
const req = this.getReqByPar(idapp, usernameOrig);
|
||||
const req = this.getReqByPar(idapp, usernameOrig, groupOrig);
|
||||
|
||||
let arrris = [];
|
||||
|
||||
const user = await User.findOne({ idapp, username: usernameDest },
|
||||
{ _id: 1, lang: 1 });
|
||||
|
||||
let lang = 'it';
|
||||
if (user) {
|
||||
lang = user.lang;
|
||||
}
|
||||
let ris = null;
|
||||
|
||||
try {
|
||||
if (user) {
|
||||
let paramsObj = {
|
||||
usernameDest,
|
||||
circuitnameDest: circuitname,
|
||||
path,
|
||||
username_action: username_action,
|
||||
singleadmin_username: usernameDest,
|
||||
extrarec,
|
||||
options: 0,
|
||||
lang,
|
||||
isAdmin,
|
||||
username_worked,
|
||||
};
|
||||
|
||||
let lang = user.lang;
|
||||
let paramsObj = {
|
||||
usernameDest,
|
||||
circuitnameDest: circuitname,
|
||||
path,
|
||||
username_action: username_action,
|
||||
singleadmin_username: usernameDest,
|
||||
extrarec,
|
||||
options: 0,
|
||||
lang,
|
||||
isAdmin,
|
||||
username_worked,
|
||||
};
|
||||
let sendnotif = true;
|
||||
let typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||
let typeid = 0;
|
||||
let onlysave = false;
|
||||
let numuserincircuit = await User.countUsersInCircuit(idapp, circuitname);
|
||||
|
||||
let sendnotif = true;
|
||||
let typedir = shared_consts.TypeNotifs.TYPEDIR_CIRCUITS;
|
||||
let typeid = 0;
|
||||
let onlysave = false;
|
||||
let numuserincircuit = await User.countUsersInCircuit(idapp, circuitname);
|
||||
if (cmd) {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
if (myreccircuit && myreccircuit.createdBy === usernameDest && numuserincircuit <= 1) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
} else {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED;
|
||||
}
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
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,
|
||||
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.REMOVEADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT) {
|
||||
// Crea l'ID di Transazione
|
||||
paramsObj.idTransaction = new ObjectId();
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sendnotif && typeid > 0) {
|
||||
const groupDestoContoCom = groupDest ? groupDest : (extrarec && extrarec.contoComDest ? extrarec.contoComDest : '');
|
||||
// Check if is group:
|
||||
if (groupDestoContoCom && (
|
||||
(cmd !== shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) &&
|
||||
(cmd !== shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT)
|
||||
)) {
|
||||
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, groupDestoContoCom);
|
||||
if (arrusers.length <= 0)
|
||||
arrusers = await Circuit.getListAdminsByCircuitPath(idapp, groupDestoContoCom);
|
||||
|
||||
let notiftoUpdate = '';
|
||||
let findrecnotif = await SendNotif.findOne({ _id: paramsObj.extrarec.notifId }).lean();
|
||||
notiftoUpdate = findrecnotif ? findrecnotif.extrarec.notifIdToUpdate : '';
|
||||
if (findrecnotif) {
|
||||
let arrrec = [];
|
||||
|
||||
if (notiftoUpdate)
|
||||
arrrec = await SendNotif.find({ 'extrarec.notifIdToUpdate': notiftoUpdate });
|
||||
|
||||
for (let rec of arrrec) {
|
||||
paramsObj.usernameDest = rec.dest;
|
||||
paramsObj.sender = rec.sender;
|
||||
if ((cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) || (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE)) {
|
||||
try {
|
||||
paramsObj.extrarec.notifId = rec._id;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
} else {
|
||||
arrris.push(ris._id);
|
||||
}
|
||||
|
||||
if (cmd) {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
if (myreccircuit && myreccircuit.createdBy === usernameDest && numuserincircuit <= 1) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||
} else {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED;
|
||||
}
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
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,
|
||||
myreccircuit._id);
|
||||
onlysave = false;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_ADDED_ADMIN;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT;
|
||||
|
||||
} else {
|
||||
|
||||
for (let i = 0; i < arrusers.length; i++) {
|
||||
paramsObj.usernameDest = arrusers[i].username;
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
} else {
|
||||
arrris.push(ris._id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sendnotif && typeid > 0) {
|
||||
} else {
|
||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||
return await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
|
||||
if ((cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) ||
|
||||
(cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE)) {
|
||||
|
||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT;
|
||||
}
|
||||
|
||||
let notiftoUpdate = '';
|
||||
let findrecnotif = await SendNotif.findOne({ _id: paramsObj.extrarec.notifId }).lean();
|
||||
notiftoUpdate = findrecnotif ? findrecnotif.extrarec.notifIdToUpdate : '';
|
||||
arrnotiftoUpdate = findrecnotif ? findrecnotif.extrarec.arrnotifIdToUpdate : '';
|
||||
if (findrecnotif && notiftoUpdate && arrnotiftoUpdate) {
|
||||
|
||||
for (let myid of arrnotiftoUpdate) {
|
||||
let rec = await SendNotif.findOne({ _id: myid }).lean();
|
||||
if (rec && rec.status === 0) {
|
||||
paramsObj.usernameDest = rec.dest;
|
||||
paramsObj.extrarec.idStatusToSent = rec._id;
|
||||
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { recnotif: ris, arrris };
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
@@ -1138,6 +1271,7 @@ module.exports = {
|
||||
sendNotificationByCircuit: async function (idapp, usernameOrig, circuitname, cmd, value, telegram, username_action, extrarec) {
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
|
||||
const circuit = await Circuit.findOne({ idapp, name: circuitname }, { _id: 1, admins: 1, createdBy: 1, path: 1 }).lean();
|
||||
if (!circuit)
|
||||
@@ -1154,41 +1288,70 @@ module.exports = {
|
||||
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) {
|
||||
recnotif = await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT, idapp, extrarec.dest, usernameOrig,
|
||||
// msg al Mittente (o mittenti del 'groupOrig') "Stai inviando X RIS"
|
||||
let res = await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT, idapp, extrarec.dest, extrarec.groupdest, usernameOrig, groupOrig,
|
||||
username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
|
||||
if (res) {
|
||||
recnotif = res.recnotif;
|
||||
arrris = res.arrris;
|
||||
}
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT, idapp, extrarec.dest, usernameOrig,
|
||||
// msg ai MITTENTI: "X RIS sono stati accettati da Destinatario"
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT, idapp, extrarec.dest, extrarec.groupdest, usernameOrig, groupOrig,
|
||||
username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT, idapp, extrarec.dest, usernameOrig,
|
||||
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT, idapp, extrarec.dest, extrarec.groupdest, usernameOrig, groupOrig,
|
||||
username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
}
|
||||
|
||||
if (recnotif)
|
||||
extrarec.notifIdToUpdate = recnotif._id;
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path,
|
||||
null,
|
||||
false, '', extrarec);
|
||||
if (arrris)
|
||||
extrarec.arrnotifIdToUpdate = arrris;
|
||||
|
||||
let usernametoOrigUse = usernameOrig
|
||||
if (extrarec.groupname) {
|
||||
usernametoOrigUse = ''
|
||||
}
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernametoOrigUse, groupOrig, extrarec.dest, extrarec.groupdest, username_action, circuitname, circuit.path,
|
||||
null, false, '', extrarec);
|
||||
|
||||
if (arrris && ris && ris.recnotif) {
|
||||
for (const rec of arrris) {
|
||||
let obj = {
|
||||
'extrarec.notifIdToUpdate': ris.recnotif._id
|
||||
};
|
||||
|
||||
await SendNotif.findOneAndUpdate({ _id: rec._id }, { $set: obj }, { new: false });
|
||||
}
|
||||
}
|
||||
|
||||
extrarec.notifIdToUpdate = '';
|
||||
|
||||
if (ris)
|
||||
if (ris.recnotif)
|
||||
inviato = true;
|
||||
// ++Todo: Inviare anche agli Admin ?!
|
||||
} else {
|
||||
|
||||
const groupOrig = '' //++Todo: extrarec.groupOrig
|
||||
|
||||
for (const singleadmin of circuit.admins) {
|
||||
try {
|
||||
if (singleadmin.username) {
|
||||
if (usernameOrig === singleadmin.username)
|
||||
giainviato = true;
|
||||
|
||||
await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, singleadmin.username, username_action, circuitname,
|
||||
await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, groupOrig, singleadmin.username, '', username_action, circuitname,
|
||||
circuit.path, circuit, true, '', extrarec);
|
||||
inviato = true;
|
||||
}
|
||||
@@ -1199,15 +1362,15 @@ module.exports = {
|
||||
|
||||
if (!giainviato && cmd !== shared_consts.CIRCUITCMD.REQ) {
|
||||
// SEND TO THE USER DEST THE NOTIFICATION
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, circuitname, circuit.path,
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, groupOrig, usernameOrig, '', username_action, circuitname, circuit.path,
|
||||
null,
|
||||
false, '', extrarec);
|
||||
if (ris)
|
||||
if (ris.recnotif)
|
||||
inviato = true;
|
||||
}
|
||||
}
|
||||
|
||||
return { ris, inviato };
|
||||
return { ris: ris.recnotif, inviato };
|
||||
|
||||
} catch (e) {
|
||||
console.error('sendNotificationByCircuit: ', e);
|
||||
@@ -1297,7 +1460,7 @@ module.exports = {
|
||||
this.mylog('checkUserOk', userpassed, userauth);
|
||||
if (String(userpassed) !== String(userauth)) {
|
||||
// I'm trying to write something not mine!
|
||||
this.mylog('userId = ', userpassed, 'req.user._id', userauth);
|
||||
this.mylog('I\'m trying to write something not mine!: userId = ', userpassed, 'req.user._id', userauth);
|
||||
if (!res) {
|
||||
return {
|
||||
exit: true,
|
||||
@@ -1322,6 +1485,12 @@ module.exports = {
|
||||
return '';
|
||||
},
|
||||
|
||||
convertSpaces_ToUScore(mystr) {
|
||||
if (mystr)
|
||||
return mystr.replace(/\s+/g, '_');
|
||||
return '';
|
||||
},
|
||||
|
||||
convertHTMLtoText(myhtml) {
|
||||
let msg = myhtml;
|
||||
if (msg) {
|
||||
@@ -1374,7 +1543,7 @@ module.exports = {
|
||||
|
||||
let myapp = this.getHostByIdApp(idapp);
|
||||
if (myapp) {
|
||||
myapp += '/signup/' + rec.aportador_solidario + '/' + msg.from.username + '/' + msg.from.id + '/' + rec.regexpire;
|
||||
myapp += '/registrati/' + rec.aportador_solidario + '/' + msg.from.username + '/' + msg.from.id + '/' + rec.regexpire;
|
||||
}
|
||||
|
||||
return myapp;
|
||||
@@ -1580,7 +1749,38 @@ module.exports = {
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$'+params.lk_FF, '$$'+params.lk_FF] },
|
||||
{ $eq: ['$' + params.lk_FF, '$$' + params.lk_FF] },
|
||||
{ $eq: ['$idapp', '$$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: params.lk_as,
|
||||
},
|
||||
},
|
||||
{ $project: proj },
|
||||
];
|
||||
|
||||
return myquery;
|
||||
},
|
||||
|
||||
getGroupnameLookupPipeLine(params, proj) {
|
||||
|
||||
let myquery = [
|
||||
{
|
||||
$lookup: {
|
||||
from: params.lk_tab,
|
||||
let: { groupname: '$' + params.lk_LF, idapp: params.idapp },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$' + params.lk_FF, '$$' + params.lk_FF] },
|
||||
{ $eq: ['$idapp', '$$idapp'] },
|
||||
],
|
||||
},
|
||||
@@ -1792,6 +1992,8 @@ module.exports = {
|
||||
});
|
||||
if (params.filterand.includes(shared_consts.FILTER_USER_TELEGRAM_BLOCKED))
|
||||
filtriadded.push({ 'profile.teleg_id_old': { $gt: 1 } });
|
||||
if (params.filterand.includes(shared_consts.FILTER_USER_PROVINCE))
|
||||
filtriadded.push({ 'profile.resid_province': { $exists: true } });
|
||||
if (params.filterand.includes(shared_consts.FILTER_ATTIVI))
|
||||
filtriadded.push({
|
||||
$or: [
|
||||
@@ -1907,7 +2109,7 @@ module.exports = {
|
||||
|
||||
if (params.filterextra) {
|
||||
if (params.filterextra.length > 0)
|
||||
query = [...query, ...params.filterextra]
|
||||
query = [...query, ...params.filterextra]
|
||||
}
|
||||
|
||||
if (filtriadded) {
|
||||
@@ -1950,6 +2152,8 @@ module.exports = {
|
||||
}, 0, {
|
||||
'user.idapp': 1,
|
||||
'user.username': 1,
|
||||
'user.name': 1,
|
||||
'user.surname': 1,
|
||||
'user.profile.img': 1,
|
||||
'user.profile.qualifica': 1,
|
||||
});
|
||||
@@ -2020,12 +2224,104 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
);
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_GROUP_CIRCUIT) {
|
||||
|
||||
const myq = this.addQueryIdMatch(params);
|
||||
if (myq)
|
||||
query.push(myq);
|
||||
|
||||
query.push({ $project: { req_groups: 1 } });
|
||||
const qa1 = this.getLookup(
|
||||
{
|
||||
lk_tab: 'mygroups',
|
||||
lk_LF: 'req_groups.groupname',
|
||||
lk_FF: 'groupname',
|
||||
lk_as: 'group',
|
||||
}, 0, {
|
||||
'group.idapp': 1,
|
||||
'group.groupname': 1,
|
||||
'group.photos': 1,
|
||||
});
|
||||
if (qa1) query = [...query, ...qa1];
|
||||
query.push({ $unwind: '$group' });
|
||||
|
||||
query.push({
|
||||
$match: {
|
||||
$and: [
|
||||
{ 'group.idapp': params.idapp },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
query.push({
|
||||
$replaceRoot: {
|
||||
newRoot: '$group',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_REFUSED_GROUP_CIRCUIT) {
|
||||
|
||||
|
||||
const myq = this.addQueryIdMatch(params);
|
||||
if (myq)
|
||||
query.push(myq);
|
||||
|
||||
query.push({ $project: { refused_groups: 1 } });
|
||||
query.push({ $unwind: '$refused_groups' });
|
||||
const qa1 = this.getGroupnameLookupPipeLine(
|
||||
{
|
||||
lk_tab: 'mygroups',
|
||||
lk_LF: 'refused_groups.groupname',
|
||||
lk_FF: 'groupname',
|
||||
lk_as: 'group',
|
||||
idapp,
|
||||
}, {
|
||||
'group.idapp': 1,
|
||||
'group.groupname': 1,
|
||||
'group.descr': 1,
|
||||
'group.photos': 1,
|
||||
});
|
||||
if (qa1) query = [...query, ...qa1];
|
||||
query.push({ $unwind: '$group' });
|
||||
/*
|
||||
query.push({
|
||||
$match: {
|
||||
$and: [
|
||||
{'user.idapp': params.idapp},
|
||||
],
|
||||
},
|
||||
});
|
||||
*/
|
||||
|
||||
query.push({
|
||||
$replaceRoot: {
|
||||
newRoot: '$group',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_LIST_MOVEMENTS) {
|
||||
|
||||
const { Movement } = require('../models/movement');
|
||||
|
||||
const myquery = await Movement.getQueryMovsByCircuitId(params.idapp, params.username, params.myid);
|
||||
const myquery = await Movement.getQueryMovsByCircuitId(params.idapp, params.username, '', '', params.myid);
|
||||
|
||||
query.push(...myquery);
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_LIST_MOVEMENTS_GROUPNAME) {
|
||||
|
||||
const { Movement } = require('../models/movement');
|
||||
|
||||
const myquery = await Movement.getQueryMovsByCircuitId(params.idapp, '', params.groupname, '', params.myid);
|
||||
|
||||
query.push(...myquery);
|
||||
|
||||
} else if (params.querytype === shared_consts.QUERYTYPE_LIST_MOVEMENTS_CONTOCOM) {
|
||||
|
||||
const { Movement } = require('../models/movement');
|
||||
|
||||
const myquery = await Movement.getQueryMovsByCircuitId(params.idapp, '', '', params.contocom, params.myid);
|
||||
|
||||
query.push(...myquery);
|
||||
|
||||
@@ -2800,6 +3096,9 @@ module.exports = {
|
||||
writeManagersLog(mystr) {
|
||||
this.writelogfile(mystr, FILEMANAGERS);
|
||||
},
|
||||
writeTransactionLog(mystr) {
|
||||
this.writelogfile(mystr, FILETRANSACTION);
|
||||
},
|
||||
writeErrorLog(mystr) {
|
||||
this.writelogfile(mystr, FILEERRLOGIN);
|
||||
},
|
||||
@@ -3327,7 +3626,7 @@ module.exports = {
|
||||
const linkuserprof = this.getHostByIdApp(idapp) + '/my/' +
|
||||
myuser.username;
|
||||
|
||||
msg = `<br>Username: <b>${name}</b><br>Profilo su APP: ${linkuserprof}<br>Email: ${myuser.email}`;
|
||||
msg = `<br>👉🏻 <a href="${linkuserprof}">${name}</a> (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')
|
||||
@@ -3337,8 +3636,12 @@ module.exports = {
|
||||
? myuser.profile.lastname_telegram
|
||||
: surname_telegram;
|
||||
|
||||
let namesurnametg = '';
|
||||
if (name_tg || surname_tg)
|
||||
namesurnametg = ` [${name_tg} ${surname_tg}]`;;
|
||||
|
||||
if (u_tg) {
|
||||
msg += `<br>Profilo su Telegram [${name_tg} ${surname_tg}]:<br>https://t.me/${u_tg}`;
|
||||
msg += `<br><br>https://t.me/${u_tg}`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('getUserInfoMsg', e);
|
||||
@@ -3347,6 +3650,28 @@ module.exports = {
|
||||
return msg;
|
||||
},
|
||||
|
||||
getUserShortInfoMsg: function (idapp, myuser, usernametelegram = '', name_telegram = '',
|
||||
surname_telegram = '') {
|
||||
|
||||
let msg = '';
|
||||
try {
|
||||
const name = myuser.username +
|
||||
(myuser.name ? ` (${myuser.name} ${myuser.surname})` : '');
|
||||
const linkuserprof = this.getHostByIdApp(idapp) + '/my/' +
|
||||
myuser.username;
|
||||
|
||||
let u_tg = myuser.profile && myuser.profile.hasOwnProperty('username_telegram') ? myuser.profile.username_telegram : usernametelegram;
|
||||
|
||||
msg = `<br>Vedi Profilo sulla APP di <a href="${linkuserprof}">${name}</a>`;
|
||||
msg += `<br>Telegram: @${u_tg}`;
|
||||
|
||||
} catch (e) {
|
||||
console.error('getUserInfoMsg', e);
|
||||
}
|
||||
|
||||
return msg;
|
||||
},
|
||||
|
||||
getlinkRelativeRequestNewPassword: function (idapp, email, tokenforgot) {
|
||||
const strlinkreg = process.env.LINK_UPDATE_PASSWORD +
|
||||
`?idapp=${idapp}&email=${email}&tokenforgot=${tokenforgot}`;
|
||||
|
||||
@@ -8,52 +8,52 @@ require('../config/config');
|
||||
|
||||
require('../models/subscribers');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
const {Booking} = require('../models/booking');
|
||||
const {Operator} = require('../models/operator');
|
||||
const {Where} = require('../models/where');
|
||||
const {MyEvent} = require('../models/myevent');
|
||||
const {Contribtype} = require('../models/contribtype');
|
||||
const {PaymentType} = require('../models/paymenttype');
|
||||
const {Discipline} = require('../models/discipline');
|
||||
const {Skill} = require('../models/skill');
|
||||
const {Good} = require('../models/good');
|
||||
const {SubSkill} = require('../models/subskill');
|
||||
const {MySkill} = require('../models/myskill');
|
||||
const {MyGood} = require('../models/mygood');
|
||||
const {MyBacheca} = require('../models/mybacheca');
|
||||
const {MyHosp} = require('../models/myhosp');
|
||||
const {StatusSkill} = require('../models/statusSkill');
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
const {Sector} = require('../models/sector');
|
||||
const {SectorGood} = require('../models/sectorgood');
|
||||
const {CatGrp} = require('../models/catgrp');
|
||||
const {Level} = require('../models/level');
|
||||
const {AdType} = require('../models/adtype');
|
||||
const {AdTypeGood} = require('../models/adtypegood');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
const {Account} = require('../models/account');
|
||||
const {Movement} = require('../models/movement');
|
||||
const { User } = require('../models/user');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const { Booking } = require('../models/booking');
|
||||
const { Operator } = require('../models/operator');
|
||||
const { Where } = require('../models/where');
|
||||
const { MyEvent } = require('../models/myevent');
|
||||
const { Contribtype } = require('../models/contribtype');
|
||||
const { PaymentType } = require('../models/paymenttype');
|
||||
const { Discipline } = require('../models/discipline');
|
||||
const { Skill } = require('../models/skill');
|
||||
const { Good } = require('../models/good');
|
||||
const { SubSkill } = require('../models/subskill');
|
||||
const { MySkill } = require('../models/myskill');
|
||||
const { MyGood } = require('../models/mygood');
|
||||
const { MyBacheca } = require('../models/mybacheca');
|
||||
const { MyHosp } = require('../models/myhosp');
|
||||
const { StatusSkill } = require('../models/statusSkill');
|
||||
const { City } = require('../models/city');
|
||||
const { Province } = require('../models/province');
|
||||
const { Sector } = require('../models/sector');
|
||||
const { SectorGood } = require('../models/sectorgood');
|
||||
const { CatGrp } = require('../models/catgrp');
|
||||
const { Level } = require('../models/level');
|
||||
const { AdType } = require('../models/adtype');
|
||||
const { AdTypeGood } = require('../models/adtypegood');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Account } = require('../models/account');
|
||||
const { Movement } = require('../models/movement');
|
||||
const Pickup = require('../models/pickup');
|
||||
const {Newstosent} = require('../models/newstosent');
|
||||
const {MyPage} = require('../models/mypage');
|
||||
const {MyElem} = require('../models/myelem');
|
||||
const {MyBot} = require('../models/bot');
|
||||
const {CfgServer} = require('../models/cfgserver');
|
||||
const {CalZoom} = require('../models/calzoom');
|
||||
const {Gallery} = require('../models/gallery');
|
||||
const {TemplEmail} = require('../models/templemail');
|
||||
const {OpzEmail} = require('../models/opzemail');
|
||||
const {MailingList} = require('../models/mailinglist');
|
||||
const {Settings} = require('../models/settings');
|
||||
const {SendMsg} = require('../models/sendmsg');
|
||||
const {Permission} = require('../models/permission');
|
||||
const {MsgTemplate} = require('../models/msg_template');
|
||||
const {Graduatoria} = require('../models/graduatoria');
|
||||
const { Newstosent } = require('../models/newstosent');
|
||||
const { MyPage } = require('../models/mypage');
|
||||
const { MyElem } = require('../models/myelem');
|
||||
const { MyBot } = require('../models/bot');
|
||||
const { CfgServer } = require('../models/cfgserver');
|
||||
const { CalZoom } = require('../models/calzoom');
|
||||
const { Gallery } = require('../models/gallery');
|
||||
const { TemplEmail } = require('../models/templemail');
|
||||
const { OpzEmail } = require('../models/opzemail');
|
||||
const { MailingList } = require('../models/mailinglist');
|
||||
const { Settings } = require('../models/settings');
|
||||
const { SendMsg } = require('../models/sendmsg');
|
||||
const { Permission } = require('../models/permission');
|
||||
const { MsgTemplate } = require('../models/msg_template');
|
||||
const { Graduatoria } = require('../models/graduatoria');
|
||||
const Product = require('../models/product');
|
||||
const Producer = require('../models/producer');
|
||||
const Cart = require('../models/cart');
|
||||
@@ -65,7 +65,7 @@ const Site = require('../models/site');
|
||||
const IscrittiConacreis = require('../models/iscrittiConacreis');
|
||||
const IscrittiArcadei = require('../models/iscrittiArcadei');
|
||||
const Group = require('../models/group');
|
||||
const {Todo} = require('../models/todo');
|
||||
const { Todo } = require('../models/todo');
|
||||
const Hours = require('../models/hours');
|
||||
const Order = require('../models/order');
|
||||
const Cash = require('../models/cash');
|
||||
@@ -88,7 +88,7 @@ module.exports = {
|
||||
mytable = MyGroup;
|
||||
else if (tablename === 'tessitura')
|
||||
mytable = Tessitura;
|
||||
// else if (tablename === 'extralist')
|
||||
// else if (tablename === 'extralist')
|
||||
// mytable = ExtraList;
|
||||
else if (tablename === 'bookings')
|
||||
mytable = Booking;
|
||||
@@ -168,7 +168,7 @@ module.exports = {
|
||||
mytable = MsgTemplate;
|
||||
else if (tablename === 'navepersistente')
|
||||
mytable = NavePersistente;
|
||||
// else if (tablename === 'listaingressos')
|
||||
// else if (tablename === 'listaingressos')
|
||||
// mytable = ListaIngresso;
|
||||
else if (tablename === 'graduatorias')
|
||||
mytable = Graduatoria;
|
||||
@@ -282,7 +282,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
SendMsgToParam: async function(idapp, params) {
|
||||
SendMsgToParam: async function (idapp, params) {
|
||||
|
||||
try {
|
||||
console.log('SendMsgToParam', params.typesend);
|
||||
@@ -294,7 +294,7 @@ module.exports = {
|
||||
if (params.typesend === 0)
|
||||
params.typesend = shared_consts.TypeSend.PUSH_NOTIFICATION;
|
||||
|
||||
let query = {idapp};
|
||||
let query = { idapp };
|
||||
let addquery = {};
|
||||
|
||||
let invia = true;
|
||||
@@ -302,39 +302,39 @@ module.exports = {
|
||||
if (params.typemsg === shared_consts.TypeMsg.SEND_TO_ALL) {
|
||||
addquery = {};
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_SOCI) {
|
||||
addquery = {'profile.socio': true};
|
||||
addquery = { 'profile.socio': true };
|
||||
} else if (params.typemsg ===
|
||||
shared_consts.TypeMsg.SEND_TO_SOCIO_RESIDENTE) {
|
||||
addquery = {'profile.socioresidente': true};
|
||||
shared_consts.TypeMsg.SEND_TO_SOCIO_RESIDENTE) {
|
||||
addquery = { 'profile.socioresidente': true };
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_CONSIGLIO) {
|
||||
addquery = {'profile.consiglio': true};
|
||||
addquery = { 'profile.consiglio': true };
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
|
||||
addquery = {'profile.socio': false};
|
||||
addquery = { 'profile.socio': false };
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_PAOLO) {
|
||||
addquery = {username: 'paoloar77'};
|
||||
addquery = { username: 'paoloar77' };
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_USER) {
|
||||
addquery = {username: params.usernameDest};
|
||||
addquery = { username: params.usernameDest };
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_MYSELF) {
|
||||
addquery = {username: params.usernameDest};
|
||||
addquery = { username: params.usernameDest };
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_TELEG_NO_USERNAME_TELEG) {
|
||||
addquery = {
|
||||
'profile.teleg_id': {$gt: 1},
|
||||
'profile.teleg_id': { $gt: 1 },
|
||||
$or: [
|
||||
{'profile.username_telegram': {$exists: false}},
|
||||
{'profile.username_telegram': {$exists: true, $eq: ''}}],
|
||||
{ 'profile.username_telegram': { $exists: false } },
|
||||
{ 'profile.username_telegram': { $exists: true, $eq: '' } }],
|
||||
};
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_TELEG_NO_VERIF_BY_APORTADOR) {
|
||||
addquery = {
|
||||
'profile.teleg_id': {$gt: 1},
|
||||
'profile.username_telegram': {$exists: true},
|
||||
$expr: {$gt: [{$strLenCP: '$profile.username_telegram'}, 3]},
|
||||
'verified_by_aportador': {$exists: false},
|
||||
'profile.teleg_id': { $gt: 1 },
|
||||
'profile.username_telegram': { $exists: true },
|
||||
$expr: { $gt: [{ $strLenCP: '$profile.username_telegram' }, 3] },
|
||||
'verified_by_aportador': { $exists: false },
|
||||
};
|
||||
} else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_GROUP) {
|
||||
if (params.groupnameDest) {
|
||||
addquery = {
|
||||
'profile.mygroups': {
|
||||
$elemMatch: {groupname: {$eq: params.groupnameDest}},
|
||||
$elemMatch: { groupname: { $eq: params.groupnameDest } },
|
||||
},
|
||||
};
|
||||
} else {
|
||||
@@ -344,7 +344,7 @@ module.exports = {
|
||||
if (params.circuitnameDest) {
|
||||
addquery = {
|
||||
'profile.mycircuits': {
|
||||
$elemMatch: {circuitname: {$eq: params.circuitnameDest}},
|
||||
$elemMatch: { circuitname: { $eq: params.circuitnameDest } },
|
||||
},
|
||||
};
|
||||
} else {
|
||||
@@ -358,14 +358,14 @@ module.exports = {
|
||||
|
||||
if (invia) {
|
||||
|
||||
const allquery = {...query, ...addquery};
|
||||
const allquery = { ...query, ...addquery };
|
||||
|
||||
const arrusers = await User.find(
|
||||
allquery,
|
||||
{
|
||||
username: 1,
|
||||
'profile.teleg_id': 1,
|
||||
},
|
||||
allquery,
|
||||
{
|
||||
username: 1,
|
||||
'profile.teleg_id': 1,
|
||||
},
|
||||
).lean();
|
||||
|
||||
|
||||
@@ -378,15 +378,15 @@ module.exports = {
|
||||
|
||||
if (params.sendreally) {
|
||||
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
|
||||
const myparam = {...params};
|
||||
const myparam = { ...params };
|
||||
risult = await tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag,
|
||||
myparam.actions, myparam.id).
|
||||
then(ris => {
|
||||
myparam.actions, myparam.id).
|
||||
then(ris => {
|
||||
|
||||
}).
|
||||
catch(e => {
|
||||
console.error(e.message);
|
||||
});
|
||||
}).
|
||||
catch(e => {
|
||||
console.error(e.message);
|
||||
});
|
||||
|
||||
}
|
||||
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.TELEGRAM)) {
|
||||
@@ -429,7 +429,7 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
SendMsgToAll: async function(idapp, params) {
|
||||
SendMsgToAll: async function (idapp, params) {
|
||||
|
||||
params.typemsg = shared_consts.TypeMsg.SEND_TO_ALL;
|
||||
params.sendreally = true;
|
||||
@@ -438,4 +438,167 @@ module.exports = {
|
||||
return await this.SendMsgToParam(idapp, params);
|
||||
},
|
||||
|
||||
replaceUsername: async function (idapp, search_username, replace_username) {
|
||||
|
||||
if (!search_username || !replace_username) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
let ris = null;
|
||||
console.log('replaceUsername = ', search_username, replace_username);
|
||||
|
||||
ris = await User.findOneAndUpdate({ idapp, username: search_username }, { $set: { username: replace_username } });
|
||||
console.log('username result = ', ris);
|
||||
|
||||
tools.move(server_constants.DIR_UPLOAD + 'profile/' + search_username, server_constants.DIR_UPLOAD + 'profile/' + replace_username, function callback() {
|
||||
console.log(' ... moved dir', server_constants.DIR_UPLOAD + 'profile/' + search_username, server_constants.DIR_UPLOAD + 'profile/' + replace_username);
|
||||
});
|
||||
|
||||
ris = await User.findOneAndUpdate({ idapp, 'profile.username_telegram': search_username }, { $set: { 'profile.username_telegram': replace_username } });
|
||||
console.log('profile.username_telegram result = ', ris);
|
||||
|
||||
ris = await User.updateMany({ idapp, aportador_iniziale: search_username },
|
||||
{
|
||||
$set:
|
||||
{ aportador_iniziale: replace_username }
|
||||
});
|
||||
console.log('aportador_iniziale result = ', ris);
|
||||
|
||||
ris = await User.updateMany({ idapp, username_who_report: search_username },
|
||||
{
|
||||
$set:
|
||||
{ username_who_report: replace_username }
|
||||
});
|
||||
console.log('username_who_report result = ', ris);
|
||||
|
||||
ris = await User.updateMany({ idapp, aportador_solidario: search_username },
|
||||
{
|
||||
$set:
|
||||
{ aportador_solidario: replace_username }
|
||||
});
|
||||
console.log('aportador_solidario result = ', ris);
|
||||
|
||||
ris = await User.updateMany({ idapp, 'profile.friends.username': search_username },
|
||||
{
|
||||
$set:
|
||||
{ 'profile.friends.$.username': replace_username }
|
||||
});
|
||||
console.log('friends.username result = ', ris);
|
||||
|
||||
ris = await User.updateMany({ idapp, 'profile.req_friends.username': search_username },
|
||||
{
|
||||
$set:
|
||||
{ 'profile.req_friends.$.username': replace_username }
|
||||
});
|
||||
console.log('req_friends.username result = ', ris);
|
||||
|
||||
ris = await User.updateMany({ idapp, 'profile.handshake.username': search_username },
|
||||
{
|
||||
$set:
|
||||
{ 'profile.handshake.$.username': replace_username }
|
||||
});
|
||||
console.log('handshake.username result = ', ris);
|
||||
|
||||
ris = await Circuit.updateMany({ idapp, 'admins.username': search_username },
|
||||
{ $set: { 'admins.$.username': replace_username } });
|
||||
console.log('Circuit.admins.username result = ', ris);
|
||||
|
||||
ris = await Circuit.updateMany({ idapp, 'req_users.username': search_username },
|
||||
{ $set: { 'req_users.$.username': replace_username } });
|
||||
console.log('Circuit.req_users.username result = ', ris);
|
||||
|
||||
ris = await Circuit.updateMany({ idapp, 'refused_users.username': search_username },
|
||||
{ $set: { 'refused_users.$.username': replace_username } });
|
||||
console.log('Circuit.refused_users.username result = ', ris);
|
||||
|
||||
ris = await Account.updateMany({ idapp, 'username': search_username },
|
||||
{ $set: { 'username': replace_username } });
|
||||
console.log('Account.username result = ', ris);
|
||||
|
||||
ris = await MyGroup.updateMany({ idapp, 'admins.username': search_username },
|
||||
{ $set: { 'admins.$.username': replace_username } });
|
||||
console.log('MyGroup.refused_users.username result = ', ris);
|
||||
|
||||
ris = await MyGroup.updateMany({ idapp, 'req_users.username': search_username },
|
||||
{ $set: { 'req_users.$.username': replace_username } });
|
||||
console.log('MyGroup.req_users.username result = ', ris);
|
||||
|
||||
// MyGroup.refused_users.username
|
||||
ris = await MyGroup.updateMany({ idapp, 'refused_users.username': search_username },
|
||||
{ $set: { 'refused_users.$.username': replace_username } });
|
||||
console.log('MyGroup.refused_users.username result = ', ris);
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
},
|
||||
ReplaceCircuitName: async function (idapp, search_circuitname, replace_circuitname) {
|
||||
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
|
||||
if (!search_circuitname || !replace_circuitname) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
let ris = null;
|
||||
console.log('ReplaceCircuitName = ', search_circuitname, replace_circuitname);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -11,6 +11,10 @@ module.exports = {
|
||||
QUERYTYPE_REFUSED_USER_CIRCUIT: 12,
|
||||
QUERYTYPE_LIST_MOVEMENTS: 15,
|
||||
QUERYTYPE_LIST_ALLMOVEMENTS: 16,
|
||||
QUERYTYPE_LIST_MOVEMENTS_GROUPNAME: 17,
|
||||
QUERYTYPE_LIST_MOVEMENTS_CONTOCOM: 18,
|
||||
QUERYTYPE_GROUP_CIRCUIT: 20,
|
||||
QUERYTYPE_REFUSED_GROUP_CIRCUIT: 22,
|
||||
// ---------------------
|
||||
|
||||
FILTER_EXTRALIST_NOT_REGISTERED: 1,
|
||||
@@ -37,6 +41,7 @@ module.exports = {
|
||||
FILTER_USER_NO_VERIFIED_APORTADOR: 2097152,
|
||||
FILTER_USER_SI_TELEGRAM_ID: 4194304,
|
||||
FILTER_USER_WITHOUT_USERNAME_TELEGRAM: 8388608,
|
||||
FILTER_USER_PROVINCE: 16777216,
|
||||
|
||||
OPTIONS_SEARCH_ONLY_FULL_WORDS: 1,
|
||||
OPTIONS_SEARCH_USER_ONLY_FULL_WORDS: 2,
|
||||
@@ -46,9 +51,11 @@ module.exports = {
|
||||
SETTRUST: 121,
|
||||
REQFRIEND: 125,
|
||||
SETFRIEND: 132,
|
||||
SETHANDSHAKE: 133,
|
||||
REMOVE_FROM_MYFRIENDS: 144,
|
||||
REFUSE_REQ_FRIEND: 145,
|
||||
CANCEL_REQ_FRIEND: 146,
|
||||
REMOVE_FROM_MYHANDSHAKE: 147,
|
||||
BLOCK_USER: 155,
|
||||
UNBLOCK_USER: 156,
|
||||
REPORT_USER: 158,
|
||||
@@ -70,6 +77,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
CIRCUITCMD: {
|
||||
CREATE: 1001,
|
||||
REQ: 2000,
|
||||
SET: 2001,
|
||||
REMOVE_FROM_MYLIST: 2144,
|
||||
@@ -130,6 +138,7 @@ module.exports = {
|
||||
|
||||
TABLES_USER_INCLUDE_MY: ['mygroups', 'circuits'],
|
||||
TABLES_GETCOMPLETEREC: ['myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||
TABLES_INSERT_ALMOST_ONE_TO_ENABLE_CIRCUIT: ['myskills', 'myhosps', 'mygoods'],
|
||||
//++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'],
|
||||
@@ -137,6 +146,8 @@ module.exports = {
|
||||
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'circuits'],
|
||||
|
||||
TABLES_ADV_NOTIFICATION: ['myskills', 'myhosps', 'mygoods'],
|
||||
TABLES_ORDER_DATE_UPDATED: ['myskills', 'myhosps', 'mygoods'],
|
||||
TABLES_ORDER_DESCR: ['mygroups'],
|
||||
TABLES_EVENTS_NOTIFICATION: ['mybachecas'],
|
||||
TABLES_GROUPS_NOTIFICATION: ['mygroups'],
|
||||
TABLES_CIRCUITS_NOTIFICATION: ['circuits'],
|
||||
@@ -283,6 +294,7 @@ module.exports = {
|
||||
REGISTRATION: 6,
|
||||
RICHIESTA_GRUPPO: 10,
|
||||
RICHIESTA_AMICIZIA: 15,
|
||||
RICHIESTA_HANDSHAKE: 16,
|
||||
RICHIESTA_CIRCUIT: 20,
|
||||
},
|
||||
|
||||
@@ -338,6 +350,8 @@ module.exports = {
|
||||
STATUS_FRIENDS_ACCEPTED: 1,
|
||||
STATUS_FRIENDS_REFUSED: 2,
|
||||
STATUS_FRIENDS_REPORTED: 3,
|
||||
STATUS_HANDSHAKE_ACCEPTED: 10,
|
||||
STATUS_HANDSHAKE_REFUSED: 11,
|
||||
},
|
||||
|
||||
GroupsNotifs: {
|
||||
@@ -350,6 +364,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
CircuitsNotif: {
|
||||
STATUS_NONE: 0,
|
||||
STATUS_NEW: 51,
|
||||
STATUS_ACCEPTED: 53,
|
||||
STATUS_REFUSED: 54,
|
||||
@@ -417,6 +432,9 @@ module.exports = {
|
||||
TYPEDIR_MSGS: 7,
|
||||
ID_MSGS_NEW_REC: 1,
|
||||
|
||||
TYPEDIR_HANDSHAKE: 10,
|
||||
ID_HANDSHAKE_ACCEPTED: 2,
|
||||
|
||||
TYPEDIR_TEST: 444,
|
||||
ID_TEST_NEW_REC: 1,
|
||||
},
|
||||
@@ -473,24 +491,24 @@ module.exports = {
|
||||
|
||||
DEFAULT_NOTIFS_USER: [
|
||||
{
|
||||
"dir": 1,
|
||||
"value": 24
|
||||
'dir': 1,
|
||||
'value': 24
|
||||
},
|
||||
{
|
||||
"dir": 2,
|
||||
"value": 1
|
||||
'dir': 2,
|
||||
'value': 1
|
||||
},
|
||||
{
|
||||
"dir": 3,
|
||||
"value": 1
|
||||
'dir': 3,
|
||||
'value': 1
|
||||
},
|
||||
{
|
||||
"dir": 4,
|
||||
"value": 1
|
||||
'dir': 4,
|
||||
'value': 1
|
||||
},
|
||||
{
|
||||
"dir": 5,
|
||||
"value": 1
|
||||
'dir': 5,
|
||||
'value': 1
|
||||
}
|
||||
],
|
||||
|
||||
@@ -501,4 +519,11 @@ module.exports = {
|
||||
FASE3_MONETA_ABILITATA: 3,
|
||||
},
|
||||
|
||||
CIRCUIT_PARAMS: {
|
||||
SCOPERTO_MIN_GRP: 200,
|
||||
SCOPERTO_MAX_GRP: 400,
|
||||
SCOPERTO_MIN_CONTO_COMUNITARIO: 500,
|
||||
SCOPERTO_MAX_CONTO_COMUNITARIO: 1000,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
9
test.http
Normal file
9
test.http
Normal file
@@ -0,0 +1,9 @@
|
||||
### Init:
|
||||
get http://localhost:3000/
|
||||
|
||||
### Create a new
|
||||
get https://splendidus.it:3000/
|
||||
|
||||
### Create a new
|
||||
get https://mail.freeplanet.app:3000/
|
||||
|
||||
Reference in New Issue
Block a user