ver 0.5.51
This commit is contained in:
@@ -6,7 +6,7 @@ mongoose.level = 'F';
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
@@ -39,6 +39,14 @@ const sendNotifSchema = new Schema({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
sendergroup: { // mittente
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
destgroup: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
@@ -90,7 +98,7 @@ const sendNotifSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
||||
sendNotifSchema.statics.setNotifAsRead = function (idapp, username, idnotif) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -98,15 +106,15 @@ sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
||||
if (idnotif) {
|
||||
return SendNotif.findOneAndUpdate({
|
||||
$and: [
|
||||
{idapp},
|
||||
{dest: username},
|
||||
{'_id': idnotif},
|
||||
{ idapp },
|
||||
{ dest: username },
|
||||
{ '_id': idnotif },
|
||||
],
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
|
||||
}, {$set: {read: true}}, {new: false}).then((ret) => {
|
||||
}, { $set: { read: true } }, { new: false }).then((ret) => {
|
||||
return !!ret;
|
||||
}).catch((err) => {
|
||||
console.error('err', err);
|
||||
@@ -117,7 +125,7 @@ sendNotifSchema.statics.setNotifAsRead = function(idapp, username, idnotif) {
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getRecNotif = function(id) {
|
||||
sendNotifSchema.statics.getRecNotif = function (id) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -128,16 +136,16 @@ sendNotifSchema.statics.getRecNotif = function(id) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function(username, lastdataread, idapp) {
|
||||
sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function (username, lastdataread, idapp) {
|
||||
const SendNotif = this;
|
||||
|
||||
return SendNotif.find({
|
||||
$and: [
|
||||
{idapp},
|
||||
{'dest': username},
|
||||
{'datenotif': {$gt: new Date(lastdataread)}},
|
||||
{ idapp },
|
||||
{ 'dest': username },
|
||||
{ 'datenotif': { $gt: new Date(lastdataread) } },
|
||||
],
|
||||
}).lean().sort({datenotif: -1}).then(async (arrnotif) => {
|
||||
}).lean().sort({ datenotif: -1 }).then(async (arrnotif) => {
|
||||
// console.log('arrnotif', arrnotif.length);
|
||||
|
||||
return this.compileOtherFields(arrnotif);
|
||||
@@ -148,7 +156,7 @@ sendNotifSchema.statics.findAllNotifByUsernameIdAndIdApp = function(username, la
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif) {
|
||||
|
||||
const numchars = 80;
|
||||
let newdescr = '';
|
||||
@@ -275,8 +283,14 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
newdescr = i18n.__('CIRCUIT_CREATED', userorig, recnotif.paramsObj.circuitnameDest);
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('ACCETTATO_NOTIFICA_ADMINS_CIRCUIT', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.username_action);
|
||||
}
|
||||
|
||||
recnotif.openUrl = '/my/' + userorig;
|
||||
} else {
|
||||
if (userorig === recnotif.paramsObj.usernameDest) {
|
||||
@@ -307,8 +321,13 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
}
|
||||
tag = 'refcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER) {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP', recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.singleadmin_username);
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', userorig, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.singleadmin_username);
|
||||
}
|
||||
tag = 'reqcircuits';
|
||||
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
|
||||
@@ -332,34 +351,36 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
tag = 'removeadmincircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ) {
|
||||
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);
|
||||
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) {
|
||||
let mydest = recnotif.paramsObj.extrarec.groupdest ? recnotif.paramsObj.extrarec.groupdest : recnotif.paramsObj.extrarec.dest;
|
||||
|
||||
newdescr = i18n.__('CIRCUIT_SENDCOINSREQ_TO_ME', recnotif.paramsObj.extrarec.qty.toString(),
|
||||
recnotif.paramsObj.extrarec.symbol, recnotif.paramsObj.extrarec.dest);
|
||||
recnotif.paramsObj.extrarec.symbol, mydest);
|
||||
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) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest,
|
||||
recnotif.paramsObj.username_action) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoDest,
|
||||
recnotif.paramsObj.extrarec.symbol
|
||||
);
|
||||
);
|
||||
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) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig,
|
||||
recnotif.paramsObj.extrarec.symbol,
|
||||
recnotif.paramsObj.extrarec.dest) + `\n` + i18n.__('SALDO_UPDATE', recnotif.paramsObj.extrarec.saldoOrig,
|
||||
recnotif.paramsObj.extrarec.symbol);
|
||||
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);
|
||||
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';ac
|
||||
recnotif.paramsObj.extrarec.dest);
|
||||
tag = 'sendcoin'; ac
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,14 +398,14 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function(recnotif) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.compileOtherFields = async function(arrnotif) {
|
||||
sendNotifSchema.statics.compileOtherFields = async function (arrnotif) {
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
try {
|
||||
// Fill in the image profile of the semyinders !
|
||||
for (const notif of arrnotif) {
|
||||
let myimgprofile = await User.findOne({idapp: notif.idapp, username: notif.sender}, {'profile.img': 1}).lean();
|
||||
let myimgprofile = await User.findOne({ idapp: notif.idapp, username: notif.sender }, { 'profile.img': 1 }).lean();
|
||||
if (myimgprofile && myimgprofile.profile.img)
|
||||
notif.myimgsender = 'upload/profile/' + notif.sender + '/' + myimgprofile.profile.img;
|
||||
}
|
||||
@@ -398,7 +419,7 @@ sendNotifSchema.statics.compileOtherFields = async function(arrnotif) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function(username, idapp, limit) {
|
||||
sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function (username, idapp, limit) {
|
||||
const SendNotif = this;
|
||||
|
||||
return SendNotif.aggregate([
|
||||
@@ -408,9 +429,9 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function(username, idap
|
||||
dest: username,
|
||||
},
|
||||
},
|
||||
{$limit: limit},
|
||||
{ $limit: limit },
|
||||
{
|
||||
$sort: {datenotif: -1},
|
||||
$sort: { datenotif: -1 },
|
||||
},
|
||||
]).then(async (arrnotif) => {
|
||||
return this.compileOtherFields(arrnotif);
|
||||
@@ -421,14 +442,16 @@ sendNotifSchema.statics.findLastNotifsByUserIdAndIdApp = function(username, idap
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.saveAndSendNotif = async function(myrecnotif, req, res, user) {
|
||||
sendNotifSchema.statics.saveAndSendNotif = async function (myrecnotif, req, res, user) {
|
||||
const SendNotif = this;
|
||||
|
||||
let idapp = req.body.idapp;
|
||||
const check = tools.checkUserOk(myrecnotif.sender, user ? myrecnotif.sender : req.user.username, res);
|
||||
let check = tools.checkUserOk(myrecnotif.sender, user ? myrecnotif.sender : req.user.username, res);
|
||||
if (!check)
|
||||
check = tools.checkUserOk(myrecnotif.sendergroup, user ? myrecnotif.sendergroup : req.user.username, res);
|
||||
if (check.exit) return check.ret;
|
||||
|
||||
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, false);
|
||||
const { myrecout, save } = await SendNotif.updateStatusAndDescr(myrecnotif, false);
|
||||
if (!myrecout)
|
||||
return null;
|
||||
|
||||
@@ -458,7 +481,7 @@ sendNotifSchema.statics.saveAndSendNotif = async function(myrecnotif, req, res,
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysave) {
|
||||
sendNotifSchema.statics.updateStatusAndDescr = async function (myrecnotif, onlysave) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -474,6 +497,8 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
|
||||
let sender = myrecnotif.sender;
|
||||
let newdest = myrecnotif.dest;
|
||||
let sendergroup = myrecnotif.sendergroup;
|
||||
let newdestgroup = myrecnotif.destgroup;
|
||||
|
||||
// Controllare se devo modificare un Notif già esistente !
|
||||
if (myrecnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
||||
@@ -550,6 +575,8 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
datenotif: new Date(),
|
||||
sender,
|
||||
dest: newdest,
|
||||
sendergroup,
|
||||
destgroup: newdestgroup,
|
||||
};
|
||||
|
||||
let query = {
|
||||
@@ -569,13 +596,13 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
}
|
||||
|
||||
// Cerca il record e se lo trova lo aggiorna
|
||||
const myrec = await SendNotif.findOneAndUpdate(query, {$set: fields_to_update}, {
|
||||
const myrec = await SendNotif.findOneAndUpdate(query, { $set: fields_to_update }, {
|
||||
new: true,
|
||||
returnNewDocument: true,
|
||||
});
|
||||
|
||||
if (myrec) {
|
||||
return {myrecout: myrec, save: false};
|
||||
return { myrecout: myrec, save: false };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,19 +611,19 @@ sendNotifSchema.statics.updateStatusAndDescr = async function(myrecnotif, onlysa
|
||||
myrecnotif.status = newstatus;
|
||||
}
|
||||
|
||||
return {myrecout: myrecnotif, save: true};
|
||||
return { myrecout: myrecnotif, save: true };
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return {myrecout: null, save: false};
|
||||
return { myrecout: null, save: false };
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getStatus = async function(notifId) {
|
||||
sendNotifSchema.statics.getStatus = async function (notifId) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
return await SendNotif.findOne({_id: notifId}, {status: 1}).lean().then((rec) => rec.status);
|
||||
return await SendNotif.findOne({ _id: notifId }, { status: 1 }).lean().then((rec) => rec.status);
|
||||
|
||||
} catch (e) {
|
||||
return 0;
|
||||
@@ -604,7 +631,7 @@ sendNotifSchema.statics.getStatus = async function(notifId) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
sendNotifSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -612,7 +639,7 @@ sendNotifSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
|
||||
if (status !== null) {
|
||||
return (status === shared_consts.CircuitsNotif.STATUS_COINS_ACCEPTED) ||
|
||||
(status === shared_consts.CircuitsNotif.STATUS_COINS_REFUSED);
|
||||
(status === shared_consts.CircuitsNotif.STATUS_COINS_REFUSED);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -624,11 +651,11 @@ sendNotifSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
||||
sendNotifSchema.statics.saveNotif = async function (myrecnotif) {
|
||||
|
||||
const SendNotif = this;
|
||||
|
||||
const {myrecout, save} = await SendNotif.updateStatusAndDescr(myrecnotif, true);
|
||||
const { myrecout, save } = await SendNotif.updateStatusAndDescr(myrecnotif, true);
|
||||
if (!myrecout)
|
||||
return null;
|
||||
|
||||
@@ -644,14 +671,16 @@ sendNotifSchema.statics.saveNotif = async function(myrecnotif) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getDefaultRec = function(req) {
|
||||
sendNotifSchema.statics.getDefaultRec = function (req) {
|
||||
|
||||
return {
|
||||
idapp: req.body.idapp,
|
||||
typedir: '',
|
||||
typeid: '',
|
||||
sender: req.user ? req.user.username : '',
|
||||
sendergroup: '',
|
||||
dest: '',
|
||||
destgroup: '',
|
||||
descr: '',
|
||||
openUrl: '',
|
||||
datenotif: new Date(),
|
||||
@@ -663,7 +692,7 @@ sendNotifSchema.statics.getDefaultRec = function(req) {
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getExtraParam = function(myrecnotif, paramsObj) {
|
||||
sendNotifSchema.statics.getExtraParam = function (myrecnotif, paramsObj) {
|
||||
let out = myrecnotif;
|
||||
//if (myrecnotif._doc) {
|
||||
//out = myrecnotif._doc
|
||||
@@ -681,7 +710,7 @@ sendNotifSchema.statics.getExtraParam = function(myrecnotif, paramsObj) {
|
||||
return myrecnotif;
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.createNewNotification = async function(req, res, paramsObj, table, rec, typedir, typeid) {
|
||||
sendNotifSchema.statics.createNewNotification = async function (req, res, paramsObj, table, rec, typedir, typeid) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -705,7 +734,7 @@ sendNotifSchema.statics.createNewNotification = async function(req, res, paramsO
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, paramsObj, onlysave, typedir, typeid) {
|
||||
sendNotifSchema.statics.createNewNotifToSingleUser = async function (req, res, paramsObj, onlysave, typedir, typeid) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
@@ -723,13 +752,13 @@ sendNotifSchema.statics.createNewNotifToSingleUser = async function(req, res, pa
|
||||
}
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, req, res) {
|
||||
sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass, req, res) {
|
||||
const SendNotif = this;
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
const { City } = require('../models/city');
|
||||
const { Province } = require('../models/province');
|
||||
|
||||
try {
|
||||
|
||||
@@ -737,8 +766,8 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
const userlist = await User.find({
|
||||
idapp: myrecnotifpass.idapp,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
@@ -760,9 +789,9 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
const mytable = globalTables.getTableByTableName(myrecnotifpass.tablerec);
|
||||
|
||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
|
||||
const myrectableorig = await mytable.findOne({_id: myrecnotifpass.idrec}).lean();
|
||||
const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
||||
if (myrectableorig) {
|
||||
for (const city of myrectableorig.idCity) {
|
||||
arrprovinces.push(await City.getProvinceByIdCity(city));
|
||||
@@ -790,16 +819,16 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
let send = false;
|
||||
|
||||
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(myrecnotifpass.tablerec) ||
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
shared_consts.TABLES_EVENTS_NOTIFICATION.includes(myrecnotifpass.tablerec)) {
|
||||
// Estrai la Città, la Provincia e la regione.
|
||||
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_PROVINCE) &&
|
||||
user.profile.notif_provinces && user.profile.notif_provinces.some(r => arrprovinces.indexOf(r) >= 0)) {
|
||||
user.profile.notif_provinces && user.profile.notif_provinces.some(r => arrprovinces.indexOf(r) >= 0)) {
|
||||
send = true;
|
||||
}
|
||||
|
||||
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_REGION) &&
|
||||
user.profile.notif_regions && user.profile.notif_regions.some(r => arrregions.indexOf(r) >= 0)) {
|
||||
user.profile.notif_regions && user.profile.notif_regions.some(r => arrregions.indexOf(r) >= 0)) {
|
||||
send = true;
|
||||
}
|
||||
|
||||
@@ -836,15 +865,15 @@ sendNotifSchema.statics.sendToTheDestinations = async function(myrecnotifpass, r
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, res, onlysave) {
|
||||
sendNotifSchema.statics.sendToSingleUserDest = async function (myrecnotif, req, res, onlysave) {
|
||||
const SendNotif = this;
|
||||
|
||||
try {
|
||||
|
||||
myrecnotif.dest = myrecnotif.paramsObj && myrecnotif.paramsObj.usernameDest ? myrecnotif.paramsObj.usernameDest : '';
|
||||
myrecnotif.username_worked = myrecnotif.paramsObj && myrecnotif.paramsObj.username_worked
|
||||
? myrecnotif.paramsObj.username_worked
|
||||
: myrecnotif.dest;
|
||||
? myrecnotif.paramsObj.username_worked
|
||||
: myrecnotif.dest;
|
||||
|
||||
if (onlysave) {
|
||||
return await SendNotif.saveNotif(myrecnotif);
|
||||
@@ -859,13 +888,14 @@ sendNotifSchema.statics.sendToSingleUserDest = async function(myrecnotif, req, r
|
||||
|
||||
};
|
||||
|
||||
sendNotifSchema.statics.getSumPendingTransactions = async function(idapp, username, circuitname) {
|
||||
sendNotifSchema.statics.getSumPendingTransactions = 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,
|
||||
@@ -882,4 +912,4 @@ sendNotifSchema.statics.getSumPendingTransactions = async function(idapp, userna
|
||||
|
||||
const SendNotif = mongoose.model('SendNotif', sendNotifSchema);
|
||||
|
||||
module.exports = {SendNotif: SendNotif};
|
||||
module.exports = { SendNotif: SendNotif };
|
||||
|
||||
Reference in New Issue
Block a user