Conti Comunitari e Collettivi
This commit is contained in:
@@ -57,15 +57,17 @@
|
||||
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal Circuito %s",
|
||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong>.",
|
||||
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto Comunitario '%s'.",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER": "il conto comunitario '%s' sta inviando <strong>%s %s</strong> a %s.",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU": "il conto comunitario '%s' ti sta inviando <strong>%s %s</strong>",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP": "il conto comunitario '%s' sta inviando <strong>%s %s</strong> al conto Comunitario %s.",
|
||||
"COMUNITARIO": "Comunitario",
|
||||
"COLLETTIVO": "Collettivo",
|
||||
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s'.",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER": "il conto %s '%s' sta inviando <strong>%s %s</strong> a %s.",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU": "il conto %s '%s' ti sta inviando <strong>%s %s</strong>",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP": "il conto %s '%s' sta inviando <strong>%s %s</strong> al conto %s '%s'.",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s. \nIl destinatario deve accettare la transazione.",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_GROUP": "Stai inviando <strong>%s %s</strong> al Conto Comunitario %s. \nIl destinatario deve accettare la transazione.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU": "<strong>%s %s</strong> accettati da %s (del Conto Comunitario %s).",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP": "<strong>%s %s</strong> accettati da %s del Conto Comunitario %s al Conto Comunitario %s.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP": "<strong>%s %s</strong> accettati da %s (per il Conto Comunitario %s).",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_GROUP": "Stai inviando <strong>%s %s</strong> al Conto %s '%s'. \nIl destinatario deve accettare la transazione.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU": "<strong>%s %s</strong> accettati da %s (del Conto %s '%s').",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP": "<strong>%s %s</strong> accettati da %s del Conto %s %s al Conto %s '%s'.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP": "<strong>%s %s</strong> accettati da %s (per il Conto %s '%s').",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU": "<strong>%s %s</strong> accettati da %s.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s.",
|
||||
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong>]",
|
||||
|
||||
@@ -36,6 +36,9 @@ const AccountSchema = new Schema({
|
||||
groupname: { // For the Groups
|
||||
type: String,
|
||||
},
|
||||
contocom: { // For the Conto Comunitario dei Circuiti
|
||||
type: String,
|
||||
},
|
||||
circuitId: { // ----- REF TO Circuit
|
||||
type: String,
|
||||
},
|
||||
@@ -195,7 +198,7 @@ AccountSchema.pre('save', async function (next) {
|
||||
next();
|
||||
});
|
||||
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, groupname = '', iscontocom = false) {
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, groupname = '', contocom = "") {
|
||||
const Account = this;
|
||||
|
||||
try {
|
||||
@@ -212,6 +215,8 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
|
||||
if (groupname) {
|
||||
myquery.groupname = groupname;
|
||||
} else if (contocom) {
|
||||
myquery.contocom = contocom;
|
||||
} else {
|
||||
myquery.username = username;
|
||||
}
|
||||
@@ -227,6 +232,7 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
idapp,
|
||||
username,
|
||||
groupname,
|
||||
contocom,
|
||||
circuitId: mycircuit._id,
|
||||
deperibile: false,
|
||||
importo_iniziale: 0,
|
||||
@@ -235,7 +241,7 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
qta_maxConcessa: 0,
|
||||
});
|
||||
|
||||
if (iscontocom) {
|
||||
if (contocom) {
|
||||
myaccount.fidoConcesso = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
|
||||
myaccount.qta_maxConcessa = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
|
||||
} else {
|
||||
@@ -267,14 +273,14 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, groupname = '') {
|
||||
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, groupname = '', contocom = '') {
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
try {
|
||||
mycircuit = await Circuit.findOne({ name: circuitName }, { _id: 1 });
|
||||
if (mycircuit) {
|
||||
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, groupname, circuitName === groupname);
|
||||
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, groupname, contocom);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -646,8 +646,8 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
if (circuittable) {
|
||||
const myqty = Math.abs(extrarec.qty);
|
||||
|
||||
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true, extrarec.groupdest);
|
||||
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true, extrarec.grouporig);
|
||||
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true, extrarec.groupdest, extrarec.contoComDest);
|
||||
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true, extrarec.grouporig, extrarec.contoComOrig);
|
||||
|
||||
const circolantePrec = this.getCircolanteSingolaTransaz(accountorigTable, accountdestTable);
|
||||
|
||||
@@ -795,6 +795,21 @@ CircuitSchema.statics.setDeperimentoOff = async function () {
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getListAdminsByCircuitPath = async function (idapp, circuitPath) {
|
||||
|
||||
let arr = await Circuit.findOne({
|
||||
idapp,
|
||||
path: circuitPath,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, {admins: 1}).lean();
|
||||
|
||||
return arr && arr.admins ? arr.admins : [];
|
||||
|
||||
};
|
||||
|
||||
|
||||
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||
|
||||
module.exports = { Circuit };
|
||||
|
||||
@@ -128,7 +128,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
if (!circuitId) {
|
||||
return [];
|
||||
}
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false);
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, '');
|
||||
|
||||
if (myaccount) {
|
||||
|
||||
@@ -196,6 +196,29 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
},
|
||||
},
|
||||
{$unwind: '$groupfrom'},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: {contocom: '$accfrom.contocom', idapp: '$accfrom.idapp'},
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$contocom', '$path']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$contocomfrom'},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
@@ -273,6 +296,29 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
},
|
||||
},
|
||||
{$unwind: '$groupto'},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: {contocom: '$accto.contocom', idapp: '$accto.idapp'},
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$contocom', '$path']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomto',
|
||||
},
|
||||
},
|
||||
{$unwind: '$contocomto'},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
@@ -288,6 +334,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
'userto.profile.img': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupto.groupname': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomto.path': 1,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -380,6 +428,34 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: {contocom: '$accfrom.contocom', idapp: '$accfrom.idapp'},
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$contocom', '$path']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
@@ -481,6 +557,34 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: {contocom: '$accto.contocom', idapp: '$accto.idapp'},
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$contocom', '$path']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
@@ -496,6 +600,8 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
'userto.profile.img': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupto.groupname': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomto.path': 1,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -281,6 +281,14 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
|
||||
tag = 'circuit';
|
||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path;
|
||||
strtipocontoOrig = recnotif.paramsObj.extrarec.contoComOrig ? i18n.__('COMUNITARIO') : i18n.__('COLLETTIVO');
|
||||
strtipocontoDest = recnotif.paramsObj.extrarec.contoComDest ? i18n.__('COMUNITARIO') : i18n.__('COLLETTIVO');
|
||||
let groupOComorig = recnotif.paramsObj.extrarec.contoComOrig ? recnotif.paramsObj.extrarec.contoComOrig : recnotif.paramsObj.extrarec.grouporig;
|
||||
let groupOComdest = recnotif.paramsObj.extrarec.contoComDest ? recnotif.paramsObj.extrarec.contoComDest : recnotif.paramsObj.extrarec.groupdest;
|
||||
let myorig = recnotif.paramsObj.extrarec.grouporig;
|
||||
let mydest = recnotif.paramsObj.extrarec.groupdest ? recnotif.paramsObj.extrarec.groupdest : recnotif.paramsObj.extrarec.dest;
|
||||
let destinatario = recnotif.paramsObj.extrarec.dest ? recnotif.paramsObj.extrarec.dest : recnotif.paramsObj.extrarec.groupdest;
|
||||
|
||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_NEW_REC) {
|
||||
newdescr = i18n.__('CIRCUIT_CREATED', sender, recnotif.paramsObj.circuitnameDest);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
@@ -352,13 +360,13 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
}
|
||||
tag = 'removeadmincircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ) {
|
||||
if (recnotif.paramsObj.extrarec.groupdest) {
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_GROUP', tools.getAhref(recnotif.paramsObj.username_action, await tools.getLinkUserTelegram(recnotif.idapp, recnotif.paramsObj.username_action)), recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.groupdest);
|
||||
} else if (recnotif.paramsObj.extrarec.grouporig && (sender === recnotif.paramsObj.usernameDest)) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU', recnotif.paramsObj.extrarec.grouporig, recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.dest);
|
||||
} else if (recnotif.paramsObj.extrarec.grouporig) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', recnotif.paramsObj.extrarec.grouporig, recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.dest);
|
||||
recnotif.paramsObj.extrarec.symbol, strtipocontoDest, groupOComdest);
|
||||
} else if (groupOComorig && (sender === recnotif.paramsObj.usernameDest)) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU', strtipocontoOrig, groupOComorig, recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.dest);
|
||||
} else if (groupOComorig) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, groupOComorig, recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.dest);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ', tools.getAhref(recnotif.paramsObj.username_action, await tools.getLinkUserTelegram(recnotif.idapp, recnotif.paramsObj.username_action)), recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol);
|
||||
@@ -367,21 +375,19 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
tag = 'sendcoin';
|
||||
recnotif.openUrl = '/circuit/' + recnotif.paramsObj.path; //++Todo: dove lo mando ?
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ_SENT) {
|
||||
let mydest = recnotif.paramsObj.extrarec.groupdest ? recnotif.paramsObj.extrarec.groupdest : recnotif.paramsObj.extrarec.dest;
|
||||
let myorig = recnotif.paramsObj.extrarec.grouporig;
|
||||
|
||||
if (myorig) {
|
||||
if (recnotif.paramsObj.extrarec.groupdest) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP', myorig, recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, mydest);
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP', strtipocontoOrig, myorig, recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, strtipocontoDest, groupOComdest);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', myorig, recnotif.paramsObj.extrarec.qty.toString(),
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER', strtipocontoOrig, myorig, recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, mydest);
|
||||
}
|
||||
} else {
|
||||
if (recnotif.paramsObj.extrarec.groupdest) {
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_GROUP', recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, mydest);
|
||||
recnotif.paramsObj.extrarec.symbol, strtipocontoDest, groupOComdest);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_ME', recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, mydest);
|
||||
@@ -394,21 +400,18 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, recnotif.paramsObj.extrarec.symbol);
|
||||
|
||||
let mydest = recnotif.paramsObj.extrarec.groupdest ? recnotif.paramsObj.extrarec.groupdest : recnotif.paramsObj.extrarec.dest;
|
||||
let myorig = recnotif.paramsObj.extrarec.grouporig;
|
||||
|
||||
if (myorig) {
|
||||
if (recnotif.paramsObj.extrarec.groupdest) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action, myorig, recnotif.paramsObj.extrarec.groupdest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, recnotif.paramsObj.extrarec.symbol);
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP', strtipocontoOrig, recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action, myorig, strtipocontoDest, groupOComdest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, recnotif.paramsObj.extrarec.symbol);
|
||||
} else {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU', strtipocontoOrig, recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action, myorig) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, recnotif.paramsObj.extrarec.symbol);
|
||||
}
|
||||
} else {
|
||||
if (recnotif.paramsObj.extrarec.groupdest) {
|
||||
if (groupOComdest) {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action, recnotif.paramsObj.extrarec.groupdest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, recnotif.paramsObj.extrarec.symbol);
|
||||
recnotif.paramsObj.username_action, strtipocontoDest, groupOComdest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, recnotif.paramsObj.extrarec.symbol);
|
||||
} else {
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest, recnotif.paramsObj.extrarec.symbol);
|
||||
@@ -417,7 +420,6 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
|
||||
tag = 'sendcoin';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_ACCEPTED_SENT) {
|
||||
let destinatario = recnotif.paramsObj.extrarec.dest ? recnotif.paramsObj.extrarec.dest : recnotif.paramsObj.extrarec.groupdest;
|
||||
if (!destinatario) {
|
||||
destinatario = recnotif.paramsObj.username_action
|
||||
}
|
||||
@@ -431,7 +433,6 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
recnotif.paramsObj.username_action);
|
||||
tag = 'sendcoin';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_COINS_REFUSED_SENT) {
|
||||
let destinatario = recnotif.paramsObj.extrarec.dest ? recnotif.paramsObj.extrarec.dest : recnotif.paramsObj.extrarec.groupdest;
|
||||
|
||||
newdescr = i18n.__('ID_CIRCUIT_COINS_REFUSED_TO_ME', recnotif.paramsObj.extrarec.qty.toString(), recnotif.paramsObj.extrarec.symbol,
|
||||
destinatario);
|
||||
|
||||
@@ -2352,7 +2352,7 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
const mycirc = await Circuit.findOne({ idapp, name: circuitname });
|
||||
if (mycirc) {
|
||||
// Il Conto Comunitario prende il nome del circuito !
|
||||
await Account.createAccount(idapp, '', circuitname, mycirc.path);
|
||||
await Account.createAccount(idapp, '', circuitname, '', mycirc.path);
|
||||
}
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
|
||||
@@ -72,7 +72,7 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
if (data) {
|
||||
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, data.path);
|
||||
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, '', data.path);
|
||||
}
|
||||
|
||||
res.send({ circuit: data, users_in_circuit });
|
||||
|
||||
@@ -1097,7 +1097,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
|
||||
for (const mycirc of allcirc) {
|
||||
// Il Conto Comunitario prende il nome del circuito !
|
||||
await Account.createAccount(idapp, '', mycirc.name, mycirc.path);
|
||||
await Account.createAccount(idapp, '', mycirc.name, '', mycirc.path);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1042,6 +1042,7 @@ module.exports = {
|
||||
const { User } = require('../models/user');
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
const { MyGroup } = require('../models/mygroup');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
const req = this.getReqByPar(idapp, usernameOrig, groupOrig);
|
||||
|
||||
@@ -1117,26 +1118,25 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (sendnotif && typeid > 0) {
|
||||
const groupDestoContoCom = groupDest ? groupDest : (extrarec && extrarec.contoComDest ? extrarec.contoComDest : '');
|
||||
// Check if is group:
|
||||
if (groupDest && (
|
||||
if (groupDestoContoCom && (
|
||||
(cmd !== shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT_SENT) &&
|
||||
(cmd !== shared_consts.CIRCUITCMD.SENDCOINS_REFUSE_SENT)
|
||||
)) {
|
||||
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, groupDest);
|
||||
let arrusers = await MyGroup.getListAdminsByGroupName(idapp, groupDestoContoCom);
|
||||
if (arrusers.length <= 0)
|
||||
arrusers = await Circuit.getListAdminsByCircuitPath(idapp, groupDestoContoCom);
|
||||
|
||||
let notiftoUpdate = '';
|
||||
let findrecnotif = await SendNotif.findOne({ _id: paramsObj.extrarec.notifId }).lean();
|
||||
notiftoUpdate = findrecnotif ? findrecnotif.extrarec.notifIdToUpdate : '';
|
||||
// arrnotiftoUpdate = findrecnotif ? findrecnotif.extrarec.arrnotifIdToUpdate : '';
|
||||
if (findrecnotif) {
|
||||
let arrrec = [];
|
||||
|
||||
if (notiftoUpdate)
|
||||
arrrec = await SendNotif.find({ 'extrarec.notifIdToUpdate': notiftoUpdate });
|
||||
// if (arrnotiftoUpdate)
|
||||
// arrrec = await SendNotif.find({'extrarec.notifIdToUpdate': notiftoUpdate});
|
||||
|
||||
|
||||
for (let rec of arrrec) {
|
||||
paramsObj.usernameDest = rec.dest;
|
||||
@@ -1149,7 +1149,7 @@ module.exports = {
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDest)
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
} else {
|
||||
arrris.push(ris._id);
|
||||
}
|
||||
@@ -1163,7 +1163,7 @@ module.exports = {
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDest)
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
} else {
|
||||
arrris.push(ris._id);
|
||||
}
|
||||
@@ -1199,7 +1199,7 @@ module.exports = {
|
||||
|
||||
ris = await SendNotif.createNewNotifToSingleUser(req, null, paramsObj, onlysave, typedir, typeid);
|
||||
if (!ris) {
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDest)
|
||||
console.error('Errore createNewNotifToSingleUser! ', paramsObj.usernameDest, "dest ->", groupDestoContoCom)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1274,12 +1274,7 @@ module.exports = {
|
||||
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ || cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT || cmd ===
|
||||
shared_consts.CIRCUITCMD.SENDCOINS_REFUSE) {
|
||||
|
||||
let extrarecorig = { ...extrarec };
|
||||
let temp = ''
|
||||
temp = extrarecorig.groupdest
|
||||
extrarecorig.groupdest = extrarecorig.grouporig
|
||||
groupOrig = extrarec.grouporig
|
||||
// extrarecorig.grouporig = temp
|
||||
|
||||
let arrris = [];
|
||||
let recnotif = null;
|
||||
|
||||
@@ -514,7 +514,7 @@ module.exports = {
|
||||
CIRCUIT_PARAMS: {
|
||||
SCOPERTO_MIN_GRP: 200,
|
||||
SCOPERTO_MAX_GRP: 500,
|
||||
SCOPERTO_MIN_CONTO_COMUNITARIO: 1000,
|
||||
SCOPERTO_MIN_CONTO_COMUNITARIO: 500,
|
||||
SCOPERTO_MAX_CONTO_COMUNITARIO: 1000,
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user