diff --git a/src/server/locales/it.json b/src/server/locales/it.json
index 71fd2e7..7daa0a3 100644
--- a/src/server/locales/it.json
+++ b/src/server/locales/it.json
@@ -127,5 +127,6 @@
"π« Ti Γ¨ stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !
Contatta l'Assistenza Tecnica.": "π« Ti Γ¨ stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !
Contatta l'Assistenza Tecnica.",
"π« %s ha rifiutato l'accesso alla App a %s !": "π« %s ha rifiutato l'accesso alla App a %s !",
"β
Hai Ammesso l'accesso alla App a %s !": "β
Hai Ammesso l'accesso alla App a %s !",
- "Good: %": "Good: %"
+ "Good: %": "Good: %",
+ "Service: %": "Service: %"
}
\ No newline at end of file
diff --git a/src/server/models/mygroup.js b/src/server/models/mygroup.js
index 5fe1ca2..8c1f7fc 100755
--- a/src/server/models/mygroup.js
+++ b/src/server/models/mygroup.js
@@ -34,9 +34,9 @@ const MyGroupSchema = new Schema({
descr: {
type: String,
},
- idCatGrp: {
+ idCatGrp: [{
type: Number,
- },
+ }],
userId: {
type: String,
},
@@ -348,6 +348,17 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
},
},
{ $project: whatToShow },
+ {
+ $lookup: {
+ from: 'catgrps',
+ localField: 'idCatGrp',
+ foreignField: '_id',
+ as: 'recCatGrp',
+ },
+ },
+ {
+ $project: shared_consts.getProjectByTable(shared_consts.TABLES_MYGROUPS, {}),
+ },
];
diff --git a/src/server/populate/catgrps.js b/src/server/populate/catgrps.js
index 7d76ac3..f7216da 100644
--- a/src/server/populate/catgrps.js
+++ b/src/server/populate/catgrps.js
@@ -2,79 +2,105 @@ module.exports = {
list: [
{
_id: 1,
- descr: 'Abitare',
- },
- {
- _id: 2,
- descr: 'Arte',
+ descr: 'OspitalitΓ ed accoglienza',
+ color: '#00BCD4',
+ icon: 'fa fa-bed'
},
{
_id: 3,
- descr: 'Alimentazione',
+ descr: 'Prodotti Alimentari',
+ color: '#4CAF50',
+ icon: 'fa fa-apple-alt'
},
{
_id: 4,
- descr: 'Artigianato',
+ descr: 'Prodotti Artigianali e Artistici',
+ color: '#9C27B0',
+ icon: 'fa fa-paint-brush'
},
{
_id: 5,
- descr: 'Assistenza Legale',
- },
- {
- _id: 6,
- descr: 'Benessere',
- },
- {
- _id: 7,
- descr: 'Gruppi Locali',
+ descr: 'Servizi di Assistenza e Integrazione',
+ color: '#2196F3',
+ icon: 'fa fa-hands-helping'
},
{
_id: 8,
- descr: 'Istruzione',
- },
- {
- _id: 2,
- descr: 'Arte',
- },
- {
- _id: 9,
- descr: 'MobilitΓ ',
- },
- {
- _id: 10,
- descr: 'Sport',
- },
- {
- _id: 11,
- descr: 'Servizi',
+ descr: 'Servizi Formativi ed Educativi',
+ color: '#FFC107',
+ icon: 'fa fa-book'
},
{
_id: 12,
descr: 'Tecnologia',
- },
- {
- _id: 13,
- descr: 'Turismo',
+ color: '#607D8B',
+ icon: 'fa fa-laptop'
},
{
_id: 14,
- descr: 'Ecovillaggi / ComunitΓ ',
- },
- {
- _id: 15,
- descr: 'Feste',
- },
- {
- _id: 16,
- descr: 'Altro',
- },
- {
- _id: 17,
- descr: 'AutoProduzione',
+ descr: 'ComunitΓ ed Ecovillaggi',
+ color: '#8BC34A',
+ icon: 'fa fa-users'
},
{
_id: 18,
- descr: 'Salute',
+ descr: 'Salute e Benessere',
+ color: '#E91E63',
+ icon: 'fa fa-heart'
+ },
+ {
+ _id: 20,
+ descr: 'Progetti Umanitari (Volontari)',
+ color: '#F44336',
+ icon: 'fa fa-hands'
+ },
+ {
+ _id: 31,
+ descr: 'Servizi per l\'Agricoltura, orto',
+ color: '#009688',
+ icon: 'fa fa-leaf'
+ },
+ {
+ _id: 32,
+ descr: 'Servizi di Distribuzione e Logistica',
+ color: '#3F51B5',
+ icon: 'fa fa-truck'
+ },
+ {
+ _id: 33,
+ descr: 'Servizi di Consulenza',
+ color: '#CDDC39',
+ icon: 'fa fa-briefcase'
+ },
+ {
+ _id: 34,
+ descr: 'AttivitΓ Ricreative e di Intrattenim.',
+ color: '#FF5722',
+ icon: 'fa fa-music'
+ },
+ {
+ _id: 36,
+ descr: 'Manutenzione e riparazioni',
+ color: '#673AB7',
+ icon: 'fa fa-wrench'
+ },
+ {
+ _id: 37,
+ descr: 'Cura della persona',
+ color: '#FFEB3B',
+ icon: 'fa fa-user'
+ },
+ {
+ _id: 40,
+ descr: 'Energia',
+ color: '#03A9F4',
+ icon: 'fa fa-bolt'
+ },
+ {
+ _id: 41,
+ descr: 'Servizi e prodotti per la casa',
+ color: '#FF9800',
+ icon: 'fa fa-home'
},
],
-};
+};
\ No newline at end of file
diff --git a/src/server/populate/populate.js b/src/server/populate/populate.js
index b10e6c8..eaf7598 100644
--- a/src/server/populate/populate.js
+++ b/src/server/populate/populate.js
@@ -17,11 +17,11 @@ module.exports = {
const mydbfile = require(pathfile);
if (mydbfile && mydbfile.list) {
- return table.insertMany(mydbfile.list, {ordered: false}).
- then((ris) => {
- console.log('Populate table ', tablename);
- return !!ris;
- });
+ return table.insertMany(mydbfile.list, { ordered: false }).
+ then((ris) => {
+ console.log('Populate table ', tablename);
+ return !!ris;
+ });
}
}
} catch (e) {
@@ -31,52 +31,62 @@ module.exports = {
},
async insertIntoDb_NoDuplicate(attiva, tablename, table, field) {
-
let numrec = 0;
+ let numupdated = 0;
try {
-
- if (!attiva && await table.countDocuments({}) > 0)
- return;
+ if (!attiva && await table.countDocuments({}) > 0) return;
const pathfile = Path.join(__dirname, tablename + '.js');
if (tools.isFileExists(pathfile)) {
-
const mydbfile = require(pathfile);
if (mydbfile && mydbfile.list) {
for (const rec of mydbfile.list) {
- let obj = {};
- obj[field] = rec[field];
+ let query = {};
+ query[field] = rec[field];
- var mynewrec = new table(rec);
-
- if (rec.hasOwnProperty('idapp')) {
- obj.idapop = rec['idapp'];
+ if (rec.hasOwnProperty('_id')) {
+ query._id = rec._id;
}
- const exist = await table.find(obj);
- if (exist.length <= 0) {
- try {
- const ris = await mynewrec.save();
- if (ris) {
+ if (rec.hasOwnProperty('idapp')) {
+ query.idapp = rec.idapp;
+ }
+
+ try {
+ const existingDoc = await table.findOne(query);
+ if (!existingDoc) {
+
+ const { value: existingDoc, upserted } = await table.findOneAndUpdate(
+ query,
+ { $set: rec },
+ { upsert: true, new: true }
+ );
+
+ if (upserted) {
+ // Il documento non esisteva, Γ¨ stato creato
+ console.log('Inserted document with _id:', existingDoc._id);
numrec++;
}
- } catch (e) {
- console.log('error ', e);
- }
+ } else {
+ // Il documento esiste, lo aggiorniamo
+ await table.updateOne({ _id: existingDoc._id }, { $set: rec });
+ numupdated++;
+ }
+ } catch (e) {
+ console.log('Error processing record:', e);
}
}
- if (numrec > 0)
- console.log('*** Insert', numrec, 'record on ' + tablename);
-
+ if (numrec > 0 || numupdated > 0) {
+ console.log(`*** Inserted ${numrec} and updated ${numupdated} records in ${tablename}`);
+ }
}
}
} catch (e) {
- console.log('error insertIntoDb', e);
+ console.log('Error in insertIntoDb_NoDuplicate:', e);
}
-
},
async rewriteTable(table) {
@@ -85,15 +95,15 @@ module.exports = {
let field = '';
try {
- const {City} = require('../models/city');
- const {Province} = require('../models/province');
- const {Sector} = require('../models/sector');
- const {SectorGood} = require('../models/sectorgood');
- const {Skill} = require('../models/skill');
- const {Good} = require('../models/good');
+ const { City } = require('../models/city');
+ const { Province } = require('../models/province');
+ const { Sector } = require('../models/sector');
+ const { SectorGood } = require('../models/sectorgood');
+ const { Skill } = require('../models/skill');
+ const { Good } = require('../models/good');
// const {SubSkill} = require('../models/subskill');
- const {Contribtype} = require('../models/contribtype');
- const {Level} = require('../models/level');
+ const { Contribtype } = require('../models/contribtype');
+ const { Level } = require('../models/level');
if (table === 'cities') {
mytab = City;
@@ -127,11 +137,11 @@ module.exports = {
if (mytab) {
await mytab.collection.drop();
// mongoose.connection.db.dropCollection(table, function(err) {
- console.log('Delete ', table);
- // await mytab.remove({});
+ console.log('Delete ', table);
+ // await mytab.remove({});
- this.insertIntoDb_NoDuplicate(false, table, mytab, field);
-// });
+ this.insertIntoDb_NoDuplicate(false, table, mytab, field);
+ // });
}
return true;
} catch (e) {
diff --git a/src/server/populate/sectorgoods.js b/src/server/populate/sectorgoods.js
index baf774a..dfd40bd 100644
--- a/src/server/populate/sectorgoods.js
+++ b/src/server/populate/sectorgoods.js
@@ -19,7 +19,8 @@ module.exports = {
{_id: 17, descr: 'Attrezzature', icon: 'fas fa-tools', color: 'blue-7'},
{_id: 18, descr: 'Animali', icon: 'fas fa-paw', color: 'green-7'},
{_id: 19, descr: 'Arte / Decorazioni', icon: 'fas fa-palette', color: 'purple-7'},
- {_id: 20, descr: 'Agricoltura', icon: 'fa-seedling', color: 'green-7'},
+ {_id: 20, descr: 'Agricoltura', icon: 'fas fa-seedling', color: 'green-7'},
+ {_id: 21, descr: 'Elettrodomestici', icon: 'fas fa-blender', color: 'green-7'},
],
};
diff --git a/src/server/router/circuits_router.js b/src/server/router/circuits_router.js
index 1c48e8d..c984051 100755
--- a/src/server/router/circuits_router.js
+++ b/src/server/router/circuits_router.js
@@ -28,6 +28,11 @@ async function getCircuitRecAdminsInfo(idapp, data) {
if (myuser && myuser.profile)
admin.profile = { img: myuser.profile.img };
}
+
+ if (data.admins.length === 0) {
+ data.admins.push({username: shared_consts.USER_ADMIN_CIRCUITS})
+ }
+
}
} catch (e) {
console.error(e);
diff --git a/src/server/router/mygroups_router.js b/src/server/router/mygroups_router.js
index 3e92725..d7c3272 100755
--- a/src/server/router/mygroups_router.js
+++ b/src/server/router/mygroups_router.js
@@ -44,7 +44,8 @@ router.post('/load', authenticate, async (req, res) => {
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username);
- let data = await MyGroup.findOne({ idapp, groupname }, whatshow).lean();
+ // let data = await MyGroup.findOne({ idapp, groupname }, whatshow).lean();
+ let data = await MyGroup.getInfoGroupByGroupname(idapp, groupname);
/*
if (data.mycircuits) {
@@ -54,7 +55,8 @@ router.post('/load', authenticate, async (req, res) => {
}
}
*/
-
+
+
if (data.mycircuits) {
for (let i = 0; i < data.mycircuits.length; i++) {
const mycirc = await Circuit.findOne({ idapp, name: data.mycircuits[i].circuitname }).lean();
diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js
index 4da0296..893e49e 100755
--- a/src/server/telegram/telegrambot.js
+++ b/src/server/telegram/telegrambot.js
@@ -503,7 +503,7 @@ const txt = {
MSG_EXIT_TELEGRAM: 'L\'account Γ¨ stato ora scollegato da questo Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Si Γ¨ appena Registrato "%s" (n. %s)\nInvitato da %s',
- MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s si sta registrando alla App %d e ti chiede di poter entrare. Confermi di conoscerla ?',
+ MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s si sta registrando su %s e ti chiede di poter entrare. Confermi di conoscerla ?',
MSG_ACCEPT_NEWENTRY_INGROUP: 'βοΈπ₯ π§ββοΈ Accetta Ingresso nel GRUPPO %s:',
MSG_FRIENDS_NOT_ACCEPTED_CONFIRMED: 'π« Hai rifiutato la richiesta di Amicizia di %s !',
MSG_HANDSHAKE_NOT_ACCEPTED_CONFIRMED: 'π« Hai rifiutato la richiesta di Stretta di mano di %s !',
@@ -552,7 +552,7 @@ const txt_es = {
MSG_EXIT_TELEGRAM: 'La cuenta ha sido desconectada de Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Acaba de registrarse "%s (n. %s)"\n(Invitado de %s)',
- MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s Abilita Nuova Registrazione:',
+ MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s si sta registrando su %s e ti chiede di poter entrare. Confermi di conoscerla ?',
MSG_ACCEPT_NEWENTRY_INGROUP: 'βοΈπ₯ π§ββοΈ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: 'β
%s Γ¨ stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: 'β
Sei stato Ammesso correttamente da %s!',
@@ -585,7 +585,7 @@ const txt_fr = {
MSG_EXIT_TELEGRAM: 'L\'account a Γ©tΓ© dΓ©connectΓ© de Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Vous venez Γ peine de vous inscrire "%s (n. %s) %s',
- MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s Abilita Nuova Registrazione:',
+ MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s si sta registrando su %s e ti chiede di poter entrare. Confermi di conoscerla ?',
MSG_ACCEPT_NEWENTRY_INGROUP: 'βοΈπ₯ π§ββοΈ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: 'β
%s Γ¨ stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: 'β
Sei stato Ammesso correttamente da %s!',
@@ -616,7 +616,7 @@ const txt_si = {
MSG_EXIT_TELEGRAM: 'RaΔun se nahaja v programu Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
'Registracija registracije %s (n. %s)\n(povabil ga %s)',
- MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s Abilita Nuova Registrazione:',
+ MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s si sta registrando su %s e ti chiede di poter entrare. Confermi di conoscerla ?',
MSG_ACCEPT_NEWENTRY_INGROUP: 'βοΈπ₯ π§ββοΈ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: 'β
%s Γ¨ stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: 'β
Sei stato Ammesso correttamente da %s!',
@@ -646,7 +646,7 @@ const txt_en = {
MSG_EXIT_TELEGRAM: 'The account has now been disconnected from this Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' He/She\'s just registered "%s (n. %s)"\n(Invited from %s)',
- MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s Abilita Nuova Registrazione:',
+ MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s si sta registrando su %s e ti chiede di poter entrare. Confermi di conoscerla ?',
MSG_ACCEPT_NEWENTRY_INGROUP: 'βοΈπ₯ π§ββοΈ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: 'β
%s Γ¨ stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: 'β
Sei stato Ammesso correttamente da %s!',
@@ -679,7 +679,7 @@ const txt_pt = {
MSG_EXIT_TELEGRAM: 'A conta foi agora desconectada deste Telegrama BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Acabou de se registar "%s (n. %s)"\n(Convidado por %s)',
- MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s Abilita Nuova Registrazione:',
+ MSG_APORTADOR_ASK_CONFIRM: 'ππ₯ π§ββοΈ %s si sta registrando su %s e ti chiede di poter entrare. Confermi di conoscerla ?',
MSG_ACCEPT_NEWENTRY_INGROUP: 'βοΈπ₯ π§ββοΈ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: 'β
%s Γ¨ stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: 'β
Sei stato Ammesso correttamente da %s!',
@@ -939,7 +939,7 @@ const MyTelegramBot = {
await setVerifiedReg(myuser.idapp, myuser.lang, myuser.username, userDest);
} else {
- msg_notifpush = getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM', myuser.username);
+ msg_notifpush = getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM', myuser.username, nomeapp);
domanda = getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM', myuser.username, nomeapp) + '
' + struserinfomsg;
keyb = cl.getInlineKeyboard(myuser.lang, [
@@ -1539,7 +1539,7 @@ async function local_sendMsgTelegram(idapp, username, text) {
}
-function getstr(lang, key, param1) {
+function getstr(lang, key, ...params) {
let mystr = '';
@@ -1578,8 +1578,8 @@ function getstr(lang, key, param1) {
if (!mystr || mystr === '')
mystr = txt[key];
- if (!!param1) {
- mystr = printf(mystr, param1);
+ if (params.length > 0) {
+ mystr = printf(mystr, ...params);
}
return mystr;
@@ -2523,7 +2523,10 @@ class Telegram {
async menuRestartSrv(rec, msg, cmd2) {
if (cmd2 === '6711') {
- await MyTelegramBot.sendMsgTelegramToTheAdminAllSites(this.chisono(rec) + ' ha rilanciato il Server NODE.JS...');
+ const freeSpace = await tools.getFreeDiskSpace();
+ const strfree = `Spazio libero su disco: ${freeSpace}`;
+
+ await MyTelegramBot.sendMsgTelegramToTheAdminAllSites(this.chisono(rec) + ' ha rilanciato il Server NODE.JS... \n' + strfree);
let file = '~/batch/production_restart_server.sh';
if (process.env.NODE_ENV === 'test') {
file = '~/batch/test_restart_server.sh';
@@ -2543,7 +2546,10 @@ class Telegram {
async menuLogSrv(rec, msg, cmd2) {
if (cmd2 === '6711') {
- const ris = await tools.execScriptByTelegram(this.idapp, msg, '~/batch/logserver.sh', this.chisono(rec) + ' Visualizzo il Log del Server...');
+ const freeSpace = await tools.getFreeDiskSpace();
+ const strfree = `Spazio libero su disco: ${freeSpace}`;
+ console.log(strfree);
+ const ris = await tools.execScriptByTelegram(this.idapp, msg, '~/batch/logserver.sh', this.chisono(rec) + ' Visualizzo il Log del Server... \n' + strfree);
} else {
this.nonAbilitato(msg);
}
@@ -4029,7 +4035,7 @@ class Telegram {
return 0;
});*/
}
-
+
if (risSendPhoto) {
inviato = true;
}
diff --git a/src/server/tools/general.js b/src/server/tools/general.js
index 487bb2c..c98e27e 100755
--- a/src/server/tools/general.js
+++ b/src/server/tools/general.js
@@ -47,6 +47,9 @@ const sanitizeHtml = require('sanitize-html');
const { exec } = require('child_process');
+const util = require('util');
+const execPromise = util.promisify(exec);
+
const { spawn } = require('child_process');
const readline = require('readline');
@@ -5348,6 +5351,8 @@ module.exports = {
if (username_telegram) {
contatto_telegram = `@${username_telegram}`;
contatto = contatto_telegram;
+ } else {
+ contatto = myrec.email;
}
} catch (e) {
}
@@ -5937,7 +5942,20 @@ module.exports = {
console.log(JSON.stringify(result, null, 2)); // Stampa il risultato in formato JSON
}
});
- }
+ },
+
+ async getFreeDiskSpace(path = '/') {
+ try {
+ const { stdout } = await execPromise(`df -k ${path} | tail -1 | awk '{print $4}'`);
+ const freeSpaceKB = parseInt(stdout.trim());
+ const freeSpaceGB = (freeSpaceKB / 1024 / 1024).toFixed(2);
+ return `${freeSpaceGB} GB`;
+ } catch (error) {
+ console.error('Errore nel recupero dello spazio libero su disco:', error);
+ return null;
+ }
+ },
+
};
diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js
index 232be57..eda8ac0 100755
--- a/src/server/tools/shared_nodejs.js
+++ b/src/server/tools/shared_nodejs.js
@@ -979,6 +979,7 @@ module.exports = {
username: 1,
name: 1,
surname: 1,
+ email: 1,
groupname: 1,
lasttimeonline: 1,
comune: 1,
diff --git a/src/server/version.txt b/src/server/version.txt
index 95ce23d..b0c8928 100644
--- a/src/server/version.txt
+++ b/src/server/version.txt
@@ -1 +1 @@
-1.1.17
\ No newline at end of file
+1.1.18
\ No newline at end of file