- email Abilitazione Circuito RISO
This commit is contained in:
@@ -56,6 +56,9 @@ const AccountSchema = new Schema({
|
||||
fidoConcesso: {
|
||||
type: Number,
|
||||
},
|
||||
username_admin_abilitante: {
|
||||
type: String,
|
||||
},
|
||||
qta_maxConcessa: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -318,6 +321,7 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (
|
||||
saldo: 0,
|
||||
saldo_pend: 0,
|
||||
fidoConcesso: 0,
|
||||
username_admin_abilitante: '',
|
||||
qta_maxConcessa: 0,
|
||||
totTransato: 0,
|
||||
numtransactions: 0,
|
||||
@@ -643,9 +647,10 @@ AccountSchema.statics.SetMinMaxPersonali = async function (idapp, fidoConcesso,
|
||||
}
|
||||
};
|
||||
|
||||
AccountSchema.statics.updateFido = async function (idapp, username, groupname, circuitId, fido) {
|
||||
AccountSchema.statics.updateFido = async function (idapp, username, groupname, circuitId, fido, username_action) {
|
||||
let paramstoupdate = {
|
||||
fidoConcesso: fido,
|
||||
username_admin_abilitante: username_action,
|
||||
};
|
||||
let risult = null;
|
||||
if (groupname) risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
|
||||
|
||||
@@ -174,6 +174,7 @@ const CircuitSchema = new Schema({
|
||||
{
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
enable_to_receive_email: { type: Boolean },
|
||||
},
|
||||
],
|
||||
photos: [
|
||||
@@ -1331,7 +1332,7 @@ CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, va
|
||||
}
|
||||
};
|
||||
|
||||
CircuitSchema.statics.setFido = async function (idapp, username, circuitName, groupname) {
|
||||
CircuitSchema.statics.setFido = async function (idapp, username, circuitName, groupname, username_action) {
|
||||
try {
|
||||
mycircuit = await Circuit.findOne({ idapp, name: circuitName }).lean();
|
||||
if (mycircuit) {
|
||||
@@ -1384,9 +1385,9 @@ CircuitSchema.statics.setFido = async function (idapp, username, circuitName, gr
|
||||
variato = await Account.updateQtaMax(idapp, username, groupname, circuitId, qtamax);
|
||||
}
|
||||
|
||||
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
||||
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido, username_action);
|
||||
if (ris) {
|
||||
return { qta_maxConcessa: qtamax, fidoConcesso: fido, changed: variato || (ris && ris.modifiedCount > 0) };
|
||||
return { qta_maxConcessa: qtamax, fidoConcesso: fido, username_admin_abilitante: username_action, changed: variato || (ris && ris.modifiedCount > 0) };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1882,6 +1883,15 @@ CircuitSchema.statics.getCircuitoItalia = async function (idapp) {
|
||||
return circuit;
|
||||
};
|
||||
|
||||
CircuitSchema.statics.isEnableToReceiveEmailByExtraRec = async function (idapp, recnotif) {
|
||||
let ricevo = true;
|
||||
if (recnotif.tag === 'setfido') {
|
||||
// Controllo se l'utente ha scelto di ricevere l'email
|
||||
}
|
||||
|
||||
return ricevo;
|
||||
};
|
||||
|
||||
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||
|
||||
Circuit.createIndexes()
|
||||
|
||||
@@ -505,6 +505,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
recnotif.paramsObj.circuitnameDest,
|
||||
username_action
|
||||
);
|
||||
tag = 'setfido_admin_group';
|
||||
} else {
|
||||
newdescr = i18n.__(
|
||||
'FIDO_IMPOSTATO_ADMINS_CIRCUIT',
|
||||
@@ -513,6 +514,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
recnotif.paramsObj.circuitnameDest,
|
||||
username_action
|
||||
);
|
||||
tag = 'setfido_admin';
|
||||
}
|
||||
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
@@ -520,11 +522,12 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
newdescr = i18n.__(
|
||||
'FIDO_IMPOSTATO',
|
||||
-recnotif.paramsObj.extrarec.fidoConcesso,
|
||||
username_action,
|
||||
recnotif.paramsObj.circuitnameDest
|
||||
recnotif.paramsObj.extrarec.username_admin_abilitante,
|
||||
recnotif.paramsObj.circuitnameDest,
|
||||
);
|
||||
tag = 'setfido';
|
||||
}
|
||||
tag = 'setfido';
|
||||
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
if (recnotif.extrarec.groupname) {
|
||||
@@ -971,7 +974,7 @@ sendNotifSchema.statics.findAllNotifCoinsAllIdAndIdApp = function (idapp) {
|
||||
});
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res, user) {
|
||||
sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res, user, paramsObj) {
|
||||
const SendNotif = this;
|
||||
|
||||
let idapp = req.body.idapp;
|
||||
@@ -1003,7 +1006,8 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
|
||||
res,
|
||||
idapp,
|
||||
user ? user : req.user,
|
||||
myrecread
|
||||
myrecread,
|
||||
paramsObj
|
||||
);
|
||||
else return false;
|
||||
}
|
||||
@@ -1018,7 +1022,8 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
|
||||
res,
|
||||
idapp,
|
||||
user ? user : req.user,
|
||||
myrecout
|
||||
myrecout,
|
||||
paramsObj
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1312,7 +1317,7 @@ sendNotifSchema.statics.createNewNotifToSingleUser = async function (req, res, p
|
||||
|
||||
myrecnotif = this.getExtraParam(myrecnotif, paramsObj);
|
||||
|
||||
return await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave);
|
||||
return await SendNotif.sendToSingleUserDest(myrecnotif, req, res, onlysave, paramsObj);
|
||||
} catch (e) {
|
||||
console.error('createNewNotification', e);
|
||||
return null;
|
||||
@@ -1547,7 +1552,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.sendToSingleUserDest = async function (myrecnotif, req, res, onlysave) {
|
||||
sendNotifSchema.statics.sendToSingleUserDest = async function (myrecnotif, req, res, onlysave, paramsObj) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -1559,9 +1564,9 @@ sendNotifSchema.statics.sendToSingleUserDest = async function (myrecnotif, req,
|
||||
: myrecnotif.dest;
|
||||
|
||||
if (onlysave) {
|
||||
return await SendNotif.saveNotif(myrecnotif, req);
|
||||
return await SendNotif.saveNotif(myrecnotif, req, paramsObj);
|
||||
} else {
|
||||
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, null);
|
||||
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, null, paramsObj);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('sendToSingleUserDest', e);
|
||||
|
||||
@@ -2547,8 +2547,7 @@ UserSchema.statics.getCircuitByTokenAndUsername = async function (idapp, usernam
|
||||
'profile.mycircuits.token': token,
|
||||
});
|
||||
|
||||
// Il circuito sarà in: circuit?.profile?.mycircuits?.[0]
|
||||
const foundCircuit = user?.profile?.mycircuits?.[0];
|
||||
const foundCircuit = user?.profile?.mycircuits?.find((c) => c.token === token);
|
||||
if (foundCircuit) {
|
||||
return { circuitname: foundCircuit.circuitname, user };
|
||||
}
|
||||
@@ -2557,6 +2556,7 @@ UserSchema.statics.getCircuitByTokenAndUsername = async function (idapp, usernam
|
||||
}
|
||||
return { circuitname: '', user: null };
|
||||
};
|
||||
|
||||
UserSchema.statics.removeAllUsersFromMyGroups = async function (idapp, groupnameDest) {
|
||||
return await User.updateMany({ idapp }, { $pull: { 'profile.mygroups': { groupname: { $in: [groupnameDest] } } } });
|
||||
};
|
||||
@@ -3458,11 +3458,12 @@ UserSchema.statics.setCircuitCmd = async function (
|
||||
}
|
||||
}
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
|
||||
ris = await Circuit.setFido(idapp, usernameOrig, circuitname, groupname);
|
||||
ris = await Circuit.setFido(idapp, usernameOrig, circuitname, groupname, username_action);
|
||||
if (ris && ris.fidoConcesso && ris.changed) {
|
||||
if (extrarec) {
|
||||
extrarec.fidoConcesso = ris.fidoConcesso;
|
||||
extrarec.qta_maxConcessa = ris.qta_maxConcessa;
|
||||
extrarec.username_admin_abilitante = ris.username_admin_abilitante;
|
||||
}
|
||||
|
||||
// Elimina la richiesta:
|
||||
@@ -3991,6 +3992,15 @@ UserSchema.statics.getInfoAskFriendByUsername = async function (idapp, username)
|
||||
.then((rec) => (!!rec ? rec : null));
|
||||
};
|
||||
|
||||
UserSchema.statics.isFidoConcesso = async function (idapp, username, nomeCircuito) {
|
||||
try {
|
||||
const myfido = await Circuit.getFido(idapp, username, nomeCircuito, '');
|
||||
return !!myfido && myfido > 0 ? true : false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
UserSchema.statics.getAskedFriendsByUsername = async function (idapp, username) {
|
||||
const whatToShow_Unknown = getWhatToShow_Unknown(idapp, username);
|
||||
|
||||
@@ -6946,6 +6956,16 @@ UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||
|
||||
// Nel tuo User schema, aggiungi questo metodo statico:
|
||||
|
||||
UserSchema.statics.isEnableToReceiveEmailByUsernameECmd = async function (idapp, username, cmd) {
|
||||
let ricevo = true;
|
||||
if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
|
||||
// Controllo se l'utente ha scelto di ricevere l'email
|
||||
|
||||
}
|
||||
|
||||
return ricevo;
|
||||
};
|
||||
|
||||
UserSchema.statics.getTokenByUsernameAndCircuitName = async function (idapp, username, circuitname) {
|
||||
const User = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user