Modifiche prima di Luglio...
This commit is contained in:
@@ -40,10 +40,10 @@
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Abilita fido a %s nel '%s':",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍♂️ Abilita fido nel Circuito al gruppo %s:",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s ed è in attesa di essere abilitato al Fido (è stato invitato da %s)",
|
||||
"CIRCUIT_ADMINS": "\nGli amministratori del circuito sono %s:\n%s",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato al Fido (è stato invitato da %s)",
|
||||
"CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s",
|
||||
"CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s",
|
||||
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel %s",
|
||||
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel %s (con %s iscritti)",
|
||||
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
|
||||
"CIRCUIT_REQUEST": "Richiesta di entrare nel %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del %s da parte di %s",
|
||||
|
||||
@@ -418,6 +418,9 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
|
||||
AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
|
||||
|
||||
if (!groupname) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
|
||||
@@ -658,7 +658,7 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_FIDO', usernameOrig);
|
||||
}
|
||||
|
||||
if (accountdestTable.saldo + myqty > accountorigTable.qta_maxConcessa) {
|
||||
if (accountdestTable.saldo + myqty > accountdestTable.qta_maxConcessa) {
|
||||
ris.cansend = false;
|
||||
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_QTAMAX', extrarec.dest);
|
||||
}
|
||||
@@ -697,7 +697,8 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupdest ? extrarec.groupdest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
|
||||
|
||||
ris.result = true;
|
||||
let msg = 'Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal + `] [Saldo ${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + ` [Saldo ${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
|
||||
let msg = '[<b>' + circuittable.name + '</b>]: Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal +
|
||||
`]\nSaldi:\n${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + `\n${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
|
||||
console.log(msg);
|
||||
|
||||
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
|
||||
@@ -875,6 +876,19 @@ CircuitSchema.statics.AbilitaTuttiCircuiti = async function (idapp) {
|
||||
return ris;
|
||||
};
|
||||
|
||||
CircuitSchema.statics.AzzeraRegolamentiTuttiCircuiti = async function (idapp) {
|
||||
|
||||
ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
regulation: '',
|
||||
}
|
||||
});
|
||||
|
||||
return ris;
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax, circuitId) {
|
||||
|
||||
@@ -978,12 +992,12 @@ CircuitSchema.statics.getListAdmins = async function (idapp, circuitname) {
|
||||
let mystr = '';
|
||||
|
||||
if (arr) {
|
||||
for (const admin of arr.admins) {
|
||||
for (const admin of arr.admins) {
|
||||
mystr += await tools.getAhref(admin.username, await tools.getLinkUserTelegram(idapp, admin.username)) + ', ';
|
||||
}
|
||||
}
|
||||
|
||||
return {str: mystr, num: arr ? arr.admins.length : 0};
|
||||
return { str: mystr, num: arr ? arr.admins.length : 0 };
|
||||
|
||||
};
|
||||
|
||||
@@ -998,7 +1012,7 @@ CircuitSchema.statics.isAdminCircuit = async function (idapp, circuitname, usern
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
if (arr) {
|
||||
for (const admin of arr.admins) {
|
||||
for (const admin of arr.admins) {
|
||||
if (admin.username === username)
|
||||
return true;
|
||||
}
|
||||
@@ -1015,11 +1029,26 @@ CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, usernam
|
||||
const myuser = await User.getUserByUsername(idapp, username);
|
||||
|
||||
const useraccounts = await Account.getUserAccounts(idapp, username);
|
||||
const groupsaccounts = await Account.getGroupAccounts(idapp, groupname);
|
||||
|
||||
|
||||
|
||||
for (let account of useraccounts) {
|
||||
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
|
||||
mystr += '\n👉🏻 ' + account.circuit.name + '\n';
|
||||
mystr += '[Saldo: ' + account.saldo + ' RIS, ';
|
||||
if (account.groupname === '') {
|
||||
mystr += '\n👉🏻 ' + account.circuit.name + '\n';
|
||||
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
|
||||
mystr += ' Fido: ' + account.fidoConcesso + ' RIS, ';
|
||||
mystr += ' Transato: ' + account.totTransato + ' RIS]';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (let account of groupsaccounts) {
|
||||
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
|
||||
mystr += '\n GRUPPO: 👉🏻 <b>' + account.groupname + '</b> in ' + account.circuit.name + '\n';
|
||||
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
|
||||
mystr += ' Fido: ' + account.fidoConcesso + ' RIS, ';
|
||||
mystr += ' Transato: ' + account.totTransato + ' RIS]';
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ const sendNotifSchema = new Schema({
|
||||
},
|
||||
textaddTelegram: {
|
||||
type: String,
|
||||
},
|
||||
linkaddTelegram: {
|
||||
type: String,
|
||||
}
|
||||
});
|
||||
|
||||
@@ -197,7 +200,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYHOSPS, true) + myidrec;
|
||||
tag = 'newhosp';
|
||||
}
|
||||
recnotif.textaddTelegram = 'Vedi annuncio';
|
||||
recnotif.linkaddTelegram = 'Vedi annuncio';
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_EVENTS) {
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec;
|
||||
tag = 'newevent';
|
||||
@@ -217,7 +220,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
tag = 'attend';
|
||||
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(recnotif.paramsObj.recObjCreator.table, true) + recnotif.paramsObj.recObjCreator.id;
|
||||
recnotif.textaddTelegram = 'Vedi post';
|
||||
recnotif.linkaddTelegram = 'Vedi post';
|
||||
}
|
||||
|
||||
} else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
||||
@@ -332,6 +335,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
let username_action = '';
|
||||
let username_mittente = '';
|
||||
let circuitname = '';
|
||||
let numuserincircuit = 0;
|
||||
try {
|
||||
username_action = recnotif.paramsObj.username_action
|
||||
username_mittente = recnotif.paramsObj.sender ? recnotif.paramsObj.sender : username_action
|
||||
@@ -341,9 +345,13 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
qty = recnotif.paramsObj.extrarec && recnotif.paramsObj.extrarec.qty ? recnotif.paramsObj.extrarec.qty.toString() : '';
|
||||
symbol = recnotif.paramsObj.extrarec ? recnotif.paramsObj.extrarec.symbol : '';
|
||||
circuitname = recnotif.paramsObj.circuitnameDest;
|
||||
numuserincircuit = await User.countUsersInCircuit(recnotif.idapp, circuitname);
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
recnotif.textaddTelegram = '';
|
||||
|
||||
if (groupOComdest) {
|
||||
destinatario += ' (' + username_mittente + ')'
|
||||
}
|
||||
@@ -408,18 +416,19 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
tag = 'refcircuit';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_REQUEST_TO_ENTER) {
|
||||
|
||||
aportador_solidario = await User.getAportadorSolidarioByUsername(idapp, sender);
|
||||
aportador_solidario = await User.getAportadorSolidarioByUsername(recnotif.idapp, sender);
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP', recnotif.extrarec.groupname, recnotif.paramsObj.circuitnameDest,
|
||||
recnotif.paramsObj.singleadmin_username);
|
||||
numuserincircuit, recnotif.paramsObj.singleadmin_username);
|
||||
|
||||
} else {
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', sender, '<strong>' + recnotif.paramsObj.circuitnameDest + '</strong>', aportador_solidario);
|
||||
newdescr = i18n.__('CIRCUIT_REQUEST_TO_ENTER', sender, '<strong>' + recnotif.paramsObj.circuitnameDest + '</strong>', numuserincircuit, aportador_solidario);
|
||||
|
||||
const myadmins = await Circuit.getListAdmins(recnotif.idapp, recnotif.paramsObj.circuitnameDest);
|
||||
|
||||
newdescr += '\n' + i18n.__('CIRCUIT_ADMINS', myadmins.num, myadmins.str);
|
||||
newdescr += '\n' + i18n.__('CIRCUIT_WHERE_IS_PRESENT', await Circuit.getListCircuitsByUsername(recnotif.idapp, sender, recnotif.extrarec.groupname));
|
||||
}
|
||||
const myadmins = await Circuit.getListAdmins(recnotif.idapp, recnotif.paramsObj.circuitnameDest);
|
||||
recnotif.textaddTelegram += '\n' + i18n.__('CIRCUIT_ADMINS', myadmins.num, myadmins.str);
|
||||
recnotif.textaddTelegram += '\n' + i18n.__('CIRCUIT_WHERE_IS_PRESENT', await Circuit.getListCircuitsByUsername(recnotif.idapp, sender, recnotif.extrarec.groupname));
|
||||
|
||||
tag = 'reqcircuits';
|
||||
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_DELETE_USER) {
|
||||
@@ -530,7 +539,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
tag = 'favorite';
|
||||
|
||||
recnotif.openUrl = shared_consts.getDirectoryByTable(recnotif.paramsObj.recObjCreator.table, true) + recnotif.paramsObj.recObjCreator.id;
|
||||
recnotif.textaddTelegram = 'Vedi post';
|
||||
recnotif.linkaddTelegram = 'Vedi post';
|
||||
}
|
||||
|
||||
recnotif.tag = recnotif.tag ? recnotif.tag : tag;
|
||||
|
||||
@@ -1903,12 +1903,12 @@ UserSchema.statics.removeFromMyGroups = async function (
|
||||
|
||||
// Rimuovo il Circuito
|
||||
UserSchema.statics.removeFromCircuits = async function (idapp, username, circuitname) {
|
||||
|
||||
// Elimina la richiesta (se esiste):
|
||||
update = { $pull: { req_users: { username: { $in: [username] } } } };
|
||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
|
||||
return await User.updateOne({ idapp, username },
|
||||
// Elimina la richiesta (se esiste):
|
||||
update = { $pull: { req_users: { username: { $in: [username] } } } };
|
||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
|
||||
return await User.updateOne({ idapp, username },
|
||||
{ $pull: { 'profile.mycircuits': { circuitname: { $in: [circuitname] } } } });
|
||||
|
||||
};
|
||||
@@ -2670,6 +2670,9 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
});
|
||||
|
||||
if (value) {
|
||||
|
||||
ris = await this.addCircuitToUser(idapp, usernameOrig, circuitname, false, groupname, '');
|
||||
|
||||
if (!foundIfAlreadyAskCircuit) {
|
||||
update = {
|
||||
$push: {
|
||||
@@ -2741,6 +2744,10 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
|
||||
|
||||
if (groupname) {
|
||||
// Elimina la richiesta:
|
||||
update = { $pull: { req_groups: { groupname: { $in: [groupname] } } } };
|
||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
|
||||
outres.result = await MyGroup.removeCircuitFromGroup(idapp, groupname, circuitname); // Rimuovo l'Amicizia da me
|
||||
} else {
|
||||
|
||||
@@ -3426,7 +3433,7 @@ UserSchema.statics.getNameSurnameById = async function (idapp, userId) {
|
||||
UserSchema.statics.getusersManagers = async function (idapp) {
|
||||
const User = this;
|
||||
// Int32 mongodb 6.0
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true , perm: { $bitsAnySet: 0b010 } },
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true, perm: { $bitsAnySet: 0b010 } },
|
||||
{ username: 1, 'profile.teleg_id': 1, perm: 1 }).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -3439,7 +3446,7 @@ UserSchema.statics.getusersAdmin = async function (idapp) {
|
||||
|
||||
// Int32 mongodb 6.0
|
||||
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true, perm: { $bitsAnySet: 0b001 } },
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true, perm: { $bitsAnySet: 0b001 } },
|
||||
{ username: 1, 'profile.teleg_id': 1, perm: 1 }).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
|
||||
@@ -19,11 +19,17 @@ const { ObjectID } = require('mongodb');
|
||||
|
||||
async function getCircuitRecAdminsInfo(idapp, data) {
|
||||
|
||||
if (data && data.admins) {
|
||||
for (const admin of data.admins) {
|
||||
const myuser = await User.findOne({ idapp, username: admin.username }, { 'profile.img': 1 }).lean();
|
||||
admin.profile = { img: myuser.profile.img };
|
||||
try {
|
||||
if (data && data.admins) {
|
||||
for (const admin of data.admins) {
|
||||
const myuser = await User.findOne({ idapp, username: admin.username }, { 'profile.img': 1 }).lean();
|
||||
if (myuser && myuser.profile)
|
||||
admin.profile = { img: myuser.profile.img };
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return data;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -1874,10 +1874,14 @@ function deleteFile(req, res, version) {
|
||||
const relativefile = req.query.filename;
|
||||
const idapp = req.user.idapp;
|
||||
|
||||
if (!relativefile) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
let dirmain = '';
|
||||
if (version > 0) {
|
||||
if (tools.sulServer() !== 1) {
|
||||
if (!tools.sulServer()) {
|
||||
dirmain = '/public';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1319,6 +1319,10 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
|
||||
await Circuit.AbilitaTuttiCircuiti(idapp);
|
||||
|
||||
} else if (mydata.dbop === 'AzzeraRegolamentiTuttiCircuiti') {
|
||||
|
||||
await Circuit.AzzeraRegolamentiTuttiCircuiti(idapp);
|
||||
|
||||
} else if (mydata.dbop === 'setstrProvByIdCityCircuits') {
|
||||
|
||||
await Circuit.setstrProvByIdCityCircuits(idapp);
|
||||
|
||||
@@ -195,7 +195,7 @@ module.exports = {
|
||||
let aportador = mylocalsconf.aportador_solidario ? ' (da ' + mylocalsconf.aportador_solidario + ')' : '';
|
||||
|
||||
const numutenti = await User.getNumUsers(mylocalsconf.idapp);
|
||||
tools.sendNotifToAdmin('++ [' + numutenti + '] ' + nometot + aportador);
|
||||
tools.sendNotifToAdmin(mylocalsconf.idapp, true, '++Reg [' + numutenti + '] ' + nometot + aportador);
|
||||
}
|
||||
|
||||
// if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
@@ -227,7 +227,7 @@ module.exports = {
|
||||
|
||||
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_CONACREIS, mylocalsconf, 'MSG_ISCRITTO_CONACREIS');
|
||||
|
||||
tools.sendNotifToAdmin('Iscrizione Conacreis : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
|
||||
tools.sendNotifToAdmin(idapp, true, 'Iscrizione Conacreis : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
|
||||
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/iscrizione_conacreis/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
@@ -260,7 +260,7 @@ module.exports = {
|
||||
|
||||
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_ARCADEI, mylocalsconf, 'MSG_ISCRITTO_ARCADEI');
|
||||
|
||||
tools.sendNotifToAdmin('Iscrizione Arcadei : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
|
||||
tools.sendNotifToAdmin(idapp, true, 'Iscrizione Arcadei : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
|
||||
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
|
||||
@@ -805,7 +805,7 @@ const MyTelegramBot = {
|
||||
if (text) {
|
||||
|
||||
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp,
|
||||
addtext + text, false, null, userdest);
|
||||
addtext + text, false, null);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -3038,12 +3038,13 @@ class Telegram {
|
||||
let mymsg = msg.text.toString().trim().toLowerCase();
|
||||
let invitante = '';
|
||||
let regexpire = '';
|
||||
const sep = '-'
|
||||
if (mymsg.startsWith('/start')) {
|
||||
let myarrmsg = mymsg.split(' ');
|
||||
if (myarrmsg.length > 0) {
|
||||
mymsg = myarrmsg[1];
|
||||
if (mymsg.startsWith('inv#')) {
|
||||
let arrparams = mymsg.split('#');
|
||||
if (mymsg.startsWith('inv' + sep)) {
|
||||
let arrparams = mymsg.split(sep);
|
||||
if (arrparams.length > 2) {
|
||||
invitante = arrparams[1];
|
||||
regexpire = arrparams[3];
|
||||
|
||||
@@ -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