Controllare che le notifiche per gli Eventi arrivino agli utenti (se io sono in una provincia mi deve arrivare almeno quella)
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
"Hello %s": "Ciao %s",
|
"Hello %s": "Ciao %s",
|
||||||
"Good: %s": "Bene: %s",
|
"Good: %s": "Bene: %s",
|
||||||
"Service: %s": "Servizio: %s",
|
"Service: %s": "Servizio: %s",
|
||||||
"NEW_GOOD": "<strong>%s</strong> ha aggiunto un nuovo Bene: %s",
|
"NEW_GOOD": "❇️ <strong>%s</strong> ha aggiunto un nuovo Bene: \n<strong>%s</strong>",
|
||||||
"NEW_SERVICE": "<strong>%s</strong> ha aggiunto un nuovo Servizio: %s",
|
"NEW_SERVICE": "❇️ <strong>%s</strong> ha aggiunto un nuovo Servizio: \n<strong>%s</strong>",
|
||||||
"NEW_HOSP": "<strong>%s</strong> ha aggiunto una nuova Ospitalità: %s",
|
"NEW_HOSP": "❇️ <strong>%s</strong> ha aggiunto una nuova Ospitalità: \n<strong>%s</strong>",
|
||||||
"NEW_EVENT": "<strong>%s</strong> ha aggiunto un nuovo Evento: %s",
|
"NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n<strong>%s</strong>",
|
||||||
"OPEN PAGE": "<em>APRI la APP RISO oppure visita riso.app</em>",
|
"OPEN PAGE": "<em>APRI la APP RISO oppure visita riso.app</em>",
|
||||||
"<strong>%s</strong> asked you for Friendship": "<strong>%s</strong> ti ha chiesto l'Amicizia",
|
"<strong>%s</strong> asked you for Friendship": "<strong>%s</strong> ti ha chiesto l'Amicizia",
|
||||||
"<strong>%s</strong> accepted your Friendship": "<strong>%s</strong> ha accettato l'Amicizia",
|
"<strong>%s</strong> accepted your Friendship": "<strong>%s</strong> ha accettato l'Amicizia",
|
||||||
|
|||||||
@@ -77,6 +77,17 @@ CitySchema.statics.getProvinceByIdCity = async function(idcity) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CitySchema.statics.getCircuitNameBystrProv = async function(strProv) {
|
||||||
|
const { Circuit } = require('../models/circuit');
|
||||||
|
|
||||||
|
const myrec = await Circuit.findOne({strProv}).lean();
|
||||||
|
if (myrec) {
|
||||||
|
return myrec.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
CitySchema.statics.getRegionByIdCity = async function(idcity) {
|
CitySchema.statics.getRegionByIdCity = async function(idcity) {
|
||||||
const myrec = await City.findOne({_id: idcity}).lean();
|
const myrec = await City.findOne({_id: idcity}).lean();
|
||||||
if (myrec) {
|
if (myrec) {
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
|||||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYHOSPS, true) + myidrec;
|
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYHOSPS, true) + myidrec;
|
||||||
tag = 'newhosp';
|
tag = 'newhosp';
|
||||||
}
|
}
|
||||||
|
recnotif.textaddTelegram = 'Vedi annuncio';
|
||||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
|
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
|
||||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec;
|
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec;
|
||||||
tag = 'newevent';
|
tag = 'newevent';
|
||||||
@@ -928,6 +929,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
// Send only to the destination to reach:
|
// Send only to the destination to reach:
|
||||||
const userlist = await User.find({
|
const userlist = await User.find({
|
||||||
idapp: myrecnotifpass.idapp,
|
idapp: myrecnotifpass.idapp,
|
||||||
|
// username: 'SuryaArena2', //TOGLIERE
|
||||||
$or: [
|
$or: [
|
||||||
{ deleted: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ deleted: { $exists: true, $eq: false } }],
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
@@ -938,6 +940,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
lang: 1,
|
lang: 1,
|
||||||
username: 1,
|
username: 1,
|
||||||
'profile.notifs': 1,
|
'profile.notifs': 1,
|
||||||
|
'profile.mycircuits': 1,
|
||||||
'profile.resid_province': 1,
|
'profile.resid_province': 1,
|
||||||
'profile.notif_idCities': 1,
|
'profile.notif_idCities': 1,
|
||||||
'profile.notif_provinces': 1,
|
'profile.notif_provinces': 1,
|
||||||
@@ -946,6 +949,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
'profile.notif_sector_goods': 1,
|
'profile.notif_sector_goods': 1,
|
||||||
}).lean();
|
}).lean();
|
||||||
|
|
||||||
|
let arrcircuits = [];
|
||||||
let arrprovinces = [];
|
let arrprovinces = [];
|
||||||
let arrregions = [];
|
let arrregions = [];
|
||||||
let idSector = 0;
|
let idSector = 0;
|
||||||
@@ -959,10 +963,13 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
||||||
if (myrectableorig) {
|
if (myrectableorig) {
|
||||||
for (const city of myrectableorig.idCity) {
|
for (const city of myrectableorig.idCity) {
|
||||||
|
const prov = await City.getProvinceByIdCity(city);
|
||||||
arrprovinces.push(await City.getProvinceByIdCity(city));
|
arrprovinces.push(await City.getProvinceByIdCity(city));
|
||||||
arrregions.push(await City.getRegionByIdCity(city));
|
arrregions.push(await City.getRegionByIdCity(city));
|
||||||
|
arrcircuits.push(await City.getCircuitNameBystrProv(prov));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
||||||
idSector = myrectableorig.idSectorGood;
|
idSector = myrectableorig.idSectorGood;
|
||||||
} else {
|
} else {
|
||||||
@@ -979,6 +986,8 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
|
|
||||||
for (const user of userlist) {
|
for (const user of userlist) {
|
||||||
|
|
||||||
|
const mycircuits = user.profile.mycircuits;
|
||||||
|
|
||||||
if (user.profile && user.profile.notifs) {
|
if (user.profile && user.profile.notifs) {
|
||||||
const usernotifprofile = user.profile.notifs.find((notif) => notif.dir === myrecnotifpass.typedir);
|
const usernotifprofile = user.profile.notifs.find((notif) => notif.dir === myrecnotifpass.typedir);
|
||||||
|
|
||||||
@@ -1017,6 +1026,11 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
send = true;
|
send = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_MY_RIS_CIRCUIT) &&
|
||||||
|
user.profile.mycircuits && user.profile.mycircuits.some(r => arrcircuits.indexOf(r.circuitname) >= 0)) {
|
||||||
|
send = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (idSector && usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_SECTOR)) {
|
if (idSector && usernotifprofile && tools.isBitActive(usernotifprofile.value, shared_consts.UsersNotif.NEW_ADV_SECTOR)) {
|
||||||
// Controlla se è del settore selezionato
|
// Controlla se è del settore selezionato
|
||||||
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
||||||
@@ -1040,7 +1054,7 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
if (send) {
|
if (send) {
|
||||||
let myrecnotif = new SendNotif(myrecnotifpass);
|
let myrecnotif = new SendNotif(myrecnotifpass);
|
||||||
myrecnotif.dest = user.username;
|
myrecnotif.dest = user.username;
|
||||||
return await SendNotif.saveAndSendNotif(myrecnotif, req, res, user);
|
await SendNotif.saveAndSendNotif(myrecnotif, req, res, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user