Modifiche prima di Luglio...
This commit is contained in:
@@ -1082,7 +1082,7 @@ module.exports = {
|
||||
let typeid = 0;
|
||||
let onlysave = false;
|
||||
let numuserincircuit = await User.countUsersInCircuit(idapp, circuitname);
|
||||
const mycircuit = await Circuit.findOne({name: circuitname}).lean();
|
||||
const mycircuit = await Circuit.findOne({ name: circuitname }).lean();
|
||||
if (mycircuit) {
|
||||
extrarec.fido_scoperto_default = mycircuit.fido_scoperto_default;
|
||||
extrarec.fido_scoperto_default_grp = mycircuit.fido_scoperto_default_grp;
|
||||
@@ -1433,26 +1433,37 @@ module.exports = {
|
||||
},
|
||||
*/
|
||||
|
||||
sendNotifToAdmin(title, msg, tag = '') {
|
||||
const { User } = require('../models/user');
|
||||
sendNotifToAdmin(idapp, alsotelegram, title, msg, tag = '') {
|
||||
try {
|
||||
const { User } = require('../models/user');
|
||||
|
||||
// console.log('nomeapp 1: ' , this.getNomeAppByIdApp(1));
|
||||
// console.log('nomeapp 2: ' , this.getNomeAppByIdApp(2));
|
||||
const queryadmins = { username: 'paoloar77', idapp };
|
||||
|
||||
User.find({ username: 'paoloar77', idapp: '1' }).then(async (arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
await this.sendNotificationToUser(user._id, title, msg, '/', '', tag, []).
|
||||
then(ris => {
|
||||
if (ris) {
|
||||
if (idapp === 0)
|
||||
idapp = '13';
|
||||
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
});
|
||||
User.find(queryadmins).then(async (arrusers) => {
|
||||
if (arrusers !== null) {
|
||||
for (const user of arrusers) {
|
||||
if (alsotelegram) {
|
||||
this.sendMsgTelegramToAdmin(idapp, title + ' ' + msg);
|
||||
}
|
||||
|
||||
await this.sendNotificationToUser(user._id, title, msg, '/', '', tag, []).
|
||||
then(ris => {
|
||||
if (ris) {
|
||||
|
||||
} else {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -4063,10 +4074,15 @@ module.exports = {
|
||||
let myhost = this.getHostByIdApp(params.idapp);
|
||||
|
||||
if (params.textaddTelegram) {
|
||||
if (params.openUrl)
|
||||
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + params.textaddTelegram + '</a>';
|
||||
content = content + '\n' + params.textaddTelegram;
|
||||
}
|
||||
|
||||
if (params.linkaddTelegram) {
|
||||
if (params.openUrl)
|
||||
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + params.linkaddTelegram + '</a>';
|
||||
}
|
||||
|
||||
|
||||
/*if (params.openUrl)
|
||||
content = content + '\n' + '<a href="' + myhost + params.openUrl + '">' + i18n.__('OPEN PAGE') + '</a>';
|
||||
|
||||
|
||||
@@ -252,6 +252,7 @@ module.exports = {
|
||||
actions: recnotif.actions ? recnotif.actions : [],
|
||||
id: recnotif._id,
|
||||
textaddTelegram: recnotif.textaddTelegram ? recnotif.textaddTelegram : '',
|
||||
linkaddTelegram: recnotif.linkaddTelegram ? recnotif.linkaddTelegram : '',
|
||||
};
|
||||
|
||||
if (tools.isBitActive(recnotif.typesend, shared_consts.MessageOptions.Notify_ByPushNotification) && this.checkifSendPushNotification) {
|
||||
@@ -380,7 +381,9 @@ module.exports = {
|
||||
const mytitle = await tools.convertSpecialTags(user, params.title);
|
||||
const mycontent = await tools.convertSpecialTags(user, params.content);
|
||||
|
||||
const usernotifprofile = user.profile.notifs.find((notif) => notif.dir === params.typenotif);
|
||||
let usernotifprofile = null;
|
||||
if (user.profile.notifs)
|
||||
usernotifprofile = user.profile.notifs.find((notif) => notif.dir === params.typenotif);
|
||||
|
||||
let risult = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user