Modifiche prima di Luglio...
This commit is contained in:
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
./node_modules
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose.yml
|
||||
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM node:alpine
|
||||
WORKDIR /Users/suryapaolo/myproject/freeplanet_serverside
|
||||
COPY package*.json .
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
#CMD ["npm", "start"]
|
||||
CMD ["npm", "run", "dev"]
|
||||
30
docker-compose.yml
Normal file
30
docker-compose.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
# mongoDB service
|
||||
mongo_db:
|
||||
container_name: db_container
|
||||
image: mongo:4.4
|
||||
restart: always
|
||||
ports:
|
||||
- 2717:27017
|
||||
volumes:
|
||||
- mongo_db:/data/db
|
||||
|
||||
# Node API service
|
||||
api:
|
||||
build: .
|
||||
ports:
|
||||
- 4000:3000
|
||||
volumes:
|
||||
- .:/Users/suryapaolo/myproject/freeplanet_serverside
|
||||
environment:
|
||||
PORT: 3000
|
||||
DOMAIN: mongodb://mongo_db:27017/
|
||||
DATABASE: test_FreePlanet
|
||||
UDB: paofreeplanet
|
||||
depends_on:
|
||||
- mongo_db
|
||||
|
||||
volumes:
|
||||
mongo_db: {}
|
||||
BIN
emails/admin/registration/.DS_Store
vendored
Normal file
BIN
emails/admin/registration/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -41,3 +41,5 @@ Dom 18/06 ORE 19:58: USER [paoloar77]: /start inv
|
||||
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
|
||||
|
||||
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
|
||||
|
||||
Ven 23/06 ORE 14:08: USER [paoloar77]: link da condividere
|
||||
|
||||
@@ -14,4 +14,8 @@ dasjdalksjdasdklasjkldasjlkdjasl
|
||||
Sab 17/06 ORE 20:03: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
pro v adsasdasdaksdas
|
||||
Dom 18/06 ORE 19:22: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
/start inv
|
||||
/start inv
|
||||
Ven 23/06 ORE 14:13: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Dom 25/06 ORE 16:11: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
10
logtrans.txt
10
logtrans.txt
@@ -12,4 +12,12 @@ Gio 01/06 ORE 12:31: Inviate Monete da paoloar77 a surya1977 4 RIS [causale: ] [
|
||||
Gio 01/06 ORE 17:26: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -9 RIS] [Saldo surya1977: 8 RIS]
|
||||
Gio 01/06 ORE 17:41: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -10 RIS] [Saldo surya1977: 9 RIS]
|
||||
Ven 02/06 ORE 19:29: Inviate Monete da paoloar77 a 2 RIS [causale: ] [Saldo paoloar77: 8 RIS] [Saldo : -261 RIS]
|
||||
Ven 02/06 ORE 19:31: Inviate Monete da paoloar77 a pontiUmani 4 RIS [causale: ] [Saldo paoloar77: 0 RIS] [Saldo pontiUmani: -253 RIS]
|
||||
Ven 02/06 ORE 19:31: Inviate Monete da paoloar77 a pontiUmani 4 RIS [causale: ] [Saldo paoloar77: 0 RIS] [Saldo pontiUmani: -253 RIS]
|
||||
Lun 26/06 ORE 23:23: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da risragusa (paoloar77) a paogruppo2 300 RIS [causale: aaa]
|
||||
Saldi:
|
||||
risragusa (paoloar77): -300 RIS]
|
||||
paogruppo2: 300 RIS]
|
||||
Lun 26/06 ORE 23:27: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da paoloar77 a paogruppo2 20 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -20 RIS]
|
||||
paogruppo2: 320 RIS]
|
||||
15
package.json
15
package.json
@@ -4,7 +4,8 @@
|
||||
"description": "freeplanet serverside",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
"start": "NODE_ENV=development nodemon src/server/server.js",
|
||||
"start": "node src/server/server.js",
|
||||
"dev": "NODE_ENV=development nodemon src/server/server.js",
|
||||
"build": "gulp build",
|
||||
"watch": "gulp watch",
|
||||
"test": "export NODE_ENV=development || SET NODE_ENV=development && mocha src/server/**/*.test.js",
|
||||
@@ -35,8 +36,8 @@
|
||||
"i18n": "^0.15.0",
|
||||
"image-downloader": "^4.3.0",
|
||||
"internet-available": "^1.0.0",
|
||||
"jade": "^1.11.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jade": "^1.9.2",
|
||||
"jsonwebtoken": "^9.0.1",
|
||||
"lodash": "^4.17.21",
|
||||
"mongodb": "^4.4.1",
|
||||
"mongoose": "^5.13.15",
|
||||
@@ -53,7 +54,7 @@
|
||||
"pug": "^3.0.2",
|
||||
"rate-limiter-flexible": "^2.3.9",
|
||||
"save": "^2.5.0",
|
||||
"sharp": "0.30.0",
|
||||
"sharp": "^0.30.7",
|
||||
"superagent": "^8.0.0",
|
||||
"url-parse": "^1.5.10",
|
||||
"validator": "^13.7.0",
|
||||
@@ -63,15 +64,15 @@
|
||||
"devDependencies": {
|
||||
"browser-sync": "^2.27.10",
|
||||
"expect": "^29.0.2",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-inline-css": "^4.0.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-inline-css": "^2.0.0",
|
||||
"gulp-pug": "^5.0.0",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-sass": "^5.1.0",
|
||||
"jest": "^29.0.2",
|
||||
"mocha": "^10.0.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"nodemon": "^3.0.1",
|
||||
"supertest": "^6.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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