Versione 1.0.17
- Fix saldo pendente - aggiunto bottone markup Telegram - aggionta opzione per registrarsi direttamente su Telegram, senza doversi registrare ad un sito
This commit is contained in:
@@ -22,18 +22,22 @@ mongoose.plugin(schema => {
|
||||
const sendNotifSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
index: true,
|
||||
},
|
||||
typedir: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
index: true,
|
||||
},
|
||||
typeid: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
index: true,
|
||||
},
|
||||
sender: { // mittente
|
||||
type: String,
|
||||
default: '',
|
||||
index: true,
|
||||
},
|
||||
dest: {
|
||||
type: String,
|
||||
@@ -66,6 +70,7 @@ const sendNotifSchema = new Schema({
|
||||
status: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
index: true,
|
||||
},
|
||||
typesend: {
|
||||
type: Number,
|
||||
@@ -107,6 +112,14 @@ const sendNotifSchema = new Schema({
|
||||
}
|
||||
});
|
||||
|
||||
sendNotifSchema.index({ idapp: 1 });
|
||||
sendNotifSchema.index({ typedir: 1 });
|
||||
sendNotifSchema.index({ typeid: 1 });
|
||||
sendNotifSchema.index({ sender: 1 });
|
||||
|
||||
sendNotifSchema.index({ idapp: 1, typedir: 1, typeid: 1, status: 1, sender: 1 });
|
||||
|
||||
|
||||
sendNotifSchema.statics.setNotifAsRead = function (idapp, username, idnotif) {
|
||||
const SendNotif = this;
|
||||
|
||||
@@ -368,7 +381,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', -recnotif.paramsObj.extrarec.fido_scoperto_default_grp, recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest,
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fido_scoperto_default_grp, recnotif.paramsObj.circuitnameDest,
|
||||
username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fido_scoperto_default, recnotif.paramsObj.circuitnameDest,
|
||||
@@ -622,6 +635,8 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
|
||||
|
||||
// console.log('myrecout._id', myrecout._id.toString());
|
||||
|
||||
let risnotif = null;
|
||||
|
||||
if (save) {
|
||||
let res = null;
|
||||
try {
|
||||
@@ -633,7 +648,7 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
|
||||
// console.log('myrecread._id', myrecread._id.toString());
|
||||
|
||||
if (myrecread)
|
||||
return await globalTables.sendNotif(myrecread.typedir, myrecread.typeid, res, idapp, user ? user : req.user, myrecread);
|
||||
risnotif = await globalTables.sendNotif(myrecread.typedir, myrecread.typeid, res, idapp, user ? user : req.user, myrecread);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -644,9 +659,12 @@ sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res,
|
||||
}
|
||||
|
||||
} else {
|
||||
return await globalTables.sendNotif(myrecout.typedir, myrecout.typeid, res, idapp, user ? user : req.user, myrecout);
|
||||
risnotif = await globalTables.sendNotif(myrecout.typedir, myrecout.typeid, res, idapp, user ? user : req.user, myrecout);
|
||||
}
|
||||
|
||||
|
||||
return risnotif;
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlysave, userorig) {
|
||||
@@ -1031,9 +1049,14 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
||||
send = true;
|
||||
}
|
||||
}
|
||||
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA || myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
|
||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA
|
||||
|| myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS
|
||||
|| myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS
|
||||
) {
|
||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec)
|
||||
|| shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)
|
||||
|| shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)
|
||||
) {
|
||||
// Estrai la Città, la Provincia e la regione.
|
||||
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_YOUR_PROVINCE) &&
|
||||
@@ -1067,7 +1090,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
||||
}
|
||||
|
||||
}
|
||||
} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
/*} else if (myrecnotifpass.typedir === shared_consts.TypeNotifs.TYPEDIR_GROUPS) {
|
||||
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.GroupsNotifs.STATUS_GROUPS_NEW)) {
|
||||
send = true;
|
||||
@@ -1078,7 +1101,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.CircuitsNotif.STATUS_NEW)) {
|
||||
send = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (send) {
|
||||
@@ -1118,7 +1141,8 @@ sendNotifSchema.statics.sendToSingleUserDest = async function (myrecnotif, req,
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getSumPendingTransactions = async function (idapp, username, circuitname, groupname) {
|
||||
|
||||
sendNotifSchema.statics.getSumPendingTransactionsMittente = async function (idapp, username, circuitname, groupname) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -1140,9 +1164,60 @@ sendNotifSchema.statics.getSumPendingTransactions = async function (idapp, usern
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getSumPendingTransactionsDest = async function (idapp, username, circuitname, groupname) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
const query = {
|
||||
idapp,
|
||||
sender: username,
|
||||
sendergroup: groupname,
|
||||
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
|
||||
typeid: shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ,
|
||||
status: 0,
|
||||
'extrarec.circuitname': circuitname,
|
||||
'extrarec.dest': username,
|
||||
'extrarec.groupdest': groupname,
|
||||
};
|
||||
|
||||
return await SendNotif.find(query).lean();
|
||||
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.updatePendingTransactions = async function (recnotif) {
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
try {
|
||||
if (recnotif && recnotif.extrarec && recnotif.extrarec.circuitname) {
|
||||
|
||||
const circuit = await Circuit.getCircuitByName(recnotif.idapp, recnotif.extrarec.circuitname);
|
||||
|
||||
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(recnotif.idapp, recnotif.extrarec.dest, circuit._id, true, false, recnotif.extrarec.groupdest, recnotif.extrarec.contoComDest);
|
||||
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(recnotif.idapp, recnotif.sender, circuit._id, true, true, recnotif.extrarec.grouporig, recnotif.extrarec.contoComOrig);
|
||||
|
||||
if (accountdestTable)
|
||||
await accountdestTable.calcPending(false);
|
||||
if (accountorigTable)
|
||||
await accountorigTable.calcPending(true);
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
sendNotifSchema.statics.checkIfAlreadyExist = async function (idapp, tag, idpost, numtab) {
|
||||
|
||||
};
|
||||
|
||||
const SendNotif = mongoose.model('SendNotif', sendNotifSchema);
|
||||
|
||||
module.exports = { SendNotif: SendNotif };
|
||||
|
||||
Reference in New Issue
Block a user