Circuits OK

Accounts Ok
Movements OK
This commit is contained in:
Paolo Arena
2022-09-14 11:32:04 +02:00
parent 2f24a02a63
commit 845e244470
90 changed files with 362 additions and 258 deletions

View File

@@ -1,4 +1,4 @@
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
var mongoose = require('mongoose').set('debug', false)
mongoose.Promise = global.Promise;
@@ -9,7 +9,7 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true
});
mongoose.set('debug', process.env.DEBUG);
mongoose.set('debug', false);
const options = {
// user: process.env.UDB,
@@ -17,7 +17,8 @@ const options = {
// useMongoClient: true,
// useMongoClient: false,
useNewUrlParser: true,
// useFindAndModify: false,
// useFindAndModify: true,
useFindAndModify: false,
// useCreateIndex: true,
useUnifiedTopology: true,

View File

@@ -51,6 +51,9 @@
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)",
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando %s %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_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",

View File

@@ -52,7 +52,11 @@
"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_TO_ME": "Stai inviando %s %s a %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_QTAMAX": "L'importo supera la quantità massima che il destinatario può accumulare",
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",

View File

@@ -1,7 +1,7 @@
/*
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;
mongoose.Promise = global.Promise;
@@ -18,7 +18,10 @@ mongoose.plugin(schema => {
const AccountSchema = new Schema({
_id: {
type: Number,
type: String,
default: function () {
return new ObjectID().toString()
}
},
idapp: {
type: String,
@@ -27,7 +30,7 @@ const AccountSchema = new Schema({
type: String,
},
circuitId: { // ----- REF TO Circuit
type: Number,
type: String,
},
name: {
type: String,
@@ -72,16 +75,7 @@ AccountSchema.statics.findAllIdApp = async function(idapp) {
AccountSchema.pre('save', async function(next) {
if (this.isNew) {
const myrec = await Account.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this._id = new ObjectID().toString()
}
next();
@@ -130,6 +124,14 @@ AccountSchema.statics.addtoSaldo = async function(id, amount) {
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) {
const Account = this;
@@ -152,12 +154,19 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
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();
if (!myaccount && createifnotexist) {
myaccount = new Account({
_id: new ObjectID().toString(),
idapp,
username,
circuitId: mycircuit._id,
@@ -172,6 +181,8 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function(idapp, u
}
return myaccount;
}
return null;
} catch (e) {
console.error('error', e);

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 shared_consts = require('../tools/shared_nodejs');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
@@ -17,7 +17,10 @@ mongoose.plugin(schema => {
const CircuitSchema = new Schema({
_id: {
type: Number,
type: String,
default: function () {
return new ObjectID().toString()
}
},
idapp: {
type: String,
@@ -165,16 +168,7 @@ const CircuitSchema = new Schema({
CircuitSchema.pre('save', async function(next) {
if (this.isNew) {
const myrec = await Circuit.findOne().limit(1).sort({_id: -1});
if (!!myrec) {
if (myrec._doc._id === 0)
this._id = 1;
else
this._id = myrec._doc._id + 1;
} else {
this._id = 1;
}
this._id = new ObjectID().toString();
this.date_created = new Date();
}
@@ -210,7 +204,7 @@ CircuitSchema.statics.executeQueryTable = function(idapp, params) {
CircuitSchema.statics.getWhatToShow = function(idapp, username) {
// FOR ME, PERMIT ALL
return {
circuitId: 1,
_id: 1,
groupnameId: 1,
path: 1,
name: 1,
@@ -245,7 +239,6 @@ CircuitSchema.statics.removeAdminOfMyCircuit = async function(idapp, username, n
CircuitSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
return {
circuitId: 1,
groupnameId: 1,
path: 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 {
const {User} = require('../models/user');
@@ -327,7 +320,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function(idapp, username, re
asked_circuits,
refused_circuits,
manage_mycircuits,
mycircuits: req.user.profile.mycircuits,
mycircuits: user.profile.mycircuits,
};
} catch (e) {
@@ -381,7 +374,7 @@ CircuitSchema.statics.getCircuitByName = async function(idapp, name) {
CircuitSchema.statics.getCircuitById = async function(circuitId) {
const myfind = {
circuitId,
_id: circuitId,
};
try {

View File

@@ -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 escapeStringRegexp = require('escape-string-regexp');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,5 +1,5 @@
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 jwt = require('jsonwebtoken');
const _ = require('lodash');
@@ -16,7 +16,7 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true
});
mongoose.set('debug', process.env.DEBUG);
mongoose.set('debug', false);
var ExtraListSchema = new mongoose.Schema({
idapp: {

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,5 +1,5 @@
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 jwt = require('jsonwebtoken');
const _ = require('lodash');
@@ -20,7 +20,7 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true
});
mongoose.set('debug', process.env.DEBUG);
mongoose.set('debug', false);
const GraduatoriaSchema = new mongoose.Schema({
idapp: {

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
@@ -16,7 +16,10 @@ mongoose.plugin(schema => {
const MovementSchema = new Schema({
_id: {
type: Number,
type: String,
default: function () {
return new ObjectID().toString()
}
},
idapp: {
type: String,
@@ -25,10 +28,10 @@ const MovementSchema = new Schema({
type: Date,
},
accountFromId: {
type: Number,
type: String,
},
accountToId: {
type: Number,
type: String,
},
causal_table: {
type: String,
@@ -62,16 +65,8 @@ MovementSchema.statics.findAllIdApp = async function(idapp) {
MovementSchema.pre('save', async function(next) {
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._id = 1;
}
this.transactionDate = new Date();
}
next();
@@ -94,6 +89,7 @@ MovementSchema.statics.addMov = async function(idapp, accountFromId, accountToId
try {
let mymov = Movement(
{
_id: new ObjectID().toString(),
idapp,
transactionDate: new Date(),
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
Account.addtoSaldo(accountToId, amount);
Account.addtoSaldo(accountFromId, -amount);
return await mymov.save();
return rismov;
}
} catch (e) {
console.error('Error in addMov', e.message);
}

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 shared_consts = require('../tools/shared_nodejs');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
mongoose = require('mongoose').set('debug', process.env.DEBUG)
mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
mongoose = require('mongoose').set('debug', process.env.DEBUG)
mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
var mongoose = require('mongoose').set('debug', false)
const _ = require('lodash');
@@ -16,7 +16,7 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true
});
mongoose.set('debug', process.env.DEBUG);
mongoose.set('debug', false);
var ProjectSchema = new mongoose.Schema({
idapp: {

View File

@@ -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 escapeStringRegexp = require('escape-string-regexp');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const mongoose = require('mongoose').set('debug', false);
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
@@ -84,7 +84,6 @@ const sendNotifSchema = new Schema({
options: {
type: Array,
},
});
sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
@@ -326,10 +325,27 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = function(recnotif) {
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_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) {
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', 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_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;
}
} else if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
if (myrecnotif.paramsObj.extrarec)
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifId;
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC;
dest = myrecnotif.dest;
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) {
typeidsearch = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ;
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);
await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave);
return await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave);
return true;
} catch (e) {
console.error('createNewNotification', e);
return false;
return null;
}
};
@@ -773,7 +798,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
if (send) {
let myrecnotif = new SendNotif(myrecnotifpass);
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;
if (onlysave) {
await SendNotif.saveNotif(myrecnotif);
return await SendNotif.saveNotif(myrecnotif);
} else {
await SendNotif.saveAndSendNotif(myrecnotif, req, res, null);
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, null);
}
} catch (e) {

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
mongoose = require('mongoose').set('debug', process.env.DEBUG)
mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');

View File

@@ -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 tools = require('../tools/general');
@@ -6,7 +6,7 @@ const tools = require('../tools/general');
mongoose.Promise = global.Promise;
mongoose.level = "F";
mongoose.set('debug', process.env.DEBUG);
mongoose.set('debug', false);
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
mongoose = require('mongoose').set('debug', process.env.DEBUG)
mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -1,4 +1,4 @@
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;

View File

@@ -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 tools = require('../tools/general');

View File

@@ -1,4 +1,4 @@
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
var mongoose = require('mongoose').set('debug', false)
const _ = require('lodash');
@@ -18,7 +18,7 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true
});
mongoose.set('debug', process.env.DEBUG);
mongoose.set('debug', false);
var TodoSchema = new mongoose.Schema({
userId: {

View File

@@ -1,5 +1,5 @@
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 jwt = require('jsonwebtoken');
const _ = require('lodash');
@@ -32,7 +32,7 @@ mongoose.plugin(schema => {
schema.options.usePushEach = true;
});
mongoose.set('debug', process.env.DEBUG);
mongoose.set('debug', false);
const UserSchema = new mongoose.Schema({
userId: {
@@ -2107,6 +2107,9 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
// Elimina eventualmente se era bloccato:
update = {$pull: {refused_users: {username: {$in: [usernameOrig]}}}};
await Circuit.updateOne({idapp, name: circuitname}, update);
await Account.createAccount(idapp, usernameOrig, circuitname);
} else {
ris = false;
}
@@ -2137,7 +2140,6 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
};
ris = await Circuit.updateOne({idapp, name: circuitname}, update);
await Account.createAccount(idapp, usernameOrig, circuitname);
}
if (ris) {
// Invia una notifica alla persona
@@ -2215,7 +2217,7 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
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 !
let ris2 = {
@@ -2231,7 +2233,11 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
risStatus = i18n.__('STATUS_REFUSED');
}
if (!await SendNotif.checkIfCoinsAlreadySent(extrarec.notifId)) {
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
ris2 = await Circuit.sendCoins(false, idapp, usernameOrig, extrarec);
} else {
ris2.cansend = true;
}
if (ris2.cansend) {
// 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.user = await User.getExtraInfoByUsername(idapp, username_action);
} else {
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 {
const listSentMyRequestFriends = await User.find({
@@ -3795,7 +3814,7 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser, req) {
// 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);

View File

@@ -1,5 +1,5 @@
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
var mongoose = require('mongoose').set('debug', false)
var variantSchema = mongoose.Schema({
productID: {

View File

@@ -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 tools = require('../tools/general');

View File

@@ -2,7 +2,7 @@
const tools = require('../tools/general');
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');

View File

@@ -1,6 +1,6 @@
const express = require('express');
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 shared_consts = require('../tools/shared_nodejs');

View File

@@ -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 { ListaIngresso } = require('../../models/listaingresso');

View File

@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
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 {Circuit} = require('../models/circuit');

View File

@@ -14,7 +14,7 @@ const {ObjectID} = require('mongodb');
// const {ListaIngresso} = require('../models/listaingresso');
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 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;
}
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') {
@@ -347,6 +348,8 @@ router.post('/settable', authenticate, async (req, res) => {
mytablerec.date_updated = new Date();
}
console.log('mydata',mydata);
return await mytablerec.save().
then(async (rec) => {
@@ -1237,7 +1240,7 @@ function load(req, res, version) {
let myuserextra = null;
if (req.user) {
// askedfriends = User.getAskedFriendsByUsername(idapp, req.user.username);
myuserextra = User.addExtraInfo(idapp, req.user, req);
myuserextra = User.addExtraInfo(idapp, req.user);
}
return Promise.all([

View File

@@ -19,7 +19,7 @@ const _ = require('lodash');
const { authenticate } = require('../middleware/authenticate');
const mongoose = require('mongoose').set('debug', process.env.DEBUG)
const mongoose = require('mongoose').set('debug', false)
// POST /iscritti_conacreis

View File

@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
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 _ = require('lodash');

View File

@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
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 _ = require('lodash');

View File

@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
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 {MyGroup} = require('../models/mygroup');

View File

@@ -9,7 +9,7 @@ var server_constants = require('../tools/server_constants');
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 _ = require('lodash');

View File

@@ -11,7 +11,7 @@ var { Project } = require('../models/project');
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 _ = require('lodash');

View File

@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
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 { Todo } = require('../models/todo');

View File

@@ -1,6 +1,6 @@
const express = require('express');
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 q = require('q');
const webpush = require('web-push');

View File

@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
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 { Todo } = require('../models/todo');

View File

@@ -7,7 +7,7 @@ const server_constants = require('../tools/server_constants');
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 { Nave } = require('../models/nave');

View File

@@ -1,6 +1,6 @@
const express = require('express');
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 tools = require('../tools/general');

View File

@@ -9,7 +9,7 @@ var { Project } = require('../models/project');
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');
var { Todo } = require('../models/todo');

View File

@@ -39,7 +39,7 @@ const TypedError = require('../modules/ErrorHandler');
const {MyGroup} = require('../models/mygroup');
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');
@@ -644,7 +644,7 @@ router.post('/circuits', authenticate, (req, res) => {
idapp = req.body.idapp;
locale = req.body.locale;
return Circuit.getCircuitsByUsername(idapp, username, req).then((ris) => {
return Circuit.getCircuitsByUsername(idapp, username, req.user).then((ris) => {
res.send(ris);
}).catch((e) => {
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).
then((ris) => {
then(async (ris) => {
// Check if ìs a Notif to read
if (extrarec && extrarec.hasOwnProperty('idnotif')) {
const idnotif = extrarec['idnotif'] ? extrarec['idnotif'] : '';
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
await SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
}
return res.send(ris);
}).

View File

@@ -63,9 +63,9 @@ const tools = require('./tools/general');
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 {ObjectID} = require('mongodb');

View File

@@ -822,6 +822,8 @@ const MyTelegramBot = {
try {
const cl = getclTelegByidapp(idapp);
if (!cl)
return false;
const langdest = myuser.lang;
const telegid = myuser.profile.teleg_id;
@@ -908,6 +910,8 @@ const MyTelegramBot = {
try {
const cl = getclTelegByidapp(idapp);
if (!cl)
return false;
const {SendNotif} = require('../models/sendnotif');
@@ -949,7 +953,7 @@ const MyTelegramBot = {
}
if (sendnotif) {
const req = this.getReqByPar(idapp, username);
const req = tools.getReqByPar(idapp, username);
// CREATE NOTIFICATION IN TABLE SENDNOTIF
await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, true, typedir, typeid);
}
@@ -3820,7 +3824,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]) : '',
circuitId: dataarr[4] ? dataarr[4] : '',
};
}
}
@@ -3942,7 +3946,7 @@ if (true) {
if (circuit) {
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) {
// Aggiungilo nel Circuito

View File

@@ -84,7 +84,7 @@ const userjson = JSON.stringify(users[0]);
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;

View File

@@ -20,7 +20,7 @@ const {ObjectID} = require('mongodb');
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 server_constants = require('./server_constants');
@@ -1070,10 +1070,16 @@ 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_REQ_SENT) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT;
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED;
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT;
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED;
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT) {
typeid = shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT;
}
}
@@ -1143,10 +1149,30 @@ module.exports = {
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) {
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,
let recnotif = 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);
} 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)
inviato = true;
@@ -1170,7 +1196,8 @@ module.exports = {
if (!giainviato && cmd !== shared_consts.CIRCUITCMD.REQ) {
// SEND TO THE USER DEST THE NOTIFICATION
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, circuitname, circuit.path, null,
ris = await this.sendNotifCircuitByUsername(cmd, idapp, usernameOrig, usernameOrig, username_action, circuitname, circuit.path,
null,
false, '', extrarec);
if (ris)
inviato = true;
@@ -1581,7 +1608,7 @@ module.exports = {
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 = {
$match: {
$expr: {

View File

@@ -73,13 +73,16 @@ module.exports = {
SET: 2001,
REMOVE_FROM_MYLIST: 2144,
REFUSE_REQ: 2145,
CANCEL_REQ: 1146,
CANCEL_REQ: 2146,
DELETE: 2170,
ADDADMIN: 2180,
REMOVEADMIN: 2185,
SENDCOINS_REQ: 2200,
SENDCOINS_REQ_SENT: 2205,
SENDCOINS_ACCEPT: 2210,
SENDCOINS_ACCEPT_SENT: 2212,
SENDCOINS_REFUSE: 2220,
SENDCOINS_REFUSE_SENT: 2222,
},
REPORT_FILT_RESP: 1,
@@ -129,7 +132,7 @@ module.exports = {
TABLES_PERM_NEWREC: ['skills', 'goods', 'subskills', 'mygroups', 'myhosps'],
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_EVENTS_NOTIFICATION: ['mybachecas'],
@@ -138,6 +141,12 @@ module.exports = {
TABLES_NUM_AS_ID_NUMBER: [ ],
TABLES_ID_STRING: [
'circuits',
'accounts',
'movements',
],
TABLES_ID_NUMBER: [
'permissions',
'levels',
@@ -155,9 +164,8 @@ module.exports = {
'mybachecas',
'myhosps',
'mygoods',
'mygroups',
'circuits',
'movements'],
'mygroups'
],
TABLES_USER_ID: ['mygroups', 'myskills', 'mybachecas', 'myhosps', 'mygoods'],
TABLES_CREATEDBY: ['mygroups', 'circuits'],
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybachecas', 'myhosps', 'mygoods', 'bots', 'mygroups', 'circuits'],
@@ -348,6 +356,8 @@ module.exports = {
STATUS_REMOVED: 57,
STATUS_COINS_ACCEPTED: 60,
STATUS_COINS_REFUSED: 61,
STATUS_COINS_ACCEPTED_SENT: 62,
STATUS_COINS_REFUSED_SENT: 63,
},
TypeNotifs: {
@@ -391,6 +401,9 @@ module.exports = {
ID_CIRCUIT_SENDCOINSREQ: 512,
ID_CIRCUIT_COINS_ACCEPTED: 1024,
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,