Circuits...
Circuits Fido e Max Qta Fixed error eslint: 7.0.0 is OK
This commit is contained in:
2
.env
2
.env
@@ -8,7 +8,7 @@ URLBASE_APP1=http://localhost
|
||||
PORT_APP1=8080
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
SIGNCODE=abc123
|
||||
DEBUG=0
|
||||
DEBUG=false
|
||||
LOCALE=1
|
||||
DELAY_SENDEMAIL=2000
|
||||
VAPI_KEY_SUBJECT=mailto:paolo@freeplanet.app
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Freeplanet_serverside
|
||||
|
||||
- Node JS (ver. 16.14.0 or up)
|
||||
- Node JS (ver. 16.17.0 or up)
|
||||
|
||||
## Install the dependencies
|
||||
```bash
|
||||
|
||||
57
package.json
57
package.json
@@ -12,27 +12,27 @@
|
||||
"test-watch": "nodemon --exec 'npm test'"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.14.0"
|
||||
"node": "^16.17.0"
|
||||
},
|
||||
"author": "Paolo Arena",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"basic-ftp": "^4.6.6",
|
||||
"basic-ftp": "^5.0.2",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"bluebird": "^3.7.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"body-parser": "^1.20.0",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"cors": "^2.8.5",
|
||||
"country-codes-list": "^1.6.8",
|
||||
"crypto-js": "^4.1.1",
|
||||
"csurf": "^1.11.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"ejs": "^3.1.6",
|
||||
"email-templates": "^8.0.8",
|
||||
"express": "^4.17.1",
|
||||
"formidable": "^1.2.2",
|
||||
"i18n": "^0.13.3",
|
||||
"image-downloader": "^4.1.0",
|
||||
"dotenv": "^16.0.2",
|
||||
"ejs": "^3.1.8",
|
||||
"email-templates": "^10.0.1",
|
||||
"express": "^4.18.1",
|
||||
"formidable": "^2.0.1",
|
||||
"i18n": "^0.15.0",
|
||||
"image-downloader": "^4.3.0",
|
||||
"internet-available": "^1.0.0",
|
||||
"jade": "^1.11.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
@@ -40,35 +40,36 @@
|
||||
"mongodb": "^4.4.1",
|
||||
"mongoose": "^5.10.19",
|
||||
"mysql": "^2.18.1",
|
||||
"node-cron": "^3.0.0",
|
||||
"node-cron": "^3.0.2",
|
||||
"node-emoji": "^1.11.0",
|
||||
"node-image-resizer": "^1.0.0",
|
||||
"node-pre-gyp": "^0.14.0",
|
||||
"node-telegram-bot-api": "^0.56.0",
|
||||
"nodemailer": "^6.6.3",
|
||||
"preview-email": "^3.0.5",
|
||||
"node-telegram-bot-api": "^0.59.0",
|
||||
"nodemailer": "^6.7.8",
|
||||
"npm-check-updates": "^16.1.0",
|
||||
"preview-email": "^3.0.7",
|
||||
"pug": "^3.0.2",
|
||||
"rate-limiter-flexible": "^2.2.4",
|
||||
"save": "^2.4.0",
|
||||
"sharp": "^0.30.1",
|
||||
"superagent": "^6.1.0",
|
||||
"url-parse": "^1.5.3",
|
||||
"validator": "^13.6.0",
|
||||
"web-push": "^3.4.5",
|
||||
"rate-limiter-flexible": "^2.3.9",
|
||||
"save": "^2.5.0",
|
||||
"sharp": "0.30.0",
|
||||
"superagent": "^8.0.0",
|
||||
"url-parse": "^1.5.10",
|
||||
"validator": "^13.7.0",
|
||||
"web-push": "^3.5.0",
|
||||
"xoauth2": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browser-sync": "^2.27.5",
|
||||
"expect": "^27.2.1",
|
||||
"browser-sync": "^2.27.10",
|
||||
"expect": "^29.0.2",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-inline-css": "^4.0.0",
|
||||
"gulp-pug": "^5.0.0",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-sass": "^5.0.0",
|
||||
"jest": "^27.2.1",
|
||||
"mocha": "^9.1.1",
|
||||
"nodemon": "^2.0.12",
|
||||
"supertest": "^6.1.6"
|
||||
"gulp-sass": "^5.1.0",
|
||||
"jest": "^29.0.2",
|
||||
"mocha": "^10.0.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"supertest": "^6.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
@@ -9,17 +9,16 @@ mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
mongoose.set('debug', false);
|
||||
mongoose.set('debug', process.env.DEBUG);
|
||||
|
||||
const options = {
|
||||
// user: process.env.UDB,
|
||||
// pass: process.env.PDB,
|
||||
// useMongoClient: true,
|
||||
// useNewUrlParser: true, // non supportato
|
||||
// useMongoClient: false,
|
||||
useNewUrlParser: true,
|
||||
useFindAndModify: false,
|
||||
useCreateIndex: true,
|
||||
// useFindAndModify: false,
|
||||
// useCreateIndex: true,
|
||||
useUnifiedTopology: true,
|
||||
|
||||
promiseLibrary: require('bluebird'),
|
||||
|
||||
@@ -50,5 +50,6 @@
|
||||
"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 %s %s."
|
||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando %s %s.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s."
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Account is a User's single Circuit
|
||||
*/
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -35,6 +35,12 @@ const AccountSchema = new Schema({
|
||||
deperibile: {
|
||||
type: Boolean,
|
||||
},
|
||||
fidoConcesso: {
|
||||
type: Number,
|
||||
},
|
||||
qta_maxConcessa: {
|
||||
type: Number,
|
||||
},
|
||||
importo_iniziale: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -138,11 +144,14 @@ AccountSchema.statics.getUserAccounts = async function(idapp, username) {
|
||||
},
|
||||
},
|
||||
},
|
||||
/*
|
||||
{
|
||||
$project: {
|
||||
"circuit.name": 1,
|
||||
},
|
||||
},
|
||||
|
||||
*/
|
||||
];
|
||||
|
||||
ris = await this.aggregate(aggr1);
|
||||
@@ -164,7 +173,7 @@ AccountSchema.statics.addtoSaldo = async function(id, amount) {
|
||||
if (myaccount) {
|
||||
myaccount.saldo = myaccount.saldo + amount;
|
||||
myaccount.date_updated = new Date();
|
||||
return myaccount.save();
|
||||
return await myaccount.save();
|
||||
|
||||
}
|
||||
|
||||
@@ -174,6 +183,8 @@ AccountSchema.statics.addtoSaldo = async function(id, amount) {
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, username, circuitId, createifnotexist) {
|
||||
const Account = this;
|
||||
|
||||
const {Circuit} = require('../models/circuit');
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
@@ -183,6 +194,8 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
|
||||
circuitId,
|
||||
};
|
||||
|
||||
const mycircuit = await Circuit.getCircuitById(circuitId);
|
||||
|
||||
let myaccount = await Account.findOne(myquery).lean();
|
||||
|
||||
if (!myaccount && createifnotexist) {
|
||||
@@ -191,11 +204,13 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
|
||||
username,
|
||||
circuitId,
|
||||
deperibile: false,
|
||||
fidoConcesso: mycircuit.fido_scoperto_default,
|
||||
qta_maxConcessa: mycircuit.qta_max_default,
|
||||
importo_iniziale: 0,
|
||||
saldo: 0,
|
||||
});
|
||||
|
||||
return myaccount.save();
|
||||
return await myaccount.save();
|
||||
}
|
||||
|
||||
return myaccount;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -46,7 +46,7 @@ AdTypeSchema.statics.findAllIdApp = async function(idapp) {
|
||||
{$sort: {_id: 1}},
|
||||
];
|
||||
|
||||
return AdType.aggregate(query).then((arrrec) => {
|
||||
return await AdType.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -46,7 +46,7 @@ AdTypeGoodSchema.statics.findAllIdApp = async function(idapp) {
|
||||
{$sort: {_id: 1}},
|
||||
];
|
||||
|
||||
return AdTypeGood.aggregate(query).then((arrrec) => {
|
||||
return await AdTypeGood.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -61,8 +61,8 @@ BotSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
BotSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
schermi
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ BotSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
const myfind = {idapp};
|
||||
|
||||
return Bot.find(myfind).sort({page: 1, lang: 1, riga: 1, index: 1}).lean();
|
||||
return await Bot.find(myfind).sort({page: 1, lang: 1, riga: 1, index: 1}).lean();
|
||||
};
|
||||
|
||||
const MyBot = mongoose.model('Bot', BotSchema);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
@@ -98,7 +98,7 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
|
||||
|
||||
const modify_at = new Date();
|
||||
|
||||
return Cart.findOneAndUpdate({_id: cartId}, {
|
||||
return await Cart.findOneAndUpdate({_id: cartId}, {
|
||||
$set: {
|
||||
items,
|
||||
totalPrice,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -60,7 +60,7 @@ CatGrpSchema.statics.findAllIdApp = async function (idapp) {
|
||||
{ $sort: { descr: 1 } }
|
||||
];
|
||||
|
||||
return CatGrp
|
||||
return await CatGrp
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -31,7 +31,7 @@ const CfgServerSchema = new Schema({
|
||||
|
||||
CfgServerSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -15,11 +15,7 @@ mongoose.plugin(schema => {
|
||||
|
||||
const CircuitSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
},
|
||||
Num: {
|
||||
type: Number,
|
||||
unique: true,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
@@ -84,6 +80,9 @@ const CircuitSchema = new Schema({
|
||||
fido_scoperto_default: {
|
||||
type: Number,
|
||||
},
|
||||
qta_max_default: {
|
||||
type: Number,
|
||||
},
|
||||
data_costituz: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -128,9 +127,18 @@ const CircuitSchema = new Schema({
|
||||
date: {type: Date},
|
||||
},
|
||||
],
|
||||
img_logo: {
|
||||
type: String,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
req_users: [
|
||||
{
|
||||
_id: false,
|
||||
@@ -147,19 +155,19 @@ const CircuitSchema = new Schema({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
}, );
|
||||
});
|
||||
|
||||
CircuitSchema.pre('save', async function(next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await Circuit.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc.Num === 0)
|
||||
this.Num = 1;
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this.Num = myrec._doc.Num + 1;
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this.Num = 1;
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
@@ -168,7 +176,6 @@ CircuitSchema.pre('save', async function(next) {
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
CircuitSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const Circuit = this;
|
||||
|
||||
@@ -181,23 +188,6 @@ CircuitSchema.statics.findAllIdApp = async function(idapp) {
|
||||
});
|
||||
};
|
||||
|
||||
CircuitSchema.pre('save', async function(next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await Circuit.findOne().limit(1).sort({Num: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc.Num === 0)
|
||||
this.Num = 1;
|
||||
else
|
||||
this.Num = myrec._doc.Num + 1;
|
||||
|
||||
} else {
|
||||
this.Num = 1;
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
CircuitSchema.statics.getFieldsForSearch = function() {
|
||||
return [
|
||||
{field: 'nome_circuito', type: tools.FieldType.string},
|
||||
@@ -230,7 +220,7 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
symbol: 1,
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
img_logo: 1,
|
||||
photos: 1,
|
||||
admins: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
@@ -241,11 +231,10 @@ CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
// Rimuovi dagli Admin del Circuito
|
||||
CircuitSchema.statics.removeAdminOfMyCircuit = async function(idapp, username, name) {
|
||||
|
||||
return Circuit.updateOne({idapp, name},
|
||||
return await Circuit.updateOne({idapp, name},
|
||||
{$pull: {admins: {username: {$in: [username]}}}});
|
||||
};
|
||||
|
||||
|
||||
CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
return {
|
||||
Num: 1,
|
||||
@@ -262,7 +251,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
symbol: 1,
|
||||
abbrev: 1,
|
||||
data_costituz: 1,
|
||||
img_logo: 1,
|
||||
photos: 1,
|
||||
admins: 1,
|
||||
createdBy: 1,
|
||||
date_created: 1,
|
||||
@@ -379,9 +368,24 @@ CircuitSchema.statics.getCircuitByName = async function(idapp, name) {
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitById = async function(circuitId) {
|
||||
|
||||
const myfind = {
|
||||
circuitId
|
||||
};
|
||||
|
||||
try {
|
||||
return await Circuit.findOne(myfind).lean();
|
||||
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.deleteCircuit = async function(idapp, usernameOrig, name) {
|
||||
console.log('Circuito ' + name + ' rimosso da ' + usernameOrig);
|
||||
return Circuit.findOneAndRemove({idapp, name});
|
||||
return await Circuit.findOneAndRemove({idapp, name});
|
||||
};
|
||||
|
||||
CircuitSchema.statics.sendCoins = async function(idapp, usernameOrig, extrarec) {
|
||||
@@ -391,18 +395,21 @@ CircuitSchema.statics.sendCoins = async function(idapp, usernameOrig, extrarec)
|
||||
const {Account} = require('../models/account');
|
||||
|
||||
try {
|
||||
const reccircuit = Circuit.getCircuitByName(extrarec.circuitname);
|
||||
const reccircuit = await Circuit.getCircuitByName(idapp, extrarec.circuitname);
|
||||
|
||||
const myqty = extrarec.qty;
|
||||
if (reccircuit) {
|
||||
const myqty = extrarec.qty;
|
||||
|
||||
const accountdest = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, reccircuit._id, true);
|
||||
const accountorig = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, reccircuit._id, true);
|
||||
const accountdest = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, reccircuit._id, true);
|
||||
const accountorig = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, reccircuit._id, true);
|
||||
|
||||
// Add a Transaction !
|
||||
Movement.addMov(accountorig, accountdest, myqty, extrarec.causal);
|
||||
// Add a Transaction !
|
||||
return await Movement.addMov(idapp, accountorig, accountdest, myqty, extrarec.causal);
|
||||
|
||||
}catch (e) {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err sendCoins', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -410,14 +417,14 @@ CircuitSchema.statics.sendCoins = async function(idapp, usernameOrig, extrarec)
|
||||
// Rimuovo la Richiesta del Circuito
|
||||
CircuitSchema.statics.removeReqCircuit = async function(idapp, username, name) {
|
||||
|
||||
return Circuit.updateOne({idapp, name},
|
||||
return await Circuit.updateOne({idapp, name},
|
||||
{$pull: {req_users: {username: {$in: [username]}}}});
|
||||
};
|
||||
|
||||
// Aggiungi agli utenti Rifiutati del Circuito
|
||||
CircuitSchema.statics.refuseReqCircuit = async function(idapp, username, name) {
|
||||
|
||||
return Circuit.updateOne({idapp, name},
|
||||
return await Circuit.updateOne({idapp, name},
|
||||
{
|
||||
$push:
|
||||
{
|
||||
@@ -430,7 +437,6 @@ CircuitSchema.statics.refuseReqCircuit = async function(idapp, username, name) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||
|
||||
module.exports = {Circuit};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const escapeStringRegexp = require('escape-string-regexp');
|
||||
@@ -185,7 +185,7 @@ CitySchema.statics.executeQueryPickup = async function(idapp, params) {
|
||||
CitySchema.statics.findAllIdApp = async function(idapp) {
|
||||
const myfind = {};
|
||||
|
||||
return City.find(myfind);
|
||||
return await City.find(myfind);
|
||||
};
|
||||
|
||||
const City = mongoose.model('City', CitySchema);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -35,7 +35,7 @@ ContribtypeSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
ContribtypeSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ ContribtypeSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return Contribtype.find(myfind, (err, arrrec) => {
|
||||
return await Contribtype.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -63,7 +63,7 @@ DisciplineSchema.statics.findAllIdApp = async function (idapp) {
|
||||
{ $sort: { order: 1 } }
|
||||
];
|
||||
|
||||
return Discipline
|
||||
return await Discipline
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
@@ -100,7 +100,7 @@ DisciplineSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
DisciplineSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var bcrypt = require('bcryptjs');
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const validator = require('validator');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const _ = require('lodash');
|
||||
@@ -227,14 +227,14 @@ ExtraListSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return ExtraList.find(myfind, (err, arrrec) => {
|
||||
return await ExtraList.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -38,7 +38,7 @@ GoodSchema.statics.findAllIdApp = async function (idapp) {
|
||||
{ $sort: { descr: 1 } }
|
||||
];
|
||||
|
||||
const res = Good
|
||||
const res = await Good
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const bcrypt = require('bcryptjs');
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const validator = require('validator');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const _ = require('lodash');
|
||||
@@ -312,7 +312,7 @@ GraduatoriaSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return Graduatoria.find(myfind, (err, arrrec) => {
|
||||
return await Graduatoria.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
@@ -381,7 +381,7 @@ GraduatoriaSchema.statics.getPosizioneInGraduatoria = async function (idapp, ind
|
||||
|
||||
const totposiz = await Graduatoria.countDocuments({ idapp });
|
||||
|
||||
return Graduatoria.findOne({ idapp, username, ind_order, num_tess }).then((rec) => {
|
||||
return await Graduatoria.findOne({ idapp, username, ind_order, num_tess }).then((rec) => {
|
||||
|
||||
if (!!rec) {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -58,7 +58,7 @@ module.exports.executeQueryTable = function (idapp, params) {
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return Hours.find(myfind);
|
||||
return await Hours.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.correggiHours = async function (idapp) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -55,7 +55,7 @@ LevelSchema.statics.findAllIdApp = async function(idapp) {
|
||||
{$sort: {_id: 1}},
|
||||
];
|
||||
|
||||
return Level.aggregate(query).then((arrrec) => {
|
||||
return await Level.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -7,6 +7,7 @@ mongoose.level = 'F';
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const {Account} = require('../models/account');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -17,8 +18,11 @@ const MovementSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
transactionDate: {
|
||||
type: Date
|
||||
type: Date,
|
||||
},
|
||||
accountFromId: {
|
||||
type: Number,
|
||||
@@ -42,7 +46,7 @@ const MovementSchema = new Schema({
|
||||
type: Number,
|
||||
},
|
||||
expiringDate: {
|
||||
type: Date
|
||||
type: Date,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -51,7 +55,7 @@ MovementSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
const myfind = {idapp};
|
||||
|
||||
return MyMovement.find(myfind, (err, arrrec) => {
|
||||
return await MyMovement.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
@@ -85,28 +89,150 @@ MovementSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
MovementSchema.statics.addMov = async function(accountFromId, accountToId, amount, causal) {
|
||||
MovementSchema.statics.addMov = async function(idapp, accountFromId, accountToId, amount, causal) {
|
||||
|
||||
const {Account} = require('../models/account');
|
||||
try {
|
||||
let mymov = Movement(
|
||||
{
|
||||
idapp,
|
||||
transactionDate: new Date(),
|
||||
accountFromId: accountFromId._id,
|
||||
accountToId: accountToId._id,
|
||||
amount,
|
||||
causal,
|
||||
residual: 0,
|
||||
// expiringDate:
|
||||
},
|
||||
);
|
||||
|
||||
let mymov = Movement(
|
||||
{
|
||||
transactionDate: new Date(),
|
||||
accountFromId,
|
||||
accountToId,
|
||||
amount,
|
||||
causal,
|
||||
residual: 0,
|
||||
// expiringDate:
|
||||
}
|
||||
);
|
||||
// Update saldo dell'Account
|
||||
Account.addtoSaldo(accountToId, amount);
|
||||
|
||||
// Update saldo dell'Account
|
||||
Account.addtoSaldo(accountToId, amount);
|
||||
Account.addtoSaldo(accountFromId, -amount);
|
||||
|
||||
Account.addtoSaldo(accountFromId, -amount);
|
||||
return await mymov.save();
|
||||
} catch (e) {
|
||||
console.error('Error in addMov', e.message);
|
||||
}
|
||||
};
|
||||
|
||||
return mymov.save();
|
||||
MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false);
|
||||
|
||||
if (myaccount) {
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
$or: [
|
||||
{accountFromId: myaccount._id},
|
||||
{accountToId: myaccount._id}],
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
localField: 'accountFromId',
|
||||
foreignField: '_id',
|
||||
as: 'accfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accfrom'},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accfrom.username', idapp: '$accfrom.idapp'},
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$userfrom'},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
localField: 'accountToId',
|
||||
foreignField: '_id',
|
||||
as: 'accto',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accto'},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accto.username', idapp: '$accto.idapp'},
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userto',
|
||||
},
|
||||
},
|
||||
{$unwind: '$userto'},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
return aggr1;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||
const MyMovement = this;
|
||||
|
||||
const myquery = await MyMovement.getQueryMovsByCircuitId(idapp, username, circuitId);
|
||||
|
||||
if (myquery) {
|
||||
ris = await MyMovement.aggregate(myquery);
|
||||
|
||||
return ris;
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
const Movement = mongoose.model('Movement', MovementSchema);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -113,7 +113,7 @@ MyBachecaSchema.statics.findAllIdApp = async function(idapp) {
|
||||
{$sort: {descr: 1}},
|
||||
];
|
||||
|
||||
return MyBacheca.aggregate(query).then((arrrec) => {
|
||||
return await MyBacheca.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -114,7 +114,7 @@ MyGoodSchema.statics.findAllIdApp = async function(idapp) {
|
||||
{$sort: {descr: 1}},
|
||||
];
|
||||
|
||||
return MyGood.aggregate(query).then((arrrec) => {
|
||||
return await MyGood.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -177,14 +177,14 @@ MyGroupSchema.statics.findAllGroups = async function(idapp) {
|
||||
// Rimuovo la Richiesta del Gruppo
|
||||
MyGroupSchema.statics.removeReqGroup = async function(idapp, username, groupnameDest) {
|
||||
|
||||
return MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
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) {
|
||||
|
||||
return MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{
|
||||
$push:
|
||||
{
|
||||
@@ -200,7 +200,7 @@ MyGroupSchema.statics.refuseReqGroup = async function(idapp, username, groupname
|
||||
// Aggiungi agli Admin del Gruppo
|
||||
MyGroupSchema.statics.addToAdminOfMyGroup = async function(idapp, username, groupnameDest) {
|
||||
|
||||
return MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{
|
||||
$push:
|
||||
{
|
||||
@@ -216,7 +216,7 @@ MyGroupSchema.statics.addToAdminOfMyGroup = async function(idapp, username, grou
|
||||
// Rimuovi dagli Admin del Gruppo
|
||||
MyGroupSchema.statics.removeAdminOfMyGroup = async function(idapp, username, groupnameDest) {
|
||||
|
||||
return MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{$pull: {admins: {username: {$in: [username]}}}});
|
||||
};
|
||||
|
||||
@@ -338,7 +338,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
|
||||
MyGroupSchema.statics.deleteGroup = async function(idapp, usernameOrig, groupname) {
|
||||
console.log('Gruppo ' + groupname + ' rimosso da ' + usernameOrig);
|
||||
return MyGroup.findOneAndRemove({idapp, groupname});
|
||||
return await MyGroup.findOneAndRemove({idapp, groupname});
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -119,7 +119,7 @@ MyHospSchema.statics.findAllIdApp = async function(idapp) {
|
||||
{$sort: {descr: 1}},
|
||||
];
|
||||
|
||||
return MyHosp.aggregate(query).then((arrrec) => {
|
||||
return await MyHosp.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -140,7 +140,7 @@ MyPageSchema.statics.findAllIdApp = async function (idapp) {
|
||||
});
|
||||
};
|
||||
|
||||
MyPageSchema.statics.findOnlyStruttRec = async function (idapp) {
|
||||
MyPageSchema.statics.findOnlyStruttRec = function (idapp) {
|
||||
const MyPage = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
@@ -169,7 +169,7 @@ MyPageSchema.statics.findInternalPages = async function (idapp) {
|
||||
internalpage: { $exists: true, $eq: true }
|
||||
};
|
||||
|
||||
return MyPage.find(myfind, {
|
||||
return await MyPage.find(myfind, {
|
||||
title: 1,
|
||||
path: 1,
|
||||
onlyif_logged: 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -117,7 +117,7 @@ MySkillSchema.statics.findAllIdApp = async function(idapp) {
|
||||
{$sort: {descr: 1}},
|
||||
];
|
||||
|
||||
return MySkill.aggregate(query).then((arrrec) => {
|
||||
return await MySkill.aggregate(query).then((arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -140,7 +140,7 @@ NewstosentSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return Newstosent.find(myfind, (err, arrrec) => {
|
||||
return await Newstosent.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -103,7 +103,7 @@ OperatorSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
OperatorSchema.statics.findAllIdApp = async function (idapp) {
|
||||
OperatorSchema.statics.findAllIdApp = function (idapp) {
|
||||
const Operator = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
@@ -50,7 +50,7 @@ var OrdersCart = module.exports = mongoose.model('OrdersCart', OrdersCartSchema)
|
||||
module.exports.findAllIdApp = async function (idapp, userId) {
|
||||
const myfind = { idapp, userId };
|
||||
|
||||
return await OrdersCart.find(myfind);
|
||||
return await await OrdersCart.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -38,7 +38,7 @@ PaymentTypeSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return PaymentType.find(myfind, (err, arrrec) => {
|
||||
return await PaymentType.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -50,7 +50,7 @@ PermissionSchema.statics.findAllIdApp = async function () {
|
||||
|
||||
const myfind = { };
|
||||
|
||||
return Permission.find(myfind, (err, arrrec) => {
|
||||
return await Permission.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -373,7 +373,7 @@ ProjectSchema.statics.enabletoModify = async function (userId, idProj) {
|
||||
|
||||
let obj = [];
|
||||
|
||||
return Project.findOne({
|
||||
return await Project.findOne({
|
||||
'_id': idProj,
|
||||
$or: [{
|
||||
privacywrite: { $ne: server_constants.Privacy.onlyme },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const escapeStringRegexp = require('escape-string-regexp');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -60,7 +60,7 @@ SectorGoodSchema.statics.findAllIdApp = async function (idapp) {
|
||||
{ $sort: { descr: 1 } }
|
||||
];
|
||||
|
||||
return SectorGood
|
||||
return await SectorGood
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -308,6 +308,9 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', recnotif.paramsObj.username_action, recnotif.paramsObj.extrarec.qty, recnotif.paramsObj.extrarec.symbol);
|
||||
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, recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.username_action);
|
||||
tag = 'sendcoin';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,6 +463,12 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_BLOCKED;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_DELETED;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_ACCEPTED;
|
||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
|
||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_REFUSED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +520,7 @@ sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
||||
if (!myrecout)
|
||||
return null;
|
||||
|
||||
return myrecout.save().then((writeresult) => {
|
||||
return await myrecout.save().then((writeresult) => {
|
||||
let idobj = writeresult._id;
|
||||
return SendNotif.findById(idobj).lean().then(async (recnotif) => {
|
||||
return recnotif;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -84,7 +84,7 @@ SettingsSchema.statics.getValDbSettings = function (idapp, key, def) {
|
||||
|
||||
SettingsSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -6,7 +6,7 @@ const tools = require('../tools/general');
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
mongoose.set('debug', false);
|
||||
mongoose.set('debug', process.env.DEBUG);
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -38,7 +38,7 @@ SkillSchema.statics.findAllIdApp = async function (idapp) {
|
||||
{ $sort: { descr: 1 } }
|
||||
];
|
||||
|
||||
return Skill
|
||||
return await Skill
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -55,7 +55,7 @@ StatusSkillSchema.statics.findAllIdApp = async function (idapp) {
|
||||
{ $sort: { descr: 1 } }
|
||||
];
|
||||
|
||||
return StatusSkill
|
||||
return await StatusSkill
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -38,7 +38,7 @@ SubSkillSchema.statics.findAllIdApp = async function (idapp) {
|
||||
{ $sort: { descr: 1 } }
|
||||
];
|
||||
|
||||
return SubSkill
|
||||
return await SubSkill
|
||||
.aggregate(query)
|
||||
.then((arrrec) => {
|
||||
return arrrec
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -51,7 +51,7 @@ TemplEmailSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
TemplEmailSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ TemplEmailSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return TemplEmail.find(myfind).lean();
|
||||
return await TemplEmail.find(myfind).lean();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const bcrypt = require('bcryptjs');
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const validator = require('validator');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const _ = require('lodash');
|
||||
@@ -470,7 +470,7 @@ UserSchema.statics.setZoomPresenza = async function(idapp, id, presenza) {
|
||||
allData.precDataUser = await User.getInfoUser(idapp,
|
||||
allData.myuser.username);
|
||||
|
||||
return User.findByIdAndUpdate(id,
|
||||
return await User.findByIdAndUpdate(id,
|
||||
{$set: {'profile.saw_zoom_presentation': presenza}}).then((rec) => {
|
||||
if (presenza) {
|
||||
const messaggio = tools.get__('ZOOM_CONFERMATO');
|
||||
@@ -663,15 +663,15 @@ UserSchema.statics.findByUsername = async function(idapp, username, alsoemail, o
|
||||
|
||||
//++TODO: Set only the necessary fields to get in memory
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp: idapp,
|
||||
username: {$regex: regexusername},
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((ris) => {
|
||||
}).then(async (ris) => {
|
||||
if ((!ris) && (alsoemail)) {
|
||||
regexemail = new RegExp(['^', username.toLowerCase(), '$'].join(''), 'i');
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
'idapp': idapp,
|
||||
'email': {$regex: regexemail},
|
||||
$or: [
|
||||
@@ -1009,7 +1009,7 @@ UserSchema.statics.setaportador_solidario = async function(
|
||||
|
||||
UserSchema.statics.setVerifiedByAportadorToALL = async function() {
|
||||
|
||||
return User.updateMany({}, {$set: {'verified_by_aportador': true}},
|
||||
return await User.updateMany({}, {$set: {'verified_by_aportador': true}},
|
||||
{new: false});
|
||||
|
||||
};
|
||||
@@ -1051,7 +1051,7 @@ UserSchema.statics.isUserQualified9 = async function(idapp, username) {
|
||||
UserSchema.statics.getnumPaymentOk = function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.count({
|
||||
return await User.count({
|
||||
idapp,
|
||||
$and: [
|
||||
{
|
||||
@@ -1146,7 +1146,7 @@ UserSchema.statics.createNewRequestPwd = function(idapp, email) {
|
||||
toString();
|
||||
user.date_tokenforgot = new Date();
|
||||
user.lasttimeonline = new Date();
|
||||
return user.save().then(async () => {
|
||||
return await user.save().then(async () => {
|
||||
await sendemail.sendEmail_RequestNewPassword(user.lang, user, user.email, user.idapp, user.tokenforgot);
|
||||
|
||||
return true;
|
||||
@@ -1172,7 +1172,7 @@ UserSchema.statics.createNewRequestPwdByUsernameAndGetLink = async function(idap
|
||||
user.date_tokenforgot = new Date();
|
||||
user.lasttimeonline = new Date();
|
||||
|
||||
return user.save().then(() => {
|
||||
return await user.save().then(() => {
|
||||
return tools.getlinkRequestNewPassword(idapp, user.email, user.tokenforgot);
|
||||
});
|
||||
}
|
||||
@@ -1294,7 +1294,7 @@ UserSchema.methods.removeToken = function(token) {
|
||||
UserSchema.statics.getEmailByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((arrrec) => {
|
||||
@@ -1307,7 +1307,7 @@ UserSchema.statics.getEmailByUsername = async function(idapp, username) {
|
||||
UserSchema.statics.getUsernameById = async function(idapp, id) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, _id: id,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {username: 1}).then((myuser) => {
|
||||
@@ -1340,7 +1340,7 @@ UserSchema.statics.isMyFriend = async function(idapp, username, myusername) {
|
||||
|
||||
const myfriends = await User.getUsernameFriendsByUsername(idapp, myusername);
|
||||
if (myfriends) {
|
||||
return myfriends.includes(username);
|
||||
return await myfriends.includes(username);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -1576,7 +1576,7 @@ UserSchema.statics.getArrUsernameFromFieldByUsername = async function(
|
||||
UserSchema.statics.getUsernameReqFriendsByUsername = async function(
|
||||
idapp, username) {
|
||||
|
||||
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'req_friends');
|
||||
|
||||
};
|
||||
@@ -1584,7 +1584,7 @@ UserSchema.statics.getUsernameReqFriendsByUsername = async function(
|
||||
UserSchema.statics.getUsernameFriendsByUsername = async function(
|
||||
idapp, username) {
|
||||
|
||||
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'friends');
|
||||
|
||||
};
|
||||
@@ -1592,14 +1592,14 @@ UserSchema.statics.getUsernameFriendsByUsername = async function(
|
||||
UserSchema.statics.getUsernameGroupsByUsername = async function(
|
||||
idapp, username) {
|
||||
|
||||
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'mygroups');
|
||||
|
||||
};
|
||||
UserSchema.statics.getUsernameCircuitsByUsername = async function(
|
||||
idapp, username) {
|
||||
|
||||
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
|
||||
'mycircuits');
|
||||
|
||||
};
|
||||
@@ -1607,39 +1607,39 @@ UserSchema.statics.getUsernameCircuitsByUsername = async function(
|
||||
// Rimuovo l'Amicizia
|
||||
UserSchema.statics.removeFriend = async function(
|
||||
idapp, username, usernameDest) {
|
||||
return User.updateOne({idapp, username},
|
||||
return await User.updateOne({idapp, username},
|
||||
{$pull: {'profile.friends': {username: {$in: [usernameDest]}}}});
|
||||
};
|
||||
|
||||
// Rimuovo il Gruppo
|
||||
UserSchema.statics.removeFromMyGroups = async function(
|
||||
idapp, username, groupnameDest) {
|
||||
return User.updateOne({idapp, username},
|
||||
return await User.updateOne({idapp, username},
|
||||
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
|
||||
};
|
||||
// Rimuovo il Gruppo
|
||||
UserSchema.statics.removeFromCircuits = async function(idapp, username, circuitname) {
|
||||
return User.updateOne({idapp, username},
|
||||
return await User.updateOne({idapp, username},
|
||||
{$pull: {'profile.mycircuits': {circuitname: {$in: [circuitname]}}}});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovo il Gruppo per Tutti gli Utenti
|
||||
UserSchema.statics.removeAllUsersFromMyGroups = async function(idapp, groupnameDest) {
|
||||
return User.updateMany({idapp},
|
||||
return await User.updateMany({idapp},
|
||||
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
|
||||
};
|
||||
|
||||
// Rimuovo il Circuito per Tutti gli Utenti
|
||||
UserSchema.statics.removeAllUsersFromMyCircuits = async function(idapp, circuitname) {
|
||||
return User.updateMany({idapp},
|
||||
return await User.updateMany({idapp},
|
||||
{$pull: {'profile.mycircuits': {circuitname: {$in: [circuitname]}}}});
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta di Amicizia
|
||||
UserSchema.statics.removeReqFriend = async function(
|
||||
idapp, username, usernameDest) {
|
||||
return User.updateOne({idapp, username: username},
|
||||
return await User.updateOne({idapp, username: username},
|
||||
{$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}});
|
||||
};
|
||||
|
||||
@@ -1665,7 +1665,7 @@ UserSchema.statics.setFriendsCmd = async function(req, idapp, usernameOrig, user
|
||||
await this.setFriendsCmd(req, idapp, usernameOrig, usernameDest,
|
||||
shared_consts.FRIENDSCMD.SETFRIEND, value);
|
||||
|
||||
return User.updateOne({idapp, username: usernameDest},
|
||||
return await User.updateOne({idapp, username: usernameDest},
|
||||
{$set: {verified_by_aportador: value, trust_modified: new Date()}},
|
||||
{new: false});
|
||||
|
||||
@@ -1890,7 +1890,7 @@ UserSchema.statics.setFriendsCmd = async function(req, idapp, usernameOrig, user
|
||||
UserSchema.statics.ifAlreadyInGroup = async function(idapp, usernameOrig, groupnameDest) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username: usernameOrig,
|
||||
'profile.mygroups': {
|
||||
@@ -1903,7 +1903,7 @@ UserSchema.statics.ifAlreadyInGroup = async function(idapp, usernameOrig, groupn
|
||||
UserSchema.statics.ifAlreadyInCircuit = async function(idapp, usernameOrig, circuitname) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username: usernameOrig,
|
||||
'profile.mycircuits': {
|
||||
@@ -1915,7 +1915,7 @@ UserSchema.statics.ifAlreadyInCircuit = async function(idapp, usernameOrig, circ
|
||||
UserSchema.statics.countUsersInGroup = async function(idapp, groupnameDest) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
return User.countDocuments({
|
||||
return await User.countDocuments({
|
||||
idapp,
|
||||
'profile.mygroups': {
|
||||
$elemMatch: {groupname: {$eq: groupnameDest}},
|
||||
@@ -1927,7 +1927,7 @@ UserSchema.statics.countUsersInGroup = async function(idapp, groupnameDest) {
|
||||
UserSchema.statics.countUsersInCircuit = async function(idapp, circuitname) {
|
||||
|
||||
// Controllo se è stato già inserito
|
||||
return User.countDocuments({
|
||||
return await User.countDocuments({
|
||||
idapp,
|
||||
'profile.mycircuits': {
|
||||
$elemMatch: {circuitname: {$eq: circuitname}},
|
||||
@@ -2190,13 +2190,13 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
|
||||
ris = await Circuit.removeAdminOfCircuit(idapp, usernameOrig, circuitname); // Rimuovo la richiesta di entrare nel gruppo
|
||||
|
||||
w
|
||||
// Invia una notifica alla persona
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
// Invia una notifica di moneta alla persona
|
||||
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
|
||||
ris = await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||
ris = await Circuit.sendCoins(idapp, usernameOrig, extrarec);
|
||||
@@ -2296,7 +2296,7 @@ UserSchema.statics.getInfoFriendByUsername = async function(idapp, username) {
|
||||
|
||||
const whatToShow = getWhatToShow(idapp, username);
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
@@ -2309,7 +2309,7 @@ UserSchema.statics.getInfoAskFriendByUsername = async function(
|
||||
|
||||
const whatToShow = getWhatToShow_Unknown(idapp, username);
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
@@ -2321,7 +2321,7 @@ UserSchema.statics.getAskedFriendsByUsername = async function(idapp, username) {
|
||||
|
||||
const whatToShow_Unknown = getWhatToShow_Unknown(idapp, username);
|
||||
|
||||
return User.find({
|
||||
return await User.find({
|
||||
idapp,
|
||||
'profile.req_friends': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
@@ -2402,7 +2402,7 @@ UserSchema.statics.getAportadorSolidarioByUsername = async function(
|
||||
idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).then((rec) => {
|
||||
@@ -2415,7 +2415,7 @@ UserSchema.statics.getAportadorSolidarioByUsername = async function(
|
||||
UserSchema.statics.UserByIdTelegram = async function(idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).lean().then((rec) => {
|
||||
@@ -2428,7 +2428,7 @@ UserSchema.statics.UserByIdTelegram = async function(idapp, teleg_id) {
|
||||
UserSchema.statics.UsersByIdTelegram = async function(idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return User.find({
|
||||
return await User.find({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}).lean().then((rec) => {
|
||||
@@ -2445,7 +2445,7 @@ UserSchema.statics.setPicProfile = async function(idapp, username, imgpic) {
|
||||
'profile.img': imgpic,
|
||||
};
|
||||
|
||||
return User.findOneAndUpdate({
|
||||
return await User.findOneAndUpdate({
|
||||
idapp, username,
|
||||
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
|
||||
return !!record;
|
||||
@@ -2456,7 +2456,7 @@ UserSchema.statics.setPicProfile = async function(idapp, username, imgpic) {
|
||||
UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {'profile.teleg_id': 1}).lean().then((rec) => {
|
||||
@@ -2469,7 +2469,7 @@ UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
|
||||
UserSchema.statics.TelegIdById = async function(idapp, id) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
_id: id,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
@@ -2481,7 +2481,7 @@ UserSchema.statics.TelegIdById = async function(idapp, id) {
|
||||
};
|
||||
UserSchema.statics.notAsk_VerifByUsername = async function(idapp, username) {
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {'notask_verif': 1}).lean().then((rec) => {
|
||||
@@ -2500,7 +2500,7 @@ UserSchema.statics.SetTelegramCheckCode = async function(
|
||||
'profile.teleg_checkcode': teleg_checkcode,
|
||||
};
|
||||
|
||||
return User.findOneAndUpdate({
|
||||
return await User.findOneAndUpdate({
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
|
||||
return !!record;
|
||||
@@ -2515,7 +2515,7 @@ UserSchema.statics.NonVoglioImbarcarmi = async function(idapp, username) {
|
||||
non_voglio_imbarcarmi: true,
|
||||
};
|
||||
|
||||
return User.findOneAndUpdate({
|
||||
return await User.findOneAndUpdate({
|
||||
idapp,
|
||||
username,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
@@ -2533,7 +2533,7 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
|
||||
'profile.teleg_checkcode': 0,
|
||||
};
|
||||
|
||||
return User.findOneAndUpdate({
|
||||
return await User.findOneAndUpdate({
|
||||
idapp,
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
|
||||
@@ -2560,7 +2560,7 @@ UserSchema.statics.setUsernameTelegram = async function(
|
||||
'profile.lastname_telegram': lastname_telegram,
|
||||
};
|
||||
|
||||
return User.findOneAndUpdate({
|
||||
return await User.findOneAndUpdate({
|
||||
idapp,
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
@@ -2576,7 +2576,7 @@ UserSchema.statics.SetLang = async function(idapp, id, lang) {
|
||||
lang,
|
||||
};
|
||||
|
||||
return User.findOneAndUpdate({
|
||||
return await User.findOneAndUpdate({
|
||||
_id: id,
|
||||
}, {$set: fields_to_update}, {new: false}).then((record) => {
|
||||
return record;
|
||||
@@ -2608,7 +2608,7 @@ UserSchema.statics.getNameSurnameByUsername = async function(
|
||||
idapp, username, reale = false) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {username: 1, name: 1, surname: 1}).then((rec) => {
|
||||
@@ -2636,7 +2636,7 @@ UserSchema.statics.getIdByUsername = async function(idapp, username) {
|
||||
|
||||
let regexp = new RegExp(`^${username}$`, 'i');
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username: {$regex: regexp},
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
@@ -2652,7 +2652,7 @@ UserSchema.statics.getRealUsernameByUsername = async function(idapp, username) {
|
||||
|
||||
let regexp = new RegExp(`^${username}$`, 'i');
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username:
|
||||
{$regex: regexp},
|
||||
@@ -2667,7 +2667,7 @@ UserSchema.statics.getRealUsernameByUsername = async function(idapp, username) {
|
||||
UserSchema.statics.getRecLangAndIdByUsername = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp, username,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
}, {lang: 1, _id: 1}).then((rec) => {
|
||||
@@ -2680,7 +2680,7 @@ UserSchema.statics.getRecLangAndIdByUsername = async function(idapp, username) {
|
||||
UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
_id: userId,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
@@ -2694,7 +2694,7 @@ UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
|
||||
UserSchema.statics.getusersManagers = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.find({idapp, 'profile.manage_telegram': true},
|
||||
return await User.find({idapp, 'profile.manage_telegram': true},
|
||||
{username: 1, 'profile.teleg_id': 1, perm: 1}).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -2705,7 +2705,7 @@ UserSchema.statics.getusersManagers = async function(idapp) {
|
||||
UserSchema.statics.getusersRespList = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.find({idapp, 'profile.resplist': true},
|
||||
return await User.find({idapp, 'profile.resplist': true},
|
||||
{_id: 1, username: 1, name: 1, surname: 1}).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -2716,7 +2716,7 @@ UserSchema.statics.getusersRespList = async function(idapp) {
|
||||
UserSchema.statics.getusersWorkersList = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.find({idapp, 'profile.workerslist': true},
|
||||
return await User.find({idapp, 'profile.workerslist': true},
|
||||
{_id: 1, username: 1, name: 1, surname: 1}).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -2727,7 +2727,7 @@ UserSchema.statics.getusersWorkersList = async function(idapp) {
|
||||
UserSchema.statics.getusersManagersAndZoomeri = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.find(
|
||||
return await User.find(
|
||||
{
|
||||
idapp,
|
||||
or: [
|
||||
@@ -2754,7 +2754,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
if (!!username) {
|
||||
return User.find({idapp, username, 'profile.teleg_id': {$gt: 0}}).lean();
|
||||
return await User.find({idapp, username, 'profile.teleg_id': {$gt: 0}}).lean();
|
||||
then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).
|
||||
@@ -2762,7 +2762,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
|
||||
console.error('getUsersTelegALL', e);
|
||||
});
|
||||
} else {
|
||||
return User.find({idapp, 'profile.teleg_id': {$gt: 0}}).
|
||||
return await User.find({idapp, 'profile.teleg_id': {$gt: 0}}).
|
||||
lean().
|
||||
then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
@@ -2777,7 +2777,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
|
||||
UserSchema.statics.isManagerByIdTeleg = async function(idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
'profile.manage_telegram': true,
|
||||
'profile.teleg_id': idtelegram,
|
||||
@@ -2792,7 +2792,7 @@ UserSchema.statics.isManagerByIdTeleg = async function(idapp, idtelegram) {
|
||||
UserSchema.statics.isAdminByIdTeleg = async function(idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username: 'paoloar77',
|
||||
'profile.manage_telegram': true,
|
||||
@@ -2884,14 +2884,14 @@ UserSchema.statics.findAllIdApp = async function(idapp) {
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
};
|
||||
|
||||
return User.find(myfind, (err, arrrec) => {
|
||||
return await User.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.DuplicateAllRecords = async function(idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
@@ -3005,7 +3005,7 @@ UserSchema.statics.getUsersRegistered = async function(idapp) {
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersOnLineToday = async function(idapp) {
|
||||
@@ -3020,7 +3020,7 @@ UserSchema.statics.getUsersOnLineToday = async function(idapp) {
|
||||
lasttimeonline: {$gt: starttoday},
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -3089,7 +3089,7 @@ UserSchema.statics.getEmailNotVerified = async function(idapp) {
|
||||
verified_email: false,
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramAttivo = async function(idapp) {
|
||||
@@ -3101,7 +3101,7 @@ UserSchema.statics.getUsersTelegramAttivo = async function(idapp) {
|
||||
'profile.teleg_id': {$gt: 0},
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersAutorizzati = async function(idapp) {
|
||||
@@ -3114,7 +3114,7 @@ UserSchema.statics.getUsersAutorizzati = async function(idapp) {
|
||||
verified_by_aportador: true,
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersAutorizzare = async function(idapp) {
|
||||
@@ -3127,7 +3127,7 @@ UserSchema.statics.getUsersAutorizzare = async function(idapp) {
|
||||
verified_by_aportador: {$exists: false},
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramPending = async function(idapp) {
|
||||
@@ -3139,7 +3139,7 @@ UserSchema.statics.getUsersTelegramPending = async function(idapp) {
|
||||
'profile.teleg_checkcode': {$gt: 0},
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getNumUsers = async function(idapp) {
|
||||
@@ -3150,7 +3150,7 @@ UserSchema.statics.getNumUsers = async function(idapp) {
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersZoom = async function(idapp) {
|
||||
@@ -3162,7 +3162,7 @@ UserSchema.statics.getUsersZoom = async function(idapp) {
|
||||
'profile.saw_zoom_presentation': true,
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersResidenti = async function(idapp) {
|
||||
@@ -3174,7 +3174,7 @@ UserSchema.statics.getUsersResidenti = async function(idapp) {
|
||||
'profile.socioresidente': {$exists: true, $eq: true},
|
||||
};
|
||||
|
||||
return User.find(myfind, {username: 1, name: 1, surname: 1});
|
||||
return await User.find(myfind, {username: 1, name: 1, surname: 1});
|
||||
};
|
||||
|
||||
UserSchema.statics.getSaw_and_Accepted = async function(idapp) {
|
||||
@@ -3186,7 +3186,7 @@ UserSchema.statics.getSaw_and_Accepted = async function(idapp) {
|
||||
'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED,
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersDreams = async function(idapp) {
|
||||
@@ -3199,7 +3199,7 @@ UserSchema.statics.getUsersDreams = async function(idapp) {
|
||||
'$expr': {'$gt': [{'$strLenCP': '$profile.my_dream'}, 10]},
|
||||
};
|
||||
|
||||
return User.count(myfind);
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getLastUsers = async function(idapp) {
|
||||
@@ -3207,7 +3207,7 @@ UserSchema.statics.getLastUsers = async function(idapp) {
|
||||
|
||||
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
|
||||
|
||||
return User.find(
|
||||
return await User.find(
|
||||
{
|
||||
idapp,
|
||||
$or: [
|
||||
@@ -3231,7 +3231,7 @@ UserSchema.statics.getLastUsers = async function(idapp) {
|
||||
UserSchema.statics.checkUser = async function(idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({idapp, username}, {
|
||||
return await User.findOne({idapp, username}, {
|
||||
verified_email: 1,
|
||||
verified_by_aportador: 1,
|
||||
notask_verif: 1,
|
||||
@@ -3301,7 +3301,7 @@ UserSchema.statics.getDistinctNationalityQuery = function(idapp) {
|
||||
UserSchema.statics.findAllDistinctNationality = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getDistinctNationalityQuery(idapp)).then(ris => {
|
||||
return await User.aggregate(User.getDistinctNationalityQuery(idapp)).then(ris => {
|
||||
// console.table(ris);
|
||||
return ris;
|
||||
});
|
||||
@@ -3403,7 +3403,7 @@ UserSchema.statics.getnumRegNDays = function(idapp, nrec) {
|
||||
UserSchema.statics.calcnumRegUntilDay = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
|
||||
return await User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
|
||||
return arr.reduce((sum, rec) => sum + rec.count, 0);
|
||||
});
|
||||
|
||||
@@ -3412,7 +3412,7 @@ UserSchema.statics.calcnumRegUntilDay = async function(idapp) {
|
||||
UserSchema.statics.calcRegDaily = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getUsersRegDaily(idapp, 60)).then(ris => {
|
||||
return await User.aggregate(User.getUsersRegDaily(idapp, 60)).then(ris => {
|
||||
// console.table(ris);
|
||||
return ris;
|
||||
});
|
||||
@@ -3421,7 +3421,7 @@ UserSchema.statics.calcRegDaily = async function(idapp) {
|
||||
UserSchema.statics.calcRegWeekly = async function(idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getUsersRegWeekly(idapp, 20 * 7)).then(ris => {
|
||||
return await User.aggregate(User.getUsersRegWeekly(idapp, 20 * 7)).then(ris => {
|
||||
// console.table(ris);
|
||||
return ris.slice(0, -1);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
var variantSchema = mongoose.Schema({
|
||||
productID: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -44,7 +44,7 @@ WhereSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return Where.find(myfind, (err, arrrec) => {
|
||||
return await Where.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
const tools = require('../tools/general');
|
||||
const Path = require('path');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const {CfgServer} = require('../models/cfgserver');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
@@ -40,7 +40,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
const liste = require('../data/liste');
|
||||
|
||||
if (cmd === shared_consts.Cmd.CITIES_SERVER) {
|
||||
return City.insertMany(liste.Comuni).then((ris) => {
|
||||
return await City.insertMany(liste.Comuni).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
//const { ListaIngresso } = require('../../models/listaingresso');
|
||||
|
||||
@@ -19,9 +19,9 @@ const sendNotifBooking = async (res, idapp, user, recbooking) => {
|
||||
|
||||
// Send Email
|
||||
if (recbooking.booked)
|
||||
return sendemail.sendEmail_Booking(res, user.lang, user.email, user, idapp, recbooking);
|
||||
return await sendemail.sendEmail_Booking(res, user.lang, user.email, user, idapp, recbooking);
|
||||
else
|
||||
return sendemail.sendEmail_CancelBooking(res, user.lang, user.email, user, idapp, recbooking);
|
||||
return await sendemail.sendEmail_CancelBooking(res, user.lang, user.email, user, idapp, recbooking);
|
||||
};
|
||||
|
||||
router.post('/', authenticate, (req, res) => {
|
||||
|
||||
@@ -12,13 +12,8 @@ var { Project } = require('../models/project');
|
||||
|
||||
var { authenticate, auth_default } = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const Product = require('../models/product');
|
||||
const Order = require('../models/order');
|
||||
const Variant = require('../models/variant');
|
||||
@@ -199,7 +194,7 @@ router.post('/:userId/cartstatus', authenticate, async function (req, res, next)
|
||||
created_at: new Date(),
|
||||
modify_at: new Date(),
|
||||
})
|
||||
return OrdersCart.updateOrdersCartById(-1, newOrderCart, function (err, ris) {
|
||||
return await OrdersCart.updateOrdersCartById(-1, newOrderCart, function (err, ris) {
|
||||
//if (err) return next(err)
|
||||
if (err)
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||
|
||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
||||
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
@@ -37,6 +37,7 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
try {
|
||||
|
||||
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'] : '';
|
||||
@@ -63,6 +64,8 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
|
||||
data = await getCircuitRecAdminsInfo(idapp, data);
|
||||
|
||||
data.movements = await Movement.getMovsByCircuitId(idapp, usernameOrig, data._id);
|
||||
|
||||
res.send({circuit: data, users_in_circuit});
|
||||
|
||||
} catch (e) {
|
||||
|
||||
@@ -11,9 +11,6 @@ const { User } = require('../models/user');
|
||||
|
||||
const { MsgTemplate } = require('../models/msg_template');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -14,7 +14,7 @@ const {ObjectID} = require('mongodb');
|
||||
// const {ListaIngresso} = require('../models/listaingresso');
|
||||
const {Graduatoria} = require('../models/graduatoria');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const {CfgServer} = require('../models/cfgserver');
|
||||
|
||||
// const uuidv4 = require('uuid/v4'); // I chose v4 ‒ you can select others
|
||||
@@ -198,14 +198,14 @@ router.post(process.env.LINK_UPDATE_PWD, (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/testServer', authenticate_noerror, (req, res) => {
|
||||
router.post('/testServer', authenticate_noerror, async (req, res) => {
|
||||
|
||||
try {
|
||||
const test = req.body.test;
|
||||
let ris = {test};
|
||||
|
||||
if (req.user) {
|
||||
tools.sendNotificationToUser(req.user._id, 'Test Server',
|
||||
await tools.sendNotificationToUser(req.user._id, 'Test Server',
|
||||
'Test Server OK',
|
||||
'/', '', 'server', []);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
const mytable = globalTables.getTableByTableName(params.table);
|
||||
let mydata = req.body.data;
|
||||
let extrarec = {};
|
||||
if (myapp.hasOwnProperty('extrarec')) {
|
||||
if (mydata && mydata.hasOwnProperty('extrarec')) {
|
||||
extrarec = mydata['extrarec'];
|
||||
delete mydata['extrarec'];
|
||||
}
|
||||
@@ -343,7 +343,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
mytablerec.date_updated = new Date();
|
||||
}
|
||||
|
||||
return mytablerec.save().
|
||||
return await mytablerec.save().
|
||||
then(async (rec) => {
|
||||
|
||||
if (shared_consts.TABLES_GETCOMPLETEREC.includes(params.table)) {
|
||||
@@ -399,7 +399,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
if (params.table === shared_consts.TAB_MYGROUPS && isnewrec) {
|
||||
// nuovo Record:
|
||||
// aggiungi il creatore al gruppo stesso
|
||||
return User.setGroupsCmd(mydata.idapp, req.user.username,
|
||||
return await User.setGroupsCmd(mydata.idapp, req.user.username,
|
||||
myrec.groupname,
|
||||
shared_consts.GROUPSCMD.SETGROUP, true, req.user.username).then((ris) => {
|
||||
return res.send(myrec);
|
||||
@@ -407,14 +407,14 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
} else if (params.table === shared_consts.TAB_MYCIRCUITS && isnewrec) {
|
||||
// nuovo Record:
|
||||
// aggiungi il creatore al Circuito stesso
|
||||
return User.setCircuitCmd(mydata.idapp, req.user.username, myrec.name,
|
||||
return await User.setCircuitCmd(mydata.idapp, req.user.username, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, req.user.username, extrarec).then((ris) => {
|
||||
return res.send(myrec);
|
||||
});
|
||||
}
|
||||
|
||||
return res.send(myrec);
|
||||
}).catch((e) => {
|
||||
}).catch(async (e) => {
|
||||
console.error('settable', e.message);
|
||||
if (e.code === 11000) {
|
||||
const id = mytablerec._id;
|
||||
@@ -423,7 +423,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
||||
if (!myfields.userId) {
|
||||
myfields.userId = req.user._id.toString();
|
||||
}
|
||||
return mytablestrutt.findByIdAndUpdate(id, {$set: myfields}).
|
||||
return await mytablestrutt.findByIdAndUpdate(id, {$set: myfields}).
|
||||
then(async (rec) => {
|
||||
return res.send(rec);
|
||||
}).
|
||||
@@ -465,10 +465,12 @@ router.post('/setsubrec', authenticate, (req, res) => {
|
||||
|
||||
return res.send(rec);
|
||||
|
||||
|
||||
return mytablerec.save().then(rec => {
|
||||
// tools.mylog('rec', rec);
|
||||
return res.send(rec);
|
||||
|
||||
|
||||
}).catch((e) => {
|
||||
if (e.code === 11000) {
|
||||
const id = mytablerec._id;
|
||||
@@ -598,7 +600,7 @@ router.post('/getpage', async (req, res) => {
|
||||
const idapp = req.body.idapp;
|
||||
const mypath = params.path;
|
||||
|
||||
return MyPage.findOne({idapp, path: mypath}).then((ris) => {
|
||||
return await MyPage.findOne({idapp, path: mypath}).then((ris) => {
|
||||
return res.send({mypage: ris});
|
||||
}).catch((e) => {
|
||||
console.log(e.message);
|
||||
@@ -1061,7 +1063,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/duprec/:table/:id', authenticate, (req, res) => {
|
||||
router.post('/duprec/:table/:id', authenticate, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const tablename = req.params.table;
|
||||
// const idapp = req.body.idapp;
|
||||
@@ -1081,12 +1083,12 @@ router.post('/duprec/:table/:id', authenticate, (req, res) => {
|
||||
send({code: server_constants.RIS_CODE_ERR_UNAUTHORIZED, msg: ''});
|
||||
}
|
||||
|
||||
return mytable.findById(id).then((mydata) => {
|
||||
return await mytable.findById(id).then(async (mydata) => {
|
||||
|
||||
const datadup = tools.CloneRecordToNew(mydata);
|
||||
const mynewrec = new mytable(datadup);
|
||||
|
||||
return mynewrec.save().then((rec) => {
|
||||
return await mynewrec.save().then(async (rec) => {
|
||||
if (!rec) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
@@ -1094,7 +1096,7 @@ router.post('/duprec/:table/:id', authenticate, (req, res) => {
|
||||
tools.mylog('DUPLICATED ', rec);
|
||||
|
||||
// Do extra things after deleted
|
||||
return actions.doOtherThingsAfterDuplicated(tablename, rec).
|
||||
return await actions.doOtherThingsAfterDuplicated(tablename, rec).
|
||||
then(({myrec}) => {
|
||||
// ...
|
||||
mytable.findById(myrec._id).then((record) => {
|
||||
@@ -1503,19 +1505,19 @@ function uploadFile(req, res, version) {
|
||||
try {
|
||||
|
||||
form.on('fileBegin', async function(name, file) {
|
||||
file.path = folder + '/' + file.name;
|
||||
file.path = folder + '/' + file.newFilename;
|
||||
});
|
||||
|
||||
form.on('file', async function(name, file) {
|
||||
try {
|
||||
console.log('1) Uploading ' + file.name);
|
||||
console.log('1) Uploading ' + file.originalFilename);
|
||||
const mydir = tools.getdirByIdApp(idapp) + dirmain +
|
||||
server_constants.DIR_UPLOAD + '/' + dir;
|
||||
|
||||
// Create Dir if doesn't exist:
|
||||
const rismk = tools.mkdirpath(mydir);
|
||||
|
||||
let filename = file.name;
|
||||
let filename = file.originalFilename;
|
||||
let ext = path.extname(filename);
|
||||
|
||||
//++Todo: Modifica del nomefile... da passare al frontend
|
||||
@@ -1524,10 +1526,10 @@ function uploadFile(req, res, version) {
|
||||
//}
|
||||
|
||||
file.name = filename;
|
||||
let newname = mydir + '/' + file.name;
|
||||
let newname = mydir + '/' + file.originalFilename;
|
||||
let resized_img = mydir + '/' + server_constants.PREFIX_IMG + filename;
|
||||
|
||||
oldpath = file.path;
|
||||
oldpath = file.newFilename;
|
||||
file.path = newname;
|
||||
|
||||
if (!tools.sulServer()) {
|
||||
|
||||
@@ -19,7 +19,7 @@ const _ = require('lodash');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
|
||||
// POST /iscritti_conacreis
|
||||
|
||||
@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
|
||||
|
||||
var {authenticate, auth_default} = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false);
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
|
||||
|
||||
var {authenticate, auth_default} = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false);
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
||||
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
|
||||
@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
|
||||
|
||||
var {authenticate, auth_default} = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false);
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -11,7 +11,7 @@ var { Project } = require('../models/project');
|
||||
|
||||
var { authenticate, auth_default } = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@@ -9,13 +9,8 @@ var { Project } = require('../models/project');
|
||||
|
||||
var { authenticate, auth_default } = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const Product = require('../models/product');
|
||||
const Variant = require('../models/variant');
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
// var mongoose = require('mongoose').set('debug', false)
|
||||
// var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
const { Project } = require('../models/project');
|
||||
const { Todo } = require('../models/todo');
|
||||
@@ -45,9 +45,9 @@ router.post('/', authenticate, (req, res) => {
|
||||
project.save().then((writeresult) => {
|
||||
let idobj = writeresult._id;
|
||||
Project.findById(idobj)
|
||||
.then(record => {
|
||||
.then(async (record) => {
|
||||
|
||||
tools.sendNotificationToUser(record.userId, '[Progetto]: ' + record.descr, record.descr, '/todo/' + record._id, '', 'todo', [])
|
||||
await tools.sendNotificationToUser(record.userId, '[Progetto]: ' + record.descr, record.descr, '/todo/' + record._id, '', 'todo', [])
|
||||
|
||||
res.send({ record: record._doc });
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
// const q = require('q');
|
||||
const webpush = require('web-push');
|
||||
@@ -89,10 +89,10 @@ router.post('/', (req, res) => {
|
||||
|
||||
async function SendMsgTo(idapp, username, params) {
|
||||
|
||||
return User.find({idapp, username}).then((arrusers) => {
|
||||
return await User.find({idapp, username}).then(async (arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
tools.sendNotificationToUser(user._id, params.title, params.content,
|
||||
await tools.sendNotificationToUser(user._id, params.title, params.content,
|
||||
params.openUrl, params.openUrl2, params.tag, params.actions, params.id).
|
||||
then(ris => {
|
||||
if (ris) {
|
||||
|
||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
// var mongoose = require('mongoose').set('debug', false)
|
||||
// var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
const { Project } = require('../models/project');
|
||||
const { Todo } = require('../models/todo');
|
||||
|
||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
||||
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
const { User } = require('../models/user');
|
||||
// const { Nave } = require('../models/nave');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const tools = require('../tools/general');
|
||||
@@ -48,7 +48,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
}).catch(err => {
|
||||
// Not found
|
||||
return null;
|
||||
}).then(myitem => {
|
||||
}).then(async (myitem) => {
|
||||
|
||||
if (myitem === null) {
|
||||
myitem = subscriptionModel;
|
||||
@@ -59,7 +59,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
myitem.createDate = new Date();
|
||||
}
|
||||
|
||||
return myitem.save((err, subscription) => {
|
||||
return await myitem.save((err, subscription) => {
|
||||
if (err) {
|
||||
console.error(`Error occurred while saving subscription. Err: ${err}`);
|
||||
return res.status(500).json({
|
||||
|
||||
@@ -9,7 +9,7 @@ var { Project } = require('../models/project');
|
||||
|
||||
var { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
var { Todo } = require('../models/todo');
|
||||
|
||||
@@ -9,8 +9,6 @@ var { Project } = require('../models/project');
|
||||
|
||||
var { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false)
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
var { Todo } = require('../models/todo');
|
||||
|
||||
@@ -56,7 +54,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
.then((writeresult) => {
|
||||
let idobj = writeresult._id;
|
||||
return Todo.findById(idobj)
|
||||
.then(record => {
|
||||
.then(async (record) => {
|
||||
// tools.mylog('REC SAVED :', record.descr);
|
||||
|
||||
let aggiorna = false;
|
||||
@@ -72,7 +70,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
if (aggiorna) {
|
||||
tools.sendNotificationToUser(todo.userId, titolo + ' ' + record.descr, record.descr, '/todo/' + todo.category, '', 'todo', [])
|
||||
await tools.sendNotificationToUser(todo.userId, titolo + ' ' + record.descr, record.descr, '/todo/' + todo.category, '', 'todo', [])
|
||||
.then(ris => {
|
||||
if (ris) {
|
||||
return res.send({ record });
|
||||
|
||||
@@ -39,7 +39,8 @@ const TypedError = require('../modules/ErrorHandler');
|
||||
const {MyGroup} = require('../models/mygroup');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
function existSubScribe(userId, access, browser) {
|
||||
|
||||
@@ -286,7 +286,7 @@ module.exports = {
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||
|
||||
return Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING')
|
||||
return await Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING')
|
||||
.then(async (ris) => {
|
||||
mylocalsconf.msgreply_after_booking = ris;
|
||||
|
||||
@@ -411,7 +411,7 @@ module.exports = {
|
||||
else
|
||||
replyto = tools.getreplyToEmailByIdApp(idapp);
|
||||
|
||||
return this.sendEmail_base('msg/sendmsg/' + lang, emailto, mylocalsconf, replyto);
|
||||
return await this.sendEmail_base('msg/sendmsg/' + lang, emailto, mylocalsconf, replyto);
|
||||
|
||||
// Send Email also to the Admin
|
||||
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
||||
@@ -872,7 +872,7 @@ module.exports = {
|
||||
checkifSentNewsletter: async function (idapp) {
|
||||
// Check if is the time to send the Newsletter
|
||||
|
||||
return Newstosent.findNewsletter_To_Send(idapp)
|
||||
return await Newstosent.findNewsletter_To_Send(idapp)
|
||||
.then((rec) => {
|
||||
if (rec)
|
||||
this.sendNewsletter(rec);
|
||||
@@ -884,7 +884,7 @@ module.exports = {
|
||||
// Check if is the time to send the Newsletter
|
||||
// Only newsletter pending en 8 hour last email sent.
|
||||
|
||||
return Newstosent.findNewsletterPending_To_Send(idapp)
|
||||
return await Newstosent.findNewsletterPending_To_Send(idapp)
|
||||
.then((rec) => { //
|
||||
this.sendNewsletter(rec, idapp)
|
||||
});
|
||||
@@ -939,7 +939,7 @@ module.exports = {
|
||||
|
||||
console.log('-> Invio Email TEST a', mylocalsconf.emailto, 'previewonly',
|
||||
previewonly);
|
||||
return this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto,
|
||||
return await this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto,
|
||||
mylocalsconf, '', smtpTransport, previewonly);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ const tools = require('./tools/general');
|
||||
|
||||
const shared_consts = require('./tools/shared_nodejs');
|
||||
|
||||
var mongoose = require('mongoose').set('debug', false);
|
||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
|
||||
mongoose.set('debug', process.env.DEBUG);
|
||||
|
||||
@@ -345,10 +345,10 @@ function testmsgwebpush() {
|
||||
// console.log('nomeapp 1: ' , tools.getNomeAppByIdApp(1));
|
||||
// console.log('nomeapp 2: ' , tools.getNomeAppByIdApp(2));
|
||||
|
||||
User.find({username: 'paoloar77', idapp: '1'}).then((arrusers) => {
|
||||
User.find({username: 'paoloar77', idapp: '1'}).then(async (arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
tools.sendNotificationToUser(user._id, 'Server',
|
||||
await tools.sendNotificationToUser(user._id, 'Server',
|
||||
'Il Server è Ripartito', '/', '', 'server', []).then(ris => {
|
||||
if (ris) {
|
||||
|
||||
|
||||
@@ -712,7 +712,7 @@ const MyTelegramBot = {
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl && idtelegram) {
|
||||
|
||||
return cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
||||
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
||||
chat_id, ripr_menuPrec);
|
||||
}
|
||||
|
||||
@@ -883,11 +883,11 @@ const MyTelegramBot = {
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Accetta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + groupid,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP + groupid,
|
||||
},
|
||||
{
|
||||
text: '🚫 Rifiuta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + groupid,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP + groupid,
|
||||
},
|
||||
]);
|
||||
}
|
||||
@@ -2517,7 +2517,7 @@ class Telegram {
|
||||
try {
|
||||
const msg = await MsgTemplate.getMsgByTitleAndLang(myuser.idapp, title, myuser.lang);
|
||||
const mytext = tools.convertSpecialTags(myuser, msg.body);
|
||||
return this.sendMsg(myuser.profile.teleg_id, mytext);
|
||||
return await this.sendMsg(myuser.profile.teleg_id, mytext);
|
||||
} catch (e) {
|
||||
console.error('ERR sendMsgByTemplate', e);
|
||||
}
|
||||
@@ -2536,7 +2536,7 @@ class Telegram {
|
||||
const mymsg = await MsgTemplate.getMsgByTitleAndLang(tools.RISO, title, langcode);
|
||||
const mytext = tools.convertSpecialTags(null, mymsg.body);
|
||||
if (id > 0)
|
||||
return this.sendMsg(id, mytext);
|
||||
return await this.sendMsg(id, mytext);
|
||||
} catch (e) {
|
||||
console.error('ERR sendMsgByTemplateByMsgStrutt', e);
|
||||
}
|
||||
@@ -2555,7 +2555,7 @@ class Telegram {
|
||||
const text = getstr(langcode, keytext);
|
||||
const mytext = tools.convertSpecialTags(null, text);
|
||||
if (id > 0)
|
||||
return this.sendMsg(id, mytext);
|
||||
return await this.sendMsg(id, mytext);
|
||||
} catch (e) {
|
||||
console.error('ERR sendMsgByTextByMsgStrutt', e);
|
||||
}
|
||||
@@ -2713,7 +2713,7 @@ class Telegram {
|
||||
|
||||
async setCmdToUsername(rec, username, cmd_to_set, valuebool) {
|
||||
if (cmd_to_set === Cmd.VALIDATE_REGISTRATION) {
|
||||
return User.setVerifiedByAportador(rec.user.idapp, username, valuebool);
|
||||
return await User.setVerifiedByAportador(rec.user.idapp, username, valuebool);
|
||||
} else if (cmd_to_set === Cmd.RICHIESTA_GRUPPO) {
|
||||
|
||||
}
|
||||
@@ -3521,7 +3521,7 @@ class Telegram {
|
||||
const username = rec ? rec.username_bo : '';
|
||||
|
||||
console.log('Msg inviato a ', username, '(', id, ')', text);
|
||||
return this.sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec);
|
||||
return await this.sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec);
|
||||
}
|
||||
|
||||
getmenuKey(mymenu, lang) {
|
||||
@@ -3808,6 +3808,7 @@ if (true) {
|
||||
username: '',
|
||||
userDest: '',
|
||||
groupId: 0,
|
||||
circuitId: '',
|
||||
};
|
||||
|
||||
const datastr = callbackQuery.data;
|
||||
@@ -3819,6 +3820,7 @@ if (true) {
|
||||
username: dataarr[1] ? dataarr[1] : '',
|
||||
userDest: dataarr[2] ? dataarr[2] : '',
|
||||
groupId: dataarr[3] ? parseInt(dataarr[3]) : '',
|
||||
circuitId: dataarr[4] ? parseInt(dataarr[4]) : '',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3943,7 +3945,7 @@ if (true) {
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (!foundIfAlreadyCircuit) {
|
||||
// Aggiungilo nel Gruppo
|
||||
// Aggiungilo nel Circuito
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ const userjson = JSON.stringify(users[0]);
|
||||
|
||||
const mynewID = new ObjectID();
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
||||
|
||||
var ObjectId = mongoose.Types.ObjectId;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ const {ObjectID} = require('mongodb');
|
||||
|
||||
const shared_consts = require('./shared_nodejs');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
||||
const Subscription = mongoose.model('subscribers');
|
||||
|
||||
const server_constants = require('./server_constants');
|
||||
@@ -746,7 +746,7 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
sendNotificationToUser: function(userId, title, content, openUrl, openUrl2, tag, actions, id) {
|
||||
sendNotificationToUser: async function(userId, title, content, openUrl, openUrl2, tag, actions, id) {
|
||||
|
||||
content = this.convertHTMLtoText(content);
|
||||
|
||||
@@ -765,94 +765,99 @@ module.exports = {
|
||||
// tag: req.body.tag
|
||||
};
|
||||
|
||||
return Subscription.find({userId}, (err, subscriptions) => {
|
||||
if (err) {
|
||||
console.error(`Error occurred while getting subscriptions`);
|
||||
// res.status(500).json({
|
||||
// error: 'Technical error occurred'
|
||||
// });
|
||||
try {
|
||||
|
||||
//++ Rimuovi questo record !?
|
||||
return await Subscription.find({userId}, (err, subscriptions) => {
|
||||
if (err) {
|
||||
console.error(`Error occurred while getting subscriptions`);
|
||||
// res.status(500).json({
|
||||
// error: 'Technical error occurred'
|
||||
// });
|
||||
|
||||
return false;
|
||||
} else {
|
||||
let conta = 0;
|
||||
let parallelSubscriptionCalls = subscriptions.map((subscription) => {
|
||||
const trovati = subscriptions.length;
|
||||
return new Promise((resolve, reject) => {
|
||||
const pushSubscription = {
|
||||
endpoint: subscription.endpoint,
|
||||
keys: {
|
||||
p256dh: subscription.keys.p256dh,
|
||||
auth: subscription.keys.auth,
|
||||
},
|
||||
};
|
||||
//++ Rimuovi questo record !?
|
||||
|
||||
conta++;
|
||||
|
||||
const parse = require('url-parse');
|
||||
const parsedUrl = parse(subscription.endpoint);
|
||||
const audience = parsedUrl.protocol + '//' + parsedUrl.hostname;
|
||||
|
||||
const vapidHeaders = webpush.getVapidHeaders(
|
||||
audience,
|
||||
process.env.VAPI_KEY_SUBJECT,
|
||||
process.env.PUBLIC_VAPI_KEY,
|
||||
process.env.PRIVATE_VAPI_KEY,
|
||||
'aes128gcm',
|
||||
);
|
||||
|
||||
const pushOptions = {
|
||||
vapidDetails: {
|
||||
subject: process.env.VAPI_KEY_SUBJECT,
|
||||
privateKey: process.env.PRIVATE_VAPI_KEY,
|
||||
publicKey: process.env.PUBLIC_VAPI_KEY,
|
||||
},
|
||||
TTL: payload.ttl,
|
||||
headers: vapidHeaders,
|
||||
};
|
||||
|
||||
console.log('************ INVIO WEBPUSH.SENDNOTIFICATION N° ',
|
||||
conta, '/', trovati, 'A', subscription.browser);
|
||||
|
||||
const pushPayload = JSON.stringify(payload);
|
||||
|
||||
webpush.sendNotification(
|
||||
pushSubscription,
|
||||
pushPayload,
|
||||
pushOptions,
|
||||
).then((value) => {
|
||||
// console.log('Invio Push', value);
|
||||
resolve({
|
||||
status: true,
|
||||
return false;
|
||||
} else {
|
||||
let conta = 0;
|
||||
let parallelSubscriptionCalls = subscriptions.map((subscription) => {
|
||||
const trovati = subscriptions.length;
|
||||
return new Promise((resolve, reject) => {
|
||||
const pushSubscription = {
|
||||
endpoint: subscription.endpoint,
|
||||
data: value,
|
||||
});
|
||||
}).catch(async (err) => {
|
||||
console.error('err Push', err.body);
|
||||
keys: {
|
||||
p256dh: subscription.keys.p256dh,
|
||||
auth: subscription.keys.auth,
|
||||
},
|
||||
};
|
||||
|
||||
// Cancella dal DB la notifica Push, visto che da errore! (sarà scaduto)
|
||||
const ris = await Subscription.deleteOne({_id: subscription._id});
|
||||
conta++;
|
||||
|
||||
reject({
|
||||
status: false,
|
||||
endpoint: subscription.endpoint,
|
||||
data: err,
|
||||
const parse = require('url-parse');
|
||||
const parsedUrl = parse(subscription.endpoint);
|
||||
const audience = parsedUrl.protocol + '//' + parsedUrl.hostname;
|
||||
|
||||
const vapidHeaders = webpush.getVapidHeaders(
|
||||
audience,
|
||||
process.env.VAPI_KEY_SUBJECT,
|
||||
process.env.PUBLIC_VAPI_KEY,
|
||||
process.env.PRIVATE_VAPI_KEY,
|
||||
'aes128gcm',
|
||||
);
|
||||
|
||||
const pushOptions = {
|
||||
vapidDetails: {
|
||||
subject: process.env.VAPI_KEY_SUBJECT,
|
||||
privateKey: process.env.PRIVATE_VAPI_KEY,
|
||||
publicKey: process.env.PUBLIC_VAPI_KEY,
|
||||
},
|
||||
TTL: payload.ttl,
|
||||
headers: vapidHeaders,
|
||||
};
|
||||
|
||||
console.log('************ INVIO WEBPUSH.SENDNOTIFICATION N° ',
|
||||
conta, '/', trovati, 'A', subscription.browser);
|
||||
|
||||
const pushPayload = JSON.stringify(payload);
|
||||
|
||||
webpush.sendNotification(
|
||||
pushSubscription,
|
||||
pushPayload,
|
||||
pushOptions,
|
||||
).then((value) => {
|
||||
// console.log('Invio Push', value);
|
||||
resolve({
|
||||
status: true,
|
||||
endpoint: subscription.endpoint,
|
||||
data: value,
|
||||
});
|
||||
}).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});
|
||||
|
||||
reject({
|
||||
status: false,
|
||||
endpoint: subscription.endpoint,
|
||||
data: err,
|
||||
});
|
||||
});
|
||||
}).catch(error => {
|
||||
console.log('ERROR: sendNotificationToUser', error.data.body ? error.data.body : error);
|
||||
});
|
||||
}).catch(error => {
|
||||
console.log('ERROR: sendNotificationToUser', error.data.body ? error.data.body : error);
|
||||
});
|
||||
});
|
||||
// q.allSettled(parallelSubscriptionCalls).then((pushResults) => {
|
||||
// console.info(pushResults);
|
||||
// });
|
||||
// res.json({
|
||||
// data: 'Push triggered'
|
||||
// });
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// q.allSettled(parallelSubscriptionCalls).then((pushResults) => {
|
||||
// console.info(pushResults);
|
||||
// });
|
||||
// res.json({
|
||||
// data: 'Push triggered'
|
||||
// });
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}catch (e) {
|
||||
console.error('sendNotificationToUser', e.message);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -907,7 +912,7 @@ module.exports = {
|
||||
|
||||
if (userId) {
|
||||
// SEND PUSH NOTIFICATION
|
||||
this.sendNotificationToUser(userId, title, descr, openUrl, '', tag, actions);
|
||||
await this.sendNotificationToUser(userId, title, descr, openUrl, '', tag, actions);
|
||||
}
|
||||
|
||||
if (telegram && sendmynotif) {
|
||||
@@ -922,7 +927,7 @@ module.exports = {
|
||||
sendNotifAndMsgTelegram: async function(idapp, userId, objmsg, telegram, msgextrateleg) {
|
||||
|
||||
if (userId) {
|
||||
this.sendNotificationToUser(userId, objmsg.title, objmsg.descr, objmsg.openUrl, '', objmsg.tag, objmsg.actions);
|
||||
await this.sendNotificationToUser(userId, objmsg.title, objmsg.descr, objmsg.openUrl, '', objmsg.tag, objmsg.actions);
|
||||
}
|
||||
|
||||
if (telegram) {
|
||||
@@ -1065,13 +1070,17 @@ module.exports = {
|
||||
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_ACCEPT) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sendnotif && typeid > 0) {
|
||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||
await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
return await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -1131,10 +1140,17 @@ module.exports = {
|
||||
try {
|
||||
// SEND TO THE ADMINS THE NOTIFICATIONS
|
||||
|
||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||
await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path, null,
|
||||
let ris = false;
|
||||
let inviato = false;
|
||||
|
||||
|
||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ || cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT || cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE ) {
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
|
||||
if (ris)
|
||||
inviato = true;
|
||||
// ++Todo: Inviare anche agli Admin ?!
|
||||
} else {
|
||||
|
||||
for (const singleadmin of circuit.admins) {
|
||||
@@ -1145,6 +1161,7 @@ module.exports = {
|
||||
|
||||
await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, singleadmin.username, username_action, circuitname,
|
||||
circuit.path, circuit, true, '', extrarec);
|
||||
inviato = true;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('sendNotificationByCircuit', e);
|
||||
@@ -1153,15 +1170,18 @@ module.exports = {
|
||||
|
||||
if (!giainviato && cmd !== shared_consts.CIRCUITCMD.REQ) {
|
||||
// SEND TO THE USER DEST THE NOTIFICATION
|
||||
await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||
false, '', extrarec);
|
||||
if (ris)
|
||||
inviato = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return inviato;
|
||||
|
||||
} catch (e) {
|
||||
console.error('sendNotificationByCircuit: ', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
},
|
||||
@@ -1226,10 +1246,10 @@ module.exports = {
|
||||
// console.log('nomeapp 1: ' , this.getNomeAppByIdApp(1));
|
||||
// console.log('nomeapp 2: ' , this.getNomeAppByIdApp(2));
|
||||
|
||||
User.find({username: 'paoloar77', idapp: '1'}).then((arrusers) => {
|
||||
User.find({username: 'paoloar77', idapp: '1'}).then(async (arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
this.sendNotificationToUser(user._id, title, msg, '/', '', tag, []).
|
||||
await this.sendNotificationToUser(user._id, title, msg, '/', '', tag, []).
|
||||
then(ris => {
|
||||
if (ris) {
|
||||
|
||||
@@ -1591,7 +1611,7 @@ module.exports = {
|
||||
return myquery;
|
||||
},
|
||||
|
||||
getQueryTable: function(idapp, params, user) {
|
||||
getQueryTable: async function(idapp, params, user) {
|
||||
|
||||
if (typeof params.startRow !== 'number') {
|
||||
throw new Error('startRow must be number');
|
||||
@@ -1834,7 +1854,7 @@ module.exports = {
|
||||
query.push({
|
||||
$match: {
|
||||
$and: [
|
||||
{'user.idapp': idapp},
|
||||
{'user.idapp': params.idapp},
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -1871,7 +1891,7 @@ module.exports = {
|
||||
query.push({
|
||||
$match: {
|
||||
$and: [
|
||||
{'user.idapp': idapp},
|
||||
{'user.idapp': params.idapp},
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -1883,6 +1903,14 @@ module.exports = {
|
||||
},
|
||||
);
|
||||
|
||||
} 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);
|
||||
|
||||
query.push(...myquery);
|
||||
|
||||
}
|
||||
|
||||
if (newvers) {
|
||||
@@ -2061,7 +2089,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
async executeQueryTable(mythistable, idapp, params, user) {
|
||||
let query = this.getQueryTable(idapp, params, user);
|
||||
let query = await this.getQueryTable(idapp, params, user);
|
||||
|
||||
try {
|
||||
// console.log('query', query);
|
||||
@@ -2104,7 +2132,7 @@ module.exports = {
|
||||
// Before check if exist more than 1 record in the destination,
|
||||
// if Yes don't copy
|
||||
if (numrec <= 0) {
|
||||
return mythistable.findAllIdApp(idapporig).then(async (arrrec) => {
|
||||
return await mythistable.findAllIdApp(idapporig).then(async (arrrec) => {
|
||||
let num = 0;
|
||||
|
||||
for (let ind = 0; ind < arrrec.length; ind++) {
|
||||
|
||||
@@ -369,7 +369,7 @@ module.exports = {
|
||||
if (params.sendreally) {
|
||||
if (tools.isBitActive(params.typesend, shared_consts.TypeSend.PUSH_NOTIFICATION)) {
|
||||
const myparam = {...params};
|
||||
risult = tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag,
|
||||
risult = await tools.sendNotificationToUser(user._id, mytitle, mycontent, myparam.openUrl, myparam.openUrl2, myparam.tag,
|
||||
myparam.actions, myparam.id).
|
||||
then(ris => {
|
||||
|
||||
@@ -420,7 +420,7 @@ module.exports = {
|
||||
params.sendreally = true;
|
||||
params.typesend = shared_consts.TypeSend.PUSH_NOTIFICATION;
|
||||
|
||||
return this.SendMsgToParam(idapp, params);
|
||||
return await this.SendMsgToParam(idapp, params);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = {
|
||||
ALL_SAW_AND_ACCEPTED: 3,
|
||||
QUERYTYPE_CIRCUIT: 10,
|
||||
QUERYTYPE_REFUSED_USER_CIRCUIT: 12,
|
||||
QUERYTYPE_LIST_MOVEMENTS: 15,
|
||||
// ---------------------
|
||||
|
||||
FILTER_EXTRALIST_NOT_REGISTERED: 1,
|
||||
@@ -344,6 +345,8 @@ module.exports = {
|
||||
STATUS_BLOCKED: 55,
|
||||
STATUS_DELETED: 56,
|
||||
STATUS_REMOVED: 57,
|
||||
STATUS_COINS_ACCEPTED: 60,
|
||||
STATUS_COINS_REFUSED: 61,
|
||||
},
|
||||
|
||||
TypeNotifs: {
|
||||
@@ -385,6 +388,8 @@ module.exports = {
|
||||
ID_CIRCUIT_ADDED_ADMIN: 128,
|
||||
ID_CIRCUIT_REMOVED_ADMIN: 256,
|
||||
ID_CIRCUIT_SENDCOINSREQ: 512,
|
||||
ID_CIRCUIT_COINS_ACCEPTED: 1024,
|
||||
ID_CIRCUIT_COINS_REFUSED: 2048,
|
||||
|
||||
TYPEDIR_BOOKING: 6,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user