Circuits OK
Accounts Ok Movements OK
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
var mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ mongoose.plugin(schema => {
|
|||||||
schema.options.usePushEach = true
|
schema.options.usePushEach = true
|
||||||
});
|
});
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
// user: process.env.UDB,
|
// user: process.env.UDB,
|
||||||
@@ -17,7 +17,8 @@ const options = {
|
|||||||
// useMongoClient: true,
|
// useMongoClient: true,
|
||||||
// useMongoClient: false,
|
// useMongoClient: false,
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
// useFindAndModify: false,
|
// useFindAndModify: true,
|
||||||
|
useFindAndModify: false,
|
||||||
// useCreateIndex: true,
|
// useCreateIndex: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,9 @@
|
|||||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %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.",
|
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
||||||
|
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "%s %s accettati da %s.",
|
||||||
|
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s.",
|
||||||
|
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s.",
|
||||||
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa",
|
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa",
|
||||||
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
|
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
|
||||||
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
||||||
|
|||||||
@@ -52,7 +52,11 @@
|
|||||||
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei 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_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.",
|
||||||
|
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando %s %s a %s.",
|
||||||
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
"ID_CIRCUIT_COINS_ACCEPTED": "%s %s accettati da %s.",
|
||||||
|
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "%s %s sono stati accettati da %s.",
|
||||||
|
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s.",
|
||||||
|
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s.",
|
||||||
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa",
|
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa",
|
||||||
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
|
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
|
||||||
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Account is a User's single Circuit
|
Account is a User's single Circuit
|
||||||
*/
|
*/
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
@@ -18,7 +18,10 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const AccountSchema = new Schema({
|
const AccountSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
|
default: function () {
|
||||||
|
return new ObjectID().toString()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -27,7 +30,7 @@ const AccountSchema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
circuitId: { // ----- REF TO Circuit
|
circuitId: { // ----- REF TO Circuit
|
||||||
type: Number,
|
type: String,
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -72,16 +75,7 @@ AccountSchema.statics.findAllIdApp = async function(idapp) {
|
|||||||
|
|
||||||
AccountSchema.pre('save', async function(next) {
|
AccountSchema.pre('save', async function(next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await Account.findOne().limit(1).sort({_id: -1});
|
this._id = new ObjectID().toString()
|
||||||
if (!!myrec) {
|
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -130,6 +124,14 @@ AccountSchema.statics.addtoSaldo = async function(id, amount) {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AccountSchema.pre('save', async function(next) {
|
||||||
|
if (this.isNew) {
|
||||||
|
this.date_created = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, username, {circuitId, circuitName}, createifnotexist) {
|
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, username, {circuitId, circuitName}, createifnotexist) {
|
||||||
const Account = this;
|
const Account = this;
|
||||||
|
|
||||||
@@ -152,12 +154,19 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
|
|||||||
myquery.circuitName = circuitName;
|
myquery.circuitName = circuitName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mycircuit = await Circuit.getCircuitById(circuitId);
|
let mycircuit;
|
||||||
|
if (circuitId)
|
||||||
|
mycircuit = await Circuit.getCircuitById(circuitId);
|
||||||
|
else
|
||||||
|
mycircuit = await Circuit.findOne({name: circuitName}).lean();
|
||||||
|
|
||||||
|
|
||||||
|
if (mycircuit) {
|
||||||
let myaccount = await Account.findOne(myquery).lean();
|
let myaccount = await Account.findOne(myquery).lean();
|
||||||
|
|
||||||
if (!myaccount && createifnotexist) {
|
if (!myaccount && createifnotexist) {
|
||||||
myaccount = new Account({
|
myaccount = new Account({
|
||||||
|
_id: new ObjectID().toString(),
|
||||||
idapp,
|
idapp,
|
||||||
username,
|
username,
|
||||||
circuitId: mycircuit._id,
|
circuitId: mycircuit._id,
|
||||||
@@ -172,6 +181,8 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
return myaccount;
|
return myaccount;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('error', e);
|
console.error('error', e);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
@@ -17,7 +17,10 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const CircuitSchema = new Schema({
|
const CircuitSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
|
default: function () {
|
||||||
|
return new ObjectID().toString()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -165,16 +168,7 @@ const CircuitSchema = new Schema({
|
|||||||
|
|
||||||
CircuitSchema.pre('save', async function(next) {
|
CircuitSchema.pre('save', async function(next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await Circuit.findOne().limit(1).sort({_id: -1});
|
this._id = new ObjectID().toString();
|
||||||
if (!!myrec) {
|
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.date_created = new Date();
|
this.date_created = new Date();
|
||||||
}
|
}
|
||||||
@@ -210,7 +204,7 @@ CircuitSchema.statics.executeQueryTable = function(idapp, params) {
|
|||||||
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
|
||||||
// FOR ME, PERMIT ALL
|
// FOR ME, PERMIT ALL
|
||||||
return {
|
return {
|
||||||
circuitId: 1,
|
_id: 1,
|
||||||
groupnameId: 1,
|
groupnameId: 1,
|
||||||
path: 1,
|
path: 1,
|
||||||
name: 1,
|
name: 1,
|
||||||
@@ -245,7 +239,6 @@ CircuitSchema.statics.removeAdminOfMyCircuit = async function(idapp, username, n
|
|||||||
|
|
||||||
CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||||
return {
|
return {
|
||||||
circuitId: 1,
|
|
||||||
groupnameId: 1,
|
groupnameId: 1,
|
||||||
path: 1,
|
path: 1,
|
||||||
name: 1,
|
name: 1,
|
||||||
@@ -271,7 +264,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, req) {
|
CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, user) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {User} = require('../models/user');
|
const {User} = require('../models/user');
|
||||||
@@ -327,7 +320,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, re
|
|||||||
asked_circuits,
|
asked_circuits,
|
||||||
refused_circuits,
|
refused_circuits,
|
||||||
manage_mycircuits,
|
manage_mycircuits,
|
||||||
mycircuits: req.user.profile.mycircuits,
|
mycircuits: user.profile.mycircuits,
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -381,7 +374,7 @@ CircuitSchema.statics.getCircuitByName = async function(idapp, name) {
|
|||||||
CircuitSchema.statics.getCircuitById = async function(circuitId) {
|
CircuitSchema.statics.getCircuitById = async function(circuitId) {
|
||||||
|
|
||||||
const myfind = {
|
const myfind = {
|
||||||
circuitId,
|
_id: circuitId,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const escapeStringRegexp = require('escape-string-regexp');
|
const escapeStringRegexp = require('escape-string-regexp');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var bcrypt = require('bcryptjs');
|
var bcrypt = require('bcryptjs');
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -16,7 +16,7 @@ mongoose.plugin(schema => {
|
|||||||
schema.options.usePushEach = true
|
schema.options.usePushEach = true
|
||||||
});
|
});
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
var ExtraListSchema = new mongoose.Schema({
|
var ExtraListSchema = new mongoose.Schema({
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const bcrypt = require('bcryptjs');
|
const bcrypt = require('bcryptjs');
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -20,7 +20,7 @@ mongoose.plugin(schema => {
|
|||||||
schema.options.usePushEach = true
|
schema.options.usePushEach = true
|
||||||
});
|
});
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
const GraduatoriaSchema = new mongoose.Schema({
|
const GraduatoriaSchema = new mongoose.Schema({
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
@@ -16,7 +16,10 @@ mongoose.plugin(schema => {
|
|||||||
|
|
||||||
const MovementSchema = new Schema({
|
const MovementSchema = new Schema({
|
||||||
_id: {
|
_id: {
|
||||||
type: Number,
|
type: String,
|
||||||
|
default: function () {
|
||||||
|
return new ObjectID().toString()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -25,10 +28,10 @@ const MovementSchema = new Schema({
|
|||||||
type: Date,
|
type: Date,
|
||||||
},
|
},
|
||||||
accountFromId: {
|
accountFromId: {
|
||||||
type: Number,
|
type: String,
|
||||||
},
|
},
|
||||||
accountToId: {
|
accountToId: {
|
||||||
type: Number,
|
type: String,
|
||||||
},
|
},
|
||||||
causal_table: {
|
causal_table: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -62,16 +65,8 @@ MovementSchema.statics.findAllIdApp = async function(idapp) {
|
|||||||
|
|
||||||
MovementSchema.pre('save', async function(next) {
|
MovementSchema.pre('save', async function(next) {
|
||||||
if (this.isNew) {
|
if (this.isNew) {
|
||||||
const myrec = await Movement.findOne().limit(1).sort({_id: -1});
|
|
||||||
if (!!myrec) {
|
|
||||||
if (myrec._doc._id === 0)
|
|
||||||
this._id = 1;
|
|
||||||
else
|
|
||||||
this._id = myrec._doc._id + 1;
|
|
||||||
|
|
||||||
} else {
|
this.transactionDate = new Date();
|
||||||
this._id = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -94,6 +89,7 @@ MovementSchema.statics.addMov = async function(idapp, accountFromId, accountToId
|
|||||||
try {
|
try {
|
||||||
let mymov = Movement(
|
let mymov = Movement(
|
||||||
{
|
{
|
||||||
|
_id: new ObjectID().toString(),
|
||||||
idapp,
|
idapp,
|
||||||
transactionDate: new Date(),
|
transactionDate: new Date(),
|
||||||
accountFromId: accountFromId._id,
|
accountFromId: accountFromId._id,
|
||||||
@@ -105,12 +101,15 @@ MovementSchema.statics.addMov = async function(idapp, accountFromId, accountToId
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const rismov = await mymov.save();
|
||||||
|
if (rismov) {
|
||||||
// Update saldo dell'Account
|
// Update saldo dell'Account
|
||||||
Account.addtoSaldo(accountToId, amount);
|
Account.addtoSaldo(accountToId, amount);
|
||||||
|
|
||||||
Account.addtoSaldo(accountFromId, -amount);
|
Account.addtoSaldo(accountFromId, -amount);
|
||||||
|
|
||||||
return await mymov.save();
|
return rismov;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error in addMov', e.message);
|
console.error('Error in addMov', e.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
var mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ mongoose.plugin(schema => {
|
|||||||
schema.options.usePushEach = true
|
schema.options.usePushEach = true
|
||||||
});
|
});
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
var ProjectSchema = new mongoose.Schema({
|
var ProjectSchema = new mongoose.Schema({
|
||||||
idapp: {
|
idapp: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const escapeStringRegexp = require('escape-string-regexp');
|
const escapeStringRegexp = require('escape-string-regexp');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
@@ -84,7 +84,6 @@ const sendNotifSchema = new Schema({
|
|||||||
options: {
|
options: {
|
||||||
type: Array,
|
type: Array,
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
||||||
@@ -326,10 +325,27 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
|
|||||||
recnotif.paramsObj.extrarec.symbol);
|
recnotif.paramsObj.extrarec.symbol);
|
||||||
tag = 'sendcoin';
|
tag = 'sendcoin';
|
||||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT) {
|
||||||
|
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_ME', recnotif.paramsObj.extrarec.qty.toString(),
|
||||||
|
recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.dest);
|
||||||
|
tag = 'sendcoin';
|
||||||
|
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED) {
|
||||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||||
recnotif.paramsObj.username_action);
|
recnotif.paramsObj.username_action);
|
||||||
tag = 'sendcoin';
|
tag = 'sendcoin';
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT) {
|
||||||
|
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||||
|
recnotif.paramsObj.extrarec.dest);
|
||||||
|
tag = 'sendcoin';
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
|
||||||
|
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||||
|
recnotif.paramsObj.username_action);
|
||||||
|
tag = 'sendcoin';
|
||||||
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
|
||||||
|
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||||
|
recnotif.paramsObj.extrarec.dest);
|
||||||
|
tag = 'sendcoin';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +485,9 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
|||||||
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_DELETED;
|
newstatus = shared_consts.GroupsNotifs.STATUS_GROUPS_DELETED;
|
||||||
}
|
}
|
||||||
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||||
|
if (myrecnotif.paramsObj.extrarec)
|
||||||
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifId;
|
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifId;
|
||||||
|
|
||||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
|
||||||
dest = myrecnotif.dest;
|
dest = myrecnotif.dest;
|
||||||
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||||
@@ -490,6 +508,14 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
|||||||
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED) {
|
||||||
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||||
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_REFUSED;
|
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_REFUSED;
|
||||||
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT) {
|
||||||
|
if (myrecnotif.paramsObj.extrarec.hasOwnProperty('notifIdToUpdate'))
|
||||||
|
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifIdToUpdate;
|
||||||
|
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_ACCEPTED_SENT;
|
||||||
|
} else if (myrecnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
|
||||||
|
if (myrecnotif.paramsObj.extrarec.hasOwnProperty('notifIdToUpdate'))
|
||||||
|
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifIdToUpdate;
|
||||||
|
newstatus = shared_consts.CircuitsNotif.STATUS_COINS_REFUSED_SENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,12 +689,11 @@ sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, pa
|
|||||||
|
|
||||||
myrecnotif = this.getExtraParam(myrecnotif, paramsObj);
|
myrecnotif = this.getExtraParam(myrecnotif, paramsObj);
|
||||||
|
|
||||||
await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave);
|
return await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave);
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('createNewNotification', e);
|
console.error('createNewNotification', e);
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -773,7 +798,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
|||||||
if (send) {
|
if (send) {
|
||||||
let myrecnotif = new SendNotif(myrecnotifpass);
|
let myrecnotif = new SendNotif(myrecnotifpass);
|
||||||
myrecnotif.dest = user.username;
|
myrecnotif.dest = user.username;
|
||||||
await SendNotif.saveAndSendNotif(myrecnotif, req, res, user);
|
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -795,9 +820,9 @@ sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, r
|
|||||||
: myrecnotif.dest;
|
: myrecnotif.dest;
|
||||||
|
|
||||||
if (onlysave) {
|
if (onlysave) {
|
||||||
await SendNotif.saveNotif(myrecnotif);
|
return await SendNotif.saveNotif(myrecnotif);
|
||||||
} else {
|
} else {
|
||||||
await SendNotif.saveAndSendNotif(myrecnotif, req, res, null);
|
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
@@ -6,7 +6,7 @@ const tools = require('../tools/general');
|
|||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
var mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ mongoose.plugin(schema => {
|
|||||||
schema.options.usePushEach = true
|
schema.options.usePushEach = true
|
||||||
});
|
});
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
var TodoSchema = new mongoose.Schema({
|
var TodoSchema = new mongoose.Schema({
|
||||||
userId: {
|
userId: {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const bcrypt = require('bcryptjs');
|
const bcrypt = require('bcryptjs');
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -32,7 +32,7 @@ mongoose.plugin(schema => {
|
|||||||
schema.options.usePushEach = true;
|
schema.options.usePushEach = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
const UserSchema = new mongoose.Schema({
|
const UserSchema = new mongoose.Schema({
|
||||||
userId: {
|
userId: {
|
||||||
@@ -2107,6 +2107,9 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
|
|||||||
// Elimina eventualmente se era bloccato:
|
// Elimina eventualmente se era bloccato:
|
||||||
update = {$pull: {refused_users: {username: {$in: [usernameOrig]}}}};
|
update = {$pull: {refused_users: {username: {$in: [usernameOrig]}}}};
|
||||||
await Circuit.updateOne({idapp, name: circuitname}, update);
|
await Circuit.updateOne({idapp, name: circuitname}, update);
|
||||||
|
|
||||||
|
await Account.createAccount(idapp, usernameOrig, circuitname);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ris = false;
|
ris = false;
|
||||||
}
|
}
|
||||||
@@ -2137,7 +2140,6 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
|
|||||||
};
|
};
|
||||||
ris = await Circuit.updateOne({idapp, name: circuitname}, update);
|
ris = await Circuit.updateOne({idapp, name: circuitname}, update);
|
||||||
|
|
||||||
await Account.createAccount(idapp, usernameOrig, circuitname);
|
|
||||||
}
|
}
|
||||||
if (ris) {
|
if (ris) {
|
||||||
// Invia una notifica alla persona
|
// Invia una notifica alla persona
|
||||||
@@ -2215,7 +2217,7 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
|
|||||||
|
|
||||||
ris = ris2;
|
ris = ris2;
|
||||||
|
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
} else if ((cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) || (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE)) {
|
||||||
// Before to accept, I see if it's already set !
|
// Before to accept, I see if it's already set !
|
||||||
|
|
||||||
let ris2 = {
|
let ris2 = {
|
||||||
@@ -2231,7 +2233,11 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
|
|||||||
risStatus = i18n.__('STATUS_REFUSED');
|
risStatus = i18n.__('STATUS_REFUSED');
|
||||||
}
|
}
|
||||||
if (!await SendNotif.checkIfCoinsAlreadySent(extrarec.notifId)) {
|
if (!await SendNotif.checkIfCoinsAlreadySent(extrarec.notifId)) {
|
||||||
|
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||||
ris2 = await Circuit.sendCoins(false, idapp, usernameOrig, extrarec);
|
ris2 = await Circuit.sendCoins(false, idapp, usernameOrig, extrarec);
|
||||||
|
} else {
|
||||||
|
ris2.cansend = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (ris2.cansend) {
|
if (ris2.cansend) {
|
||||||
// Invia una notifica di moneta alla persona
|
// Invia una notifica di moneta alla persona
|
||||||
@@ -2239,6 +2245,8 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
|
|||||||
}
|
}
|
||||||
|
|
||||||
ris2.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
|
ris2.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
|
||||||
|
|
||||||
|
ris2.user = await User.getExtraInfoByUsername(idapp, username_action);
|
||||||
} else {
|
} else {
|
||||||
ris2.cansend = false;
|
ris2.cansend = false;
|
||||||
|
|
||||||
@@ -3734,7 +3742,18 @@ UserSchema.statics.DbOp = async function(idapp, mydata) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
UserSchema.statics.addExtraInfo = async function(idapp, recUser, req) {
|
UserSchema.statics.getExtraInfoByUsername = async function(idapp, username) {
|
||||||
|
const User = this;
|
||||||
|
|
||||||
|
let myuser = await User.findOne({idapp, username});
|
||||||
|
if (myuser) {
|
||||||
|
myuserextra = await User.addExtraInfo(idapp, myuser);
|
||||||
|
}
|
||||||
|
|
||||||
|
return myuser._doc;
|
||||||
|
|
||||||
|
};
|
||||||
|
UserSchema.statics.addExtraInfo = async function(idapp, recUser) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const listSentMyRequestFriends = await User.find({
|
const listSentMyRequestFriends = await User.find({
|
||||||
@@ -3795,7 +3814,7 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser, req) {
|
|||||||
|
|
||||||
// Circuit>
|
// Circuit>
|
||||||
|
|
||||||
const circuitobj = await Circuit.getCircuitsByUsername(idapp, recUser.username, req);
|
const circuitobj = await Circuit.getCircuitsByUsername(idapp, recUser.username, recUser);
|
||||||
|
|
||||||
const useraccounts = await Account.getUserAccounts(idapp, recUser.username);
|
const useraccounts = await Account.getUserAccounts(idapp, recUser.username);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
var mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
var variantSchema = mongoose.Schema({
|
var variantSchema = mongoose.Schema({
|
||||||
productID: {
|
productID: {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
const Path = require('path');
|
const Path = require('path');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const {CfgServer} = require('../models/cfgserver');
|
const {CfgServer} = require('../models/cfgserver');
|
||||||
|
|
||||||
const shared_consts = require('../tools/shared_nodejs');
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
//const { ListaIngresso } = require('../../models/listaingresso');
|
//const { ListaIngresso } = require('../../models/listaingresso');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
const {authenticate} = require('../middleware/authenticate');
|
const {authenticate} = require('../middleware/authenticate');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
|
|
||||||
const {User} = require('../models/user');
|
const {User} = require('../models/user');
|
||||||
const {Circuit} = require('../models/circuit');
|
const {Circuit} = require('../models/circuit');
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const {ObjectID} = require('mongodb');
|
|||||||
// const {ListaIngresso} = require('../models/listaingresso');
|
// const {ListaIngresso} = require('../models/listaingresso');
|
||||||
const {Graduatoria} = require('../models/graduatoria');
|
const {Graduatoria} = require('../models/graduatoria');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const {CfgServer} = require('../models/cfgserver');
|
const {CfgServer} = require('../models/cfgserver');
|
||||||
|
|
||||||
// const uuidv4 = require('uuid/v4'); // I chose v4 ‒ you can select others
|
// const uuidv4 = require('uuid/v4'); // I chose v4 ‒ you can select others
|
||||||
@@ -305,7 +305,8 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
mytablerec.isNew = false;
|
mytablerec.isNew = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
|
if (shared_consts.TABLES_ID_NUMBER.includes(params.table) ||
|
||||||
|
shared_consts.TABLES_ID_STRING.includes(params.table)) {
|
||||||
|
|
||||||
} else if (params.table === 'hours') {
|
} else if (params.table === 'hours') {
|
||||||
|
|
||||||
@@ -347,6 +348,8 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
mytablerec.date_updated = new Date();
|
mytablerec.date_updated = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('mydata',mydata);
|
||||||
|
|
||||||
return await mytablerec.save().
|
return await mytablerec.save().
|
||||||
then(async (rec) => {
|
then(async (rec) => {
|
||||||
|
|
||||||
@@ -1237,7 +1240,7 @@ function load(req, res, version) {
|
|||||||
let myuserextra = null;
|
let myuserextra = null;
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
// askedfriends = User.getAskedFriendsByUsername(idapp, req.user.username);
|
// askedfriends = User.getAskedFriendsByUsername(idapp, req.user.username);
|
||||||
myuserextra = User.addExtraInfo(idapp, req.user, req);
|
myuserextra = User.addExtraInfo(idapp, req.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const _ = require('lodash');
|
|||||||
|
|
||||||
const { authenticate } = require('../middleware/authenticate');
|
const { authenticate } = require('../middleware/authenticate');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
|
|
||||||
// POST /iscritti_conacreis
|
// POST /iscritti_conacreis
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
var {authenticate, auth_default} = require('../middleware/authenticate');
|
var {authenticate, auth_default} = require('../middleware/authenticate');
|
||||||
|
|
||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
var mongoose = require('mongoose').set('debug', false);
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
var {authenticate, auth_default} = require('../middleware/authenticate');
|
var {authenticate, auth_default} = require('../middleware/authenticate');
|
||||||
|
|
||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
var mongoose = require('mongoose').set('debug', false);
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
const {authenticate} = require('../middleware/authenticate');
|
const {authenticate} = require('../middleware/authenticate');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
|
|
||||||
const {User} = require('../models/user');
|
const {User} = require('../models/user');
|
||||||
const {MyGroup} = require('../models/mygroup');
|
const {MyGroup} = require('../models/mygroup');
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
var {authenticate, auth_default} = require('../middleware/authenticate');
|
var {authenticate, auth_default} = require('../middleware/authenticate');
|
||||||
|
|
||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
var mongoose = require('mongoose').set('debug', false);
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ var { Project } = require('../models/project');
|
|||||||
|
|
||||||
var { authenticate, auth_default } = require('../middleware/authenticate');
|
var { authenticate, auth_default } = require('../middleware/authenticate');
|
||||||
|
|
||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
var mongoose = require('mongoose').set('debug', false)
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
const { authenticate } = require('../middleware/authenticate');
|
const { authenticate } = require('../middleware/authenticate');
|
||||||
|
|
||||||
// var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
// var mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
const { Project } = require('../models/project');
|
const { Project } = require('../models/project');
|
||||||
const { Todo } = require('../models/todo');
|
const { Todo } = require('../models/todo');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
// const q = require('q');
|
// const q = require('q');
|
||||||
const webpush = require('web-push');
|
const webpush = require('web-push');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
const { authenticate } = require('../middleware/authenticate');
|
const { authenticate } = require('../middleware/authenticate');
|
||||||
|
|
||||||
// var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
// var mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
const { Project } = require('../models/project');
|
const { Project } = require('../models/project');
|
||||||
const { Todo } = require('../models/todo');
|
const { Todo } = require('../models/todo');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
|
|||||||
|
|
||||||
const { authenticate } = require('../middleware/authenticate');
|
const { authenticate } = require('../middleware/authenticate');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
// const { Nave } = require('../models/nave');
|
// const { Nave } = require('../models/nave');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var { Project } = require('../models/project');
|
|||||||
|
|
||||||
var { authenticate } = require('../middleware/authenticate');
|
var { authenticate } = require('../middleware/authenticate');
|
||||||
|
|
||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
var mongoose = require('mongoose').set('debug', false)
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
var { Todo } = require('../models/todo');
|
var { Todo } = require('../models/todo');
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const TypedError = require('../modules/ErrorHandler');
|
|||||||
const {MyGroup} = require('../models/mygroup');
|
const {MyGroup} = require('../models/mygroup');
|
||||||
const {Circuit} = require('../models/circuit');
|
const {Circuit} = require('../models/circuit');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
|
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ router.post('/circuits', authenticate, (req, res) => {
|
|||||||
idapp = req.body.idapp;
|
idapp = req.body.idapp;
|
||||||
locale = req.body.locale;
|
locale = req.body.locale;
|
||||||
|
|
||||||
return Circuit.getCircuitsByUsername(idapp, username, req).then((ris) => {
|
return Circuit.getCircuitsByUsername(idapp, username, req.user).then((ris) => {
|
||||||
res.send(ris);
|
res.send(ris);
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
tools.mylog('ERRORE IN circuits: ' + e.message);
|
tools.mylog('ERRORE IN circuits: ' + e.message);
|
||||||
@@ -731,11 +731,13 @@ router.post('/circuits/cmd', authenticate, async (req, res) => {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
return await User.setCircuitCmd(idapp, usernameOrig, circuitname, cmd, value, usernameLogged, extrarec).
|
return await User.setCircuitCmd(idapp, usernameOrig, circuitname, cmd, value, usernameLogged, extrarec).
|
||||||
then((ris) => {
|
then(async (ris) => {
|
||||||
|
|
||||||
// Check if ìs a Notif to read
|
// Check if ìs a Notif to read
|
||||||
|
if (extrarec && extrarec.hasOwnProperty('idnotif')) {
|
||||||
const idnotif = extrarec['idnotif'] ? extrarec['idnotif'] : '';
|
const idnotif = extrarec['idnotif'] ? extrarec['idnotif'] : '';
|
||||||
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
await SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
||||||
|
}
|
||||||
|
|
||||||
return res.send(ris);
|
return res.send(ris);
|
||||||
}).
|
}).
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ const tools = require('./tools/general');
|
|||||||
|
|
||||||
const shared_consts = require('./tools/shared_nodejs');
|
const shared_consts = require('./tools/shared_nodejs');
|
||||||
|
|
||||||
var mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
var mongoose = require('mongoose').set('debug', false);
|
||||||
|
|
||||||
mongoose.set('debug', process.env.DEBUG);
|
mongoose.set('debug', false);
|
||||||
|
|
||||||
const {CfgServer} = require('./models/cfgserver');
|
const {CfgServer} = require('./models/cfgserver');
|
||||||
const {ObjectID} = require('mongodb');
|
const {ObjectID} = require('mongodb');
|
||||||
|
|||||||
@@ -822,6 +822,8 @@ const MyTelegramBot = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const cl = getclTelegByidapp(idapp);
|
const cl = getclTelegByidapp(idapp);
|
||||||
|
if (!cl)
|
||||||
|
return false;
|
||||||
|
|
||||||
const langdest = myuser.lang;
|
const langdest = myuser.lang;
|
||||||
const telegid = myuser.profile.teleg_id;
|
const telegid = myuser.profile.teleg_id;
|
||||||
@@ -908,6 +910,8 @@ const MyTelegramBot = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const cl = getclTelegByidapp(idapp);
|
const cl = getclTelegByidapp(idapp);
|
||||||
|
if (!cl)
|
||||||
|
return false;
|
||||||
|
|
||||||
const {SendNotif} = require('../models/sendnotif');
|
const {SendNotif} = require('../models/sendnotif');
|
||||||
|
|
||||||
@@ -949,7 +953,7 @@ const MyTelegramBot = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sendnotif) {
|
if (sendnotif) {
|
||||||
const req = this.getReqByPar(idapp, username);
|
const req = tools.getReqByPar(idapp, username);
|
||||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||||
await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, true, typedir, typeid);
|
await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, true, typedir, typeid);
|
||||||
}
|
}
|
||||||
@@ -3820,7 +3824,7 @@ if (true) {
|
|||||||
username: dataarr[1] ? dataarr[1] : '',
|
username: dataarr[1] ? dataarr[1] : '',
|
||||||
userDest: dataarr[2] ? dataarr[2] : '',
|
userDest: dataarr[2] ? dataarr[2] : '',
|
||||||
groupId: dataarr[3] ? parseInt(dataarr[3]) : '',
|
groupId: dataarr[3] ? parseInt(dataarr[3]) : '',
|
||||||
circuitId: dataarr[4] ? parseInt(dataarr[4]) : '',
|
circuitId: dataarr[4] ? dataarr[4] : '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3942,7 +3946,7 @@ if (true) {
|
|||||||
|
|
||||||
if (circuit) {
|
if (circuit) {
|
||||||
cmd = shared_consts.CIRCUITCMD.SET;
|
cmd = shared_consts.CIRCUITCMD.SET;
|
||||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
constF foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||||
|
|
||||||
if (!foundIfAlreadyCircuit) {
|
if (!foundIfAlreadyCircuit) {
|
||||||
// Aggiungilo nel Circuito
|
// Aggiungilo nel Circuito
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const userjson = JSON.stringify(users[0]);
|
|||||||
|
|
||||||
const mynewID = new ObjectID();
|
const mynewID = new ObjectID();
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
|
|
||||||
var ObjectId = mongoose.Types.ObjectId;
|
var ObjectId = mongoose.Types.ObjectId;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const {ObjectID} = require('mongodb');
|
|||||||
|
|
||||||
const shared_consts = require('./shared_nodejs');
|
const shared_consts = require('./shared_nodejs');
|
||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Subscription = mongoose.model('subscribers');
|
const Subscription = mongoose.model('subscribers');
|
||||||
|
|
||||||
const server_constants = require('./server_constants');
|
const server_constants = require('./server_constants');
|
||||||
@@ -1070,10 +1070,16 @@ module.exports = {
|
|||||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN;
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_REMOVED_ADMIN;
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
|
||||||
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT) {
|
||||||
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
|
||||||
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) {
|
||||||
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT;
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||||
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
|
||||||
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT) {
|
||||||
|
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1143,10 +1149,30 @@ module.exports = {
|
|||||||
let ris = false;
|
let ris = false;
|
||||||
let inviato = false;
|
let inviato = false;
|
||||||
|
|
||||||
|
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ || cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT || cmd ===
|
||||||
|
shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||||
|
|
||||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ || cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT || cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE ) {
|
let recnotif = null;
|
||||||
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path, null,
|
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
|
||||||
|
recnotif = await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REQ_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||||
false, '', extrarec);
|
false, '', extrarec);
|
||||||
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
|
||||||
|
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||||
|
false, '', extrarec);
|
||||||
|
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||||
|
await this.sendNotifCircuitByUsername(shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT, idapp, extrarec.dest, usernameOrig, username_action, circuitname, circuit.path, null,
|
||||||
|
false, '', extrarec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (recnotif)
|
||||||
|
extrarec.notifIdToUpdate = recnotif._id;
|
||||||
|
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, extrarec.dest, username_action, circuitname, circuit.path,
|
||||||
|
null,
|
||||||
|
false, '', extrarec);
|
||||||
|
|
||||||
|
extrarec.notifIdToUpdate = '';
|
||||||
|
|
||||||
|
|
||||||
if (ris)
|
if (ris)
|
||||||
inviato = true;
|
inviato = true;
|
||||||
@@ -1170,7 +1196,8 @@ module.exports = {
|
|||||||
|
|
||||||
if (!giainviato && cmd !== shared_consts.CIRCUITCMD.REQ) {
|
if (!giainviato && cmd !== shared_consts.CIRCUITCMD.REQ) {
|
||||||
// SEND TO THE USER DEST THE NOTIFICATION
|
// SEND TO THE USER DEST THE NOTIFICATION
|
||||||
ris = 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);
|
false, '', extrarec);
|
||||||
if (ris)
|
if (ris)
|
||||||
inviato = true;
|
inviato = true;
|
||||||
@@ -1581,7 +1608,7 @@ module.exports = {
|
|||||||
|
|
||||||
myquery = {};
|
myquery = {};
|
||||||
|
|
||||||
if (shared_consts.TABLES_ID_NUMBER.includes(params.table)) {
|
if (shared_consts.TABLES_ID_NUMBER.includes(params.table) || shared_consts.TABLES_ID_STRING.includes(params.table)) {
|
||||||
myquery = {
|
myquery = {
|
||||||
$match: {
|
$match: {
|
||||||
$expr: {
|
$expr: {
|
||||||
|
|||||||
@@ -73,13 +73,16 @@ module.exports = {
|
|||||||
SET: 2001,
|
SET: 2001,
|
||||||
REMOVE_FROM_MYLIST: 2144,
|
REMOVE_FROM_MYLIST: 2144,
|
||||||
REFUSE_REQ: 2145,
|
REFUSE_REQ: 2145,
|
||||||
CANCEL_REQ: 1146,
|
CANCEL_REQ: 2146,
|
||||||
DELETE: 2170,
|
DELETE: 2170,
|
||||||
ADDADMIN: 2180,
|
ADDADMIN: 2180,
|
||||||
REMOVEADMIN: 2185,
|
REMOVEADMIN: 2185,
|
||||||
SENDCOINS_REQ: 2200,
|
SENDCOINS_REQ: 2200,
|
||||||
|
SENDCOINS_REQ_SENT: 2205,
|
||||||
SENDCOINS_ACCEPT: 2210,
|
SENDCOINS_ACCEPT: 2210,
|
||||||
|
SENDCOINS_ACCEPT_SENT: 2212,
|
||||||
SENDCOINS_REFUSE: 2220,
|
SENDCOINS_REFUSE: 2220,
|
||||||
|
SENDCOINS_REFUSE_SENT: 2222,
|
||||||
},
|
},
|
||||||
|
|
||||||
REPORT_FILT_RESP: 1,
|
REPORT_FILT_RESP: 1,
|
||||||
@@ -129,7 +132,7 @@ module.exports = {
|
|||||||
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
|
||||||
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
TABLES_REC_ID: ['skills', 'goods', 'subskills'],
|
||||||
|
|
||||||
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups'],
|
TABLES_VISU_STAT_IN_HOME: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'mygroups', 'circuits'],
|
||||||
|
|
||||||
TABLES_ADV_NOTIFICATION: ['myskills', 'myhosps', 'mygoods'],
|
TABLES_ADV_NOTIFICATION: ['myskills', 'myhosps', 'mygoods'],
|
||||||
TABLES_EVENTS_NOTIFICATION: ['mybachecas'],
|
TABLES_EVENTS_NOTIFICATION: ['mybachecas'],
|
||||||
@@ -138,6 +141,12 @@ module.exports = {
|
|||||||
|
|
||||||
TABLES_NUM_AS_ID_NUMBER: [ ],
|
TABLES_NUM_AS_ID_NUMBER: [ ],
|
||||||
|
|
||||||
|
TABLES_ID_STRING: [
|
||||||
|
'circuits',
|
||||||
|
'accounts',
|
||||||
|
'movements',
|
||||||
|
],
|
||||||
|
|
||||||
TABLES_ID_NUMBER: [
|
TABLES_ID_NUMBER: [
|
||||||
'permissions',
|
'permissions',
|
||||||
'levels',
|
'levels',
|
||||||
@@ -155,9 +164,8 @@ module.exports = {
|
|||||||
'mybachecas',
|
'mybachecas',
|
||||||
'myhosps',
|
'myhosps',
|
||||||
'mygoods',
|
'mygoods',
|
||||||
'mygroups',
|
'mygroups'
|
||||||
'circuits',
|
],
|
||||||
'movements'],
|
|
||||||
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
|
||||||
TABLES_CREATEDBY: ['mygroups', 'circuits'],
|
TABLES_CREATEDBY: ['mygroups', 'circuits'],
|
||||||
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits'],
|
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits'],
|
||||||
@@ -348,6 +356,8 @@ module.exports = {
|
|||||||
STATUS_REMOVED: 57,
|
STATUS_REMOVED: 57,
|
||||||
STATUS_COINS_ACCEPTED: 60,
|
STATUS_COINS_ACCEPTED: 60,
|
||||||
STATUS_COINS_REFUSED: 61,
|
STATUS_COINS_REFUSED: 61,
|
||||||
|
STATUS_COINS_ACCEPTED_SENT: 62,
|
||||||
|
STATUS_COINS_REFUSED_SENT: 63,
|
||||||
},
|
},
|
||||||
|
|
||||||
TypeNotifs: {
|
TypeNotifs: {
|
||||||
@@ -391,6 +401,9 @@ module.exports = {
|
|||||||
ID_CIRCUIT_SENDCOINSREQ: 512,
|
ID_CIRCUIT_SENDCOINSREQ: 512,
|
||||||
ID_CIRCUIT_COINS_ACCEPTED: 1024,
|
ID_CIRCUIT_COINS_ACCEPTED: 1024,
|
||||||
ID_CIRCUIT_COINS_REFUSED: 2048,
|
ID_CIRCUIT_COINS_REFUSED: 2048,
|
||||||
|
ID_CIRCUIT_SENDCOINSREQ_SENT: 4096,
|
||||||
|
ID_CIRCUIT_COINS_ACCEPTED_SENT: 8192,
|
||||||
|
ID_CIRCUIT_COINS_REFUSED_SENT: 16384,
|
||||||
|
|
||||||
TYPEDIR_BOOKING: 6,
|
TYPEDIR_BOOKING: 6,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user