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 @@
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) {
idnotiftosearch = myrecnotif.paramsObj.extrarec.notifId;
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) {