Merge branch 'develop' of ssh://risosrv:5522/~/repository/freeplanet_serverside into develop
This commit is contained in:
BIN
emails/.DS_Store
vendored
Normal file
BIN
emails/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -23,3 +23,5 @@ Ven 29/09 ORE 23:18: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
|||||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
|
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||||
|
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Abilita fido a %s nel '%s':",
|
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Abilita fido a %s nel '%s':",
|
||||||
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍♂️ Abilita fido nel Circuito al gruppo %s:",
|
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍♂️ Abilita fido nel Circuito al gruppo %s:",
|
||||||
|
"CIRCUIT_OPEN_RISITALIA": "Apri il Circuito RIS Italia e chiedi di entrare",
|
||||||
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato al Fido (è stato invitato da %s)",
|
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato al Fido (è stato invitato da %s)",
|
||||||
"CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s",
|
"CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s",
|
||||||
"CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s",
|
"CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s",
|
||||||
@@ -105,5 +106,6 @@
|
|||||||
"SET_ATTEND_OTHERS": "%s e altre %s persone hanno detto che Parteciperanno all'evento: %s",
|
"SET_ATTEND_OTHERS": "%s e altre %s persone hanno detto che Parteciperanno all'evento: %s",
|
||||||
"DATEDAYONLY": "%s dalle %s alle %s",
|
"DATEDAYONLY": "%s dalle %s alle %s",
|
||||||
"DATE_2DAYS": "%s dalle %s fino a %s alle %s",
|
"DATE_2DAYS": "%s dalle %s fino a %s alle %s",
|
||||||
|
"SENDMSG_ENTRA_IN_RISO_ITALIA": "Ciao %s!<br>%s che appartiene al <em>%s</em> vuole inviarti dei RIS. Per poterli ricevere dovete entrambi utilizzare il <strong>Circuito RIS Italia</strong>.",
|
||||||
"CLICCA_QUI": "CLICCA QUI"
|
"CLICCA_QUI": "CLICCA QUI"
|
||||||
}
|
}
|
||||||
@@ -582,7 +582,7 @@ AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valma
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
|
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
|
||||||
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, valmin, valmax, circuitId) {
|
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, fidoConcesso, qta_maxConcessa, circuitId) {
|
||||||
const Account = this;
|
const Account = this;
|
||||||
|
|
||||||
if (circuitId) {
|
if (circuitId) {
|
||||||
@@ -590,17 +590,21 @@ AccountSchema.statics.SetMinMaxPersonali = async function (idapp, valmin, valmax
|
|||||||
{
|
{
|
||||||
$set:
|
$set:
|
||||||
{
|
{
|
||||||
fidoConcesso: valmin,
|
fidoConcesso,
|
||||||
qta_maxConcessa: valmax,
|
qta_maxConcessa,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Se aggiorno questi dati, allora devo aggiornare anche gli account del RIS Nazionale
|
||||||
|
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||||
{
|
{
|
||||||
$set:
|
$set:
|
||||||
{
|
{
|
||||||
fidoConcesso: valmin,
|
fidoConcesso,
|
||||||
qta_maxConcessa: valmax,
|
qta_maxConcessa,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -621,6 +625,66 @@ AccountSchema.statics.updateFido = async function (idapp, username, groupname, c
|
|||||||
return risult;
|
return risult;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AccountSchema.statics.updateQtaMax = async function (idapp, username, groupname, circuitId, qtamax) {
|
||||||
|
|
||||||
|
let paramstoupdate = {
|
||||||
|
qta_maxConcessa: qtamax,
|
||||||
|
};
|
||||||
|
let risult = null;
|
||||||
|
if (groupname)
|
||||||
|
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
|
||||||
|
else
|
||||||
|
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
|
||||||
|
|
||||||
|
return risult;
|
||||||
|
};
|
||||||
|
|
||||||
|
AccountSchema.statics.getAccountsCircuitiNazionali = async function (idapp) {
|
||||||
|
const { Circuit } = require('../models/circuit');
|
||||||
|
|
||||||
|
const circuit = await Circuit.find({ idapp, showAlways: true });
|
||||||
|
|
||||||
|
return Account.find({ idapp, circuitId: circuit.id });
|
||||||
|
};
|
||||||
|
|
||||||
|
AccountSchema.statics.updateAccountCircuitoNazionaleByLimiti = async function (idapp, circuitId, fidoConcesso, qta_maxConcessa) {
|
||||||
|
const { Circuit } = require('../models/circuit');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const accounts = await this.getAccountsCircuitiNazionali(idapp);
|
||||||
|
|
||||||
|
for (const account of accounts) {
|
||||||
|
const circuitId = account.circuitId;
|
||||||
|
const circuit = await Circuit.findOne({ _id: circuitId });
|
||||||
|
if (circuit) {
|
||||||
|
let fido = 0;
|
||||||
|
let qtamax = 0;
|
||||||
|
|
||||||
|
if (account.groupname) {
|
||||||
|
fido = circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||||
|
qtamax = circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||||
|
} else {
|
||||||
|
fido = circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||||
|
qtamax = circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
let paramstoupdate = {
|
||||||
|
fidoConcesso: fido,
|
||||||
|
qta_maxConcessa: qtamax,
|
||||||
|
};
|
||||||
|
|
||||||
|
risult = await Account.updateOne({ _id: account.id }, { $set: paramstoupdate });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return risult;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('updateAccountCircuitoNazionaleByLimiti', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
||||||
const account = await Account.findOne({ _id: id }).lean();
|
const account = await Account.findOne({ _id: id }).lean();
|
||||||
|
|
||||||
@@ -653,11 +717,19 @@ AccountSchema.statics.addToPeopleOfMyAccount = async function (idapp, username,
|
|||||||
|
|
||||||
// Rimuovi dagli Admin del Account
|
// Rimuovi dagli Admin del Account
|
||||||
AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, circuitId, person_username, perm) {
|
AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, circuitId, person_username, perm) {
|
||||||
|
const { Circuit } = require('../models/circuit');
|
||||||
|
|
||||||
return await Circuit.updateOne({ idapp, username, circuitId },
|
return await Circuit.updateOne({ idapp, username, circuitId },
|
||||||
{ $pull: { people: { username: { $in: [person_username] } } } });
|
{ $pull: { people: { username: { $in: [person_username] } } } });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Rimuovi l'account
|
||||||
|
AccountSchema.statics.removeAccount = async function (accountId) {
|
||||||
|
const { Circuit } = require('../models/circuit');
|
||||||
|
|
||||||
|
return await Circuit.deleteOne({ _id: accountId});
|
||||||
|
};
|
||||||
|
|
||||||
AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) {
|
AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) {
|
||||||
|
|
||||||
const recaccounts = await Account.find({ idapp });
|
const recaccounts = await Account.find({ idapp });
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ const CircuitSchema = new Schema({
|
|||||||
totCircolante: {
|
totCircolante: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
|
showAlways: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
totTransato: {
|
totTransato: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
@@ -212,6 +215,10 @@ const CircuitSchema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
showAlways: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
status: {
|
status: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
@@ -276,6 +283,7 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
|||||||
fido_scoperto_default_grp: 1,
|
fido_scoperto_default_grp: 1,
|
||||||
qta_max_default_grp: 1,
|
qta_max_default_grp: 1,
|
||||||
deperimento: 1,
|
deperimento: 1,
|
||||||
|
showAlways: 1,
|
||||||
transactionsEnabled: 1,
|
transactionsEnabled: 1,
|
||||||
status: 1,
|
status: 1,
|
||||||
valuta_per_euro: 1,
|
valuta_per_euro: 1,
|
||||||
@@ -331,6 +339,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
|||||||
longdescr: 1,
|
longdescr: 1,
|
||||||
regulation: 1,
|
regulation: 1,
|
||||||
numMembers: 1,
|
numMembers: 1,
|
||||||
|
showAlways: 1,
|
||||||
systemUserId: 1,
|
systemUserId: 1,
|
||||||
founderUserId: 1,
|
founderUserId: 1,
|
||||||
nome_valuta: 1,
|
nome_valuta: 1,
|
||||||
@@ -469,6 +478,23 @@ CircuitSchema.statics.getCircuitByName = async function (idapp, name) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CircuitSchema.statics.getCircuitIdByName = async function (idapp, name) {
|
||||||
|
|
||||||
|
const myfind = {
|
||||||
|
idapp,
|
||||||
|
name,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const circuit = await Circuit.findOne(myfind);
|
||||||
|
return (!!circuit ? circuit._id : 0);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
CircuitSchema.statics.getCircuitByProvince = async function (idapp, strProv) {
|
CircuitSchema.statics.getCircuitByProvince = async function (idapp, strProv) {
|
||||||
|
|
||||||
const myfind = {
|
const myfind = {
|
||||||
@@ -915,6 +941,28 @@ CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, val
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||||
|
CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
|
||||||
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
|
const myuser = await User.getUserByUsername(idapp, username);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const circuit = await this.getCircuitByProvince(idapp, myuser.profile.resid_province);
|
||||||
|
|
||||||
|
if (circuit) {
|
||||||
|
if (await User.ifAlreadyInCircuit(idapp, username, circuit.name)) {
|
||||||
|
return circuit.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '[nessun Circuito]';
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error', e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||||
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
|
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province) {
|
||||||
const { User } = require('../models/user');
|
const { User } = require('../models/user');
|
||||||
@@ -936,6 +984,7 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
|||||||
photos: [],
|
photos: [],
|
||||||
color: '#ff5500',
|
color: '#ff5500',
|
||||||
deperimento: false,
|
deperimento: false,
|
||||||
|
showAlways: false,
|
||||||
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
|
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
|
||||||
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
|
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
|
||||||
symbol: 'RIS',
|
symbol: 'RIS',
|
||||||
@@ -1092,16 +1141,56 @@ CircuitSchema.statics.setFido = async function (idapp, username, circuitName, gr
|
|||||||
mycircuit = await Circuit.findOne({ idapp, name: circuitName });
|
mycircuit = await Circuit.findOne({ idapp, name: circuitName });
|
||||||
if (mycircuit) {
|
if (mycircuit) {
|
||||||
const circuitId = mycircuit._id;
|
const circuitId = mycircuit._id;
|
||||||
|
let account = null;
|
||||||
const account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
|
|
||||||
if (account) {
|
|
||||||
let fido = 0;
|
let fido = 0;
|
||||||
|
let qtamax = 0;
|
||||||
|
|
||||||
|
if (mycircuit.showAlways) {
|
||||||
|
|
||||||
|
const { User } = require('../models/user');
|
||||||
|
|
||||||
|
const myuser = await User.getUserByUsername(idapp, username);
|
||||||
|
|
||||||
|
// Se è il circuito Nazionale, allora prende i valori dal proprio Circuito Locale:
|
||||||
|
const accountsuser = await Account.getUserAccounts(idapp, username);
|
||||||
|
if (accountsuser) {
|
||||||
|
// Se lo trovo della mia provincia, prendo quello
|
||||||
|
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province)
|
||||||
|
if (!account && accountsuser.length > 0) {
|
||||||
|
// Se non lo trovo, prendo il primo in cui sono entrato !
|
||||||
|
account = accountsuser[0];
|
||||||
|
}
|
||||||
|
if (account && account.circuit) {
|
||||||
|
if (groupname) {
|
||||||
|
qtamax = account.circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||||
|
fido = account.circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||||
|
} else {
|
||||||
|
qtamax = account.circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||||
|
fido = account.circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Se non ho Circuiti locali, non applico il Fido !
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
|
||||||
if (groupname)
|
if (groupname)
|
||||||
fido = mycircuit.fido_scoperto_default_grp;
|
fido = mycircuit.fido_scoperto_default_grp;
|
||||||
else
|
else
|
||||||
fido = mycircuit.fido_scoperto_default;
|
fido = mycircuit.fido_scoperto_default;
|
||||||
|
}
|
||||||
|
|
||||||
return await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
if (account) {
|
||||||
|
if (qtamax > 0) {
|
||||||
|
await Account.updateQtaMax(idapp, username, groupname, circuitId, qtamax);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
||||||
|
if (ris) {
|
||||||
|
return { qta_maxConcessa: qtamax, fidoConcesso: fido };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -381,16 +381,16 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
|||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
|
||||||
if (recnotif.paramsObj.isAdmin) {
|
if (recnotif.paramsObj.isAdmin) {
|
||||||
if (recnotif.extrarec.groupname) {
|
if (recnotif.extrarec.groupname) {
|
||||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fido_scoperto_default_grp, recnotif.paramsObj.circuitnameDest,
|
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
|
||||||
username_action);
|
username_action);
|
||||||
} else {
|
} else {
|
||||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fido_scoperto_default, recnotif.paramsObj.circuitnameDest,
|
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
|
||||||
username_action);
|
username_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
recnotif.openUrl = '/my/' + sender;
|
recnotif.openUrl = '/my/' + sender;
|
||||||
} else {
|
} else {
|
||||||
newdescr = i18n.__('FIDO_IMPOSTATO', -recnotif.paramsObj.extrarec.fido_scoperto_default, username_action, recnotif.paramsObj.circuitnameDest);
|
newdescr = i18n.__('FIDO_IMPOSTATO', -recnotif.paramsObj.extrarec.fidoConcesso, username_action, recnotif.paramsObj.circuitnameDest);
|
||||||
}
|
}
|
||||||
tag = 'setfido';
|
tag = 'setfido';
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||||
|
|||||||
@@ -450,6 +450,9 @@ const UserSchema = new mongoose.Schema({
|
|||||||
noCircuit: {
|
noCircuit: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
|
noCircIta: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
noFoto: {
|
noFoto: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
@@ -1899,9 +1902,26 @@ UserSchema.statics.removeFromCircuits = async function (idapp, username, circuit
|
|||||||
update = { $pull: { req_users: { username: { $in: [username] } } } };
|
update = { $pull: { req_users: { username: { $in: [username] } } } };
|
||||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||||
|
|
||||||
return await User.updateOne({ idapp, username },
|
const ris = await User.updateOne({ idapp, username },
|
||||||
{ $pull: { 'profile.mycircuits': { circuitname: { $in: [circuitname] } } } });
|
{ $pull: { 'profile.mycircuits': { circuitname: { $in: [circuitname] } } } });
|
||||||
|
|
||||||
|
|
||||||
|
const circuitId = await Circuit.getCircuitIdByName(idapp, circuitname);
|
||||||
|
let remove = false;
|
||||||
|
|
||||||
|
// Se il mio account non è stato utilizzato, allora lo cancello anche questo
|
||||||
|
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, false, '', '');
|
||||||
|
if (myaccount && myaccount.totTransato === 0) {
|
||||||
|
remove = true;
|
||||||
|
} else {
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remove) {
|
||||||
|
await Account.removeAccount(myaccount._id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ris;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Aggiungo il Circuito
|
// Aggiungo il Circuito
|
||||||
@@ -2329,6 +2349,86 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
|||||||
return ris;
|
return ris;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UserSchema.statics.sendCmd = async function (req, idapp, usernameOrig, usernameDest, cmd, value, disablenotif) {
|
||||||
|
|
||||||
|
const { SendNotif } = require('../models/sendnotif');
|
||||||
|
|
||||||
|
const telegrambot = require('../telegram/telegrambot');
|
||||||
|
|
||||||
|
const cl = telegrambot.getclTelegByidapp(idapp);
|
||||||
|
|
||||||
|
if (!req) {
|
||||||
|
req = tools.getReqByPar(idapp, usernameOrig);
|
||||||
|
}
|
||||||
|
|
||||||
|
const myuser = await User.getUserByUsername(idapp, usernameOrig);
|
||||||
|
const recuserDest = await User.getUserByUsername(idapp, usernameDest);
|
||||||
|
|
||||||
|
const langdest = recuserDest.lang;
|
||||||
|
const telegid = recuserDest.profile.teleg_id;
|
||||||
|
|
||||||
|
let userId = recuserDest._id;
|
||||||
|
let title = tools.getNomeAppByIdApp(idapp);
|
||||||
|
let keyb = null;
|
||||||
|
let descr = '';
|
||||||
|
|
||||||
|
let send_notif = false;
|
||||||
|
let send_msgTelegramBot = false;
|
||||||
|
let actions = [];
|
||||||
|
let popupOnApp = '';
|
||||||
|
|
||||||
|
let ris = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (cmd === shared_consts.CallFunz.ENTRA_RIS_ITALIA) {
|
||||||
|
mycircuitOrig = await Circuit.getCircuitMyProvince(idapp, usernameOrig);
|
||||||
|
descr = i18n.__({ phrase: 'SENDMSG_ENTRA_IN_RISO_ITALIA', locale: langdest }, usernameDest, usernameOrig, mycircuitOrig);
|
||||||
|
msgtelegram = descr;
|
||||||
|
|
||||||
|
openUrl = '/circuit/ris_italia';
|
||||||
|
bottone = i18n.__({ phrase: 'CIRCUIT_OPEN_RISITALIA', locale: langdest });
|
||||||
|
tag = 'risitalia';
|
||||||
|
|
||||||
|
send_notif = true;
|
||||||
|
send_msgTelegramBot = true;
|
||||||
|
|
||||||
|
keyb = cl.getInlineKeyboard(langdest, [
|
||||||
|
{
|
||||||
|
text: bottone,
|
||||||
|
url: tools.getHostByIdApp(idapp) + openUrl,
|
||||||
|
// callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||||
|
// groupid,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
popupOnApp = 'Messaggio inviato al destinatario';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (send_notif) {
|
||||||
|
// SEND PUSH NOTIFICATION
|
||||||
|
await tools.sendNotificationToUser(userId, title, descr, openUrl, '', tag, actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invia Msg
|
||||||
|
if (send_msgTelegramBot && msgtelegram) {
|
||||||
|
await telegrambot.local_sendMsgTelegramByIdTelegram(idapp, telegid, msgtelegram, undefined, undefined, true, keyb);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userprofile = await User.getInfoFriendByUsername(idapp, usernameDest);
|
||||||
|
const myuser = await User.getInfoFriendByUsername(idapp, usernameOrig);
|
||||||
|
|
||||||
|
ris = { userprofile, myuser, popupOnApp, result: true };
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
popupOnApp = e;
|
||||||
|
ris = { popupOnApp };
|
||||||
|
console.error('Error sendCmd: ', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ris;
|
||||||
|
};
|
||||||
|
|
||||||
UserSchema.statics.ifAlreadyInGroup = async function (idapp, usernameOrig, groupnameDest) {
|
UserSchema.statics.ifAlreadyInGroup = async function (idapp, usernameOrig, groupnameDest) {
|
||||||
|
|
||||||
// Controllo se è stato già inserito
|
// Controllo se è stato già inserito
|
||||||
@@ -2615,6 +2715,10 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
|||||||
} else if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
|
} else if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
|
||||||
|
|
||||||
ris = await Circuit.setFido(idapp, usernameOrig, circuitname, groupname);
|
ris = await Circuit.setFido(idapp, usernameOrig, circuitname, groupname);
|
||||||
|
if (ris) {
|
||||||
|
|
||||||
|
extrarec.fidoConcesso = ris.fidoConcesso;
|
||||||
|
extrarec.qta_maxConcessa = ris.qta_maxConcessa;
|
||||||
|
|
||||||
// Elimina la richiesta:
|
// Elimina la richiesta:
|
||||||
update = { $pull: { req_users: { username: { $in: [usernameOrig] } } } };
|
update = { $pull: { req_users: { username: { $in: [usernameOrig] } } } };
|
||||||
@@ -2626,6 +2730,9 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
|||||||
tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, value, true, username_action, extrarec);
|
tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, value, true, username_action, extrarec);
|
||||||
outres.result = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
outres.result = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// errore !?
|
||||||
|
}
|
||||||
|
|
||||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||||
|
|
||||||
@@ -4832,7 +4939,7 @@ UserSchema.statics.getExtraInfoByUsername = async function (idapp, username) {
|
|||||||
UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, version) {
|
UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, version) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tools.startTimeLog('addExtraInfo')
|
// tools.startTimeLog('addExtraInfo')
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
let versattualeuser = 0;
|
let versattualeuser = 0;
|
||||||
@@ -4931,7 +5038,7 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, v
|
|||||||
|
|
||||||
recUser.profile.calc = await User.calcOtherByUser(idapp, recUser._id);
|
recUser.profile.calc = await User.calcOtherByUser(idapp, recUser._id);
|
||||||
|
|
||||||
tools.endTimeLog('addExtraInfo')
|
// tools.endTimeLog('addExtraInfo')
|
||||||
|
|
||||||
return recUser;
|
return recUser;
|
||||||
|
|
||||||
|
|||||||
@@ -777,6 +777,29 @@ router.post('/friends/cmd', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/sendcmd', authenticate, async (req, res) => {
|
||||||
|
const usernameLogged = req.user.username;
|
||||||
|
const idapp = req.body.idapp;
|
||||||
|
const locale = req.body.locale;
|
||||||
|
let usernameOrig = req.body.usernameOrig;
|
||||||
|
let usernameDest = req.body.usernameDest;
|
||||||
|
const cmd = req.body.cmd;
|
||||||
|
const value = req.body.value;
|
||||||
|
|
||||||
|
usernameOrig = await User.getRealUsernameByUsername(idapp, usernameOrig);
|
||||||
|
usernameDest = await User.getRealUsernameByUsername(idapp, usernameDest);
|
||||||
|
|
||||||
|
return User.sendCmd(req, idapp, usernameOrig, usernameDest, cmd, value).
|
||||||
|
then((ris) => {
|
||||||
|
res.send(ris);
|
||||||
|
}).
|
||||||
|
catch((e) => {
|
||||||
|
tools.mylog('ERRORE IN sendcmd: ' + e.message);
|
||||||
|
res.status(400).send();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
router.post('/groups/cmd', authenticate, (req, res) => {
|
router.post('/groups/cmd', authenticate, (req, res) => {
|
||||||
const usernameLogged = req.user.username;
|
const usernameLogged = req.user.username;
|
||||||
const idapp = req.body.idapp;
|
const idapp = req.body.idapp;
|
||||||
@@ -1521,6 +1544,9 @@ async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
|
|||||||
} else if (mydata.dbop === 'noCircuit') {
|
} else if (mydata.dbop === 'noCircuit') {
|
||||||
await User.findOneAndUpdate({ _id: mydata._id },
|
await User.findOneAndUpdate({ _id: mydata._id },
|
||||||
{ $set: { 'profile.noCircuit': mydata.value } });
|
{ $set: { 'profile.noCircuit': mydata.value } });
|
||||||
|
} else if (mydata.dbop === 'noCircIta') {
|
||||||
|
await User.findOneAndUpdate({ _id: mydata._id },
|
||||||
|
{ $set: { 'profile.noCircIta': mydata.value } });
|
||||||
} else if (mydata.dbop === 'noFoto') {
|
} else if (mydata.dbop === 'noFoto') {
|
||||||
await User.findOneAndUpdate({ _id: mydata._id },
|
await User.findOneAndUpdate({ _id: mydata._id },
|
||||||
{ $set: { 'profile.noFoto': mydata.value } });
|
{ $set: { 'profile.noFoto': mydata.value } });
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ const tools = require('../tools/general');
|
|||||||
|
|
||||||
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
||||||
|
|
||||||
|
//prova
|
||||||
|
|
||||||
const appTelegram_TEST = [tools.FREEPLANET, tools.RISO];
|
const appTelegram_TEST = [tools.FREEPLANET, tools.RISO];
|
||||||
const appTelegram_DEVELOP = [tools.RISO];
|
const appTelegram_DEVELOP = [tools.RISO];
|
||||||
// const appTelegram_DEVELOP = [tools.FIOREDELLAVITA];
|
// const appTelegram_DEVELOP = [tools.FIOREDELLAVITA];
|
||||||
@@ -760,6 +762,11 @@ const MyTelegramBot = {
|
|||||||
return FormDaMostrare;
|
return FormDaMostrare;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getclTelegByidapp: function (idapp) {
|
||||||
|
const cl = getclTelegByidapp(idapp);
|
||||||
|
return cl;
|
||||||
|
},
|
||||||
|
|
||||||
getCiao: function (idapp, username, lang) {
|
getCiao: function (idapp, username, lang) {
|
||||||
return tools.gettranslate('CIAO', lang) + ' ' + username + '!\n';
|
return tools.gettranslate('CIAO', lang) + ' ' + username + '!\n';
|
||||||
},
|
},
|
||||||
@@ -831,11 +838,18 @@ const MyTelegramBot = {
|
|||||||
if (!cl)
|
if (!cl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
const langdest = myuser.lang;
|
const langdest = myuser.lang;
|
||||||
const telegid = myuser.profile.teleg_id;
|
const telegid = myuser.profile.teleg_id;
|
||||||
|
|
||||||
|
|
||||||
|
let userrecDest = await User.getUserShortDataByUsername(idapp, userDest);
|
||||||
|
let userId = userrecDest._id;
|
||||||
|
let title = this.getNomeAppByIdApp(idapp);
|
||||||
let keyb = null;
|
let keyb = null;
|
||||||
let domanda = '';
|
let domanda = '';
|
||||||
|
let send_notif = false;
|
||||||
|
let actions = [];
|
||||||
|
|
||||||
const struserinfomsg = tools.getUserInfoMsg(idapp, myuser);
|
const struserinfomsg = tools.getUserInfoMsg(idapp, myuser);
|
||||||
|
|
||||||
@@ -913,7 +927,7 @@ const MyTelegramBot = {
|
|||||||
} else {
|
} else {
|
||||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest }, myuser.username, name) + '<br>' + struserinfomsg;
|
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest }, myuser.username, name) + '<br>' + struserinfomsg;
|
||||||
|
|
||||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
const keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||||
{
|
{
|
||||||
text: '✅ Abilita fido a ' + myuser.username,
|
text: '✅ Abilita fido a ' + myuser.username,
|
||||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||||
@@ -928,6 +942,11 @@ const MyTelegramBot = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (send_notif) {
|
||||||
|
// SEND PUSH NOTIFICATION
|
||||||
|
await this.sendNotificationToUser(userId, title, descr, openUrl, '', tag, actions);
|
||||||
|
}
|
||||||
|
|
||||||
// Invia Msg
|
// Invia Msg
|
||||||
if (domanda) {
|
if (domanda) {
|
||||||
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
|
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
|
||||||
@@ -4288,6 +4307,10 @@ if (true) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.ENTRA_RIS_ITALIA) {
|
||||||
|
|
||||||
|
url = '';
|
||||||
|
bot.answerCallbackQuery(callbackQuery.id, { url });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -907,6 +907,7 @@ module.exports = {
|
|||||||
let openUrl = '/';
|
let openUrl = '/';
|
||||||
let tag = '';
|
let tag = '';
|
||||||
let actions = [];
|
let actions = [];
|
||||||
|
let domanda = '';
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
|
if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
|
||||||
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), usernameOrig);
|
descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), usernameOrig);
|
||||||
@@ -940,7 +941,7 @@ module.exports = {
|
|||||||
|
|
||||||
const idtelegram = await User.TelegIdByUsername(idapp, username);
|
const idtelegram = await User.TelegIdByUsername(idapp, username);
|
||||||
|
|
||||||
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr);
|
await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr + domanda, undefined, undefined, true, keyb);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -248,6 +248,12 @@ module.exports = {
|
|||||||
VISIB_ONLY_MANAGER: 2,
|
VISIB_ONLY_MANAGER: 2,
|
||||||
VISIB_ONLY_ADMIN: 4,
|
VISIB_ONLY_ADMIN: 4,
|
||||||
|
|
||||||
|
CIRCUIT_CFG: {
|
||||||
|
MULT_FIDO_USER: 2.0,
|
||||||
|
MULT_FIDO_GROUP: 2.0,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
Visibility_Group: {
|
Visibility_Group: {
|
||||||
PRIVATE: 1,
|
PRIVATE: 1,
|
||||||
HIDDEN: 2,
|
HIDDEN: 2,
|
||||||
@@ -334,6 +340,7 @@ module.exports = {
|
|||||||
RICHIESTA_HANDSHAKE: 16,
|
RICHIESTA_HANDSHAKE: 16,
|
||||||
RICHIESTA_CIRCUIT: 20,
|
RICHIESTA_CIRCUIT: 20,
|
||||||
RICHIESTA_FIDO: 25,
|
RICHIESTA_FIDO: 25,
|
||||||
|
ENTRA_RIS_ITALIA: 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
OrderStatus: {
|
OrderStatus: {
|
||||||
@@ -643,6 +650,7 @@ module.exports = {
|
|||||||
nome_valuta: 1,
|
nome_valuta: 1,
|
||||||
fido_scoperto_default: 1,
|
fido_scoperto_default: 1,
|
||||||
deperimento: 1,
|
deperimento: 1,
|
||||||
|
showAlways: 1,
|
||||||
status: 1,
|
status: 1,
|
||||||
transactionsEnabled: 1,
|
transactionsEnabled: 1,
|
||||||
qta_max_default: 1,
|
qta_max_default: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user