- Gruppi si chiamano ora "Organizzazioni".

- Categorie dei Gruppi aggiornate.
- Email ora compare sul profilo se non hai telegram e anche sugli annunci.
This commit is contained in:
Surya Paolo
2025-01-28 23:32:32 +01:00
parent b56e25d1fa
commit 341b4b8ec7
11 changed files with 195 additions and 114 deletions

View File

@@ -127,5 +127,6 @@
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.", "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
"🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !", "🚫 %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 !", "✅ Hai Ammesso l'accesso alla App a %s !": "✅ Hai Ammesso l'accesso alla App a %s !",
"Good: %": "Good: %" "Good: %": "Good: %",
"Service: %": "Service: %"
} }

View File

@@ -34,9 +34,9 @@ const MyGroupSchema = new Schema({
descr: { descr: {
type: String, type: String,
}, },
idCatGrp: { idCatGrp: [{
type: Number, type: Number,
}, }],
userId: { userId: {
type: String, type: String,
}, },
@@ -348,6 +348,17 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname
}, },
}, },
{ $project: whatToShow }, { $project: whatToShow },
{
$lookup: {
from: 'catgrps',
localField: 'idCatGrp',
foreignField: '_id',
as: 'recCatGrp',
},
},
{
$project: shared_consts.getProjectByTable(shared_consts.TABLES_MYGROUPS, {}),
},
]; ];

View File

@@ -2,79 +2,105 @@ module.exports = {
list: [ list: [
{ {
_id: 1, _id: 1,
descr: 'Abitare', descr: 'Ospitalità ed accoglienza',
}, color: '#00BCD4',
{ icon: 'fa fa-bed'
_id: 2,
descr: 'Arte',
}, },
{ {
_id: 3, _id: 3,
descr: 'Alimentazione', descr: 'Prodotti Alimentari',
color: '#4CAF50',
icon: 'fa fa-apple-alt'
}, },
{ {
_id: 4, _id: 4,
descr: 'Artigianato', descr: 'Prodotti Artigianali e Artistici',
color: '#9C27B0',
icon: 'fa fa-paint-brush'
}, },
{ {
_id: 5, _id: 5,
descr: 'Assistenza Legale', descr: 'Servizi di Assistenza e Integrazione',
}, color: '#2196F3',
{ icon: 'fa fa-hands-helping'
_id: 6,
descr: 'Benessere',
},
{
_id: 7,
descr: 'Gruppi Locali',
}, },
{ {
_id: 8, _id: 8,
descr: 'Istruzione', descr: 'Servizi Formativi ed Educativi',
}, color: '#FFC107',
{ icon: 'fa fa-book'
_id: 2,
descr: 'Arte',
},
{
_id: 9,
descr: 'Mobilità',
},
{
_id: 10,
descr: 'Sport',
},
{
_id: 11,
descr: 'Servizi',
}, },
{ {
_id: 12, _id: 12,
descr: 'Tecnologia', descr: 'Tecnologia',
}, color: '#607D8B',
{ icon: 'fa fa-laptop'
_id: 13,
descr: 'Turismo',
}, },
{ {
_id: 14, _id: 14,
descr: 'Ecovillaggi / Comunità', descr: 'Comunità ed Ecovillaggi',
}, color: '#8BC34A',
{ icon: 'fa fa-users'
_id: 15,
descr: 'Feste',
},
{
_id: 16,
descr: 'Altro',
},
{
_id: 17,
descr: 'AutoProduzione',
}, },
{ {
_id: 18, _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'
}, },
], ],
}; };

View File

@@ -17,11 +17,11 @@ module.exports = {
const mydbfile = require(pathfile); const mydbfile = require(pathfile);
if (mydbfile && mydbfile.list) { if (mydbfile && mydbfile.list) {
return table.insertMany(mydbfile.list, {ordered: false}). return table.insertMany(mydbfile.list, { ordered: false }).
then((ris) => { then((ris) => {
console.log('Populate table ', tablename); console.log('Populate table ', tablename);
return !!ris; return !!ris;
}); });
} }
} }
} catch (e) { } catch (e) {
@@ -31,52 +31,62 @@ module.exports = {
}, },
async insertIntoDb_NoDuplicate(attiva, tablename, table, field) { async insertIntoDb_NoDuplicate(attiva, tablename, table, field) {
let numrec = 0; let numrec = 0;
let numupdated = 0;
try { try {
if (!attiva && await table.countDocuments({}) > 0) return;
if (!attiva && await table.countDocuments({}) > 0)
return;
const pathfile = Path.join(__dirname, tablename + '.js'); const pathfile = Path.join(__dirname, tablename + '.js');
if (tools.isFileExists(pathfile)) { if (tools.isFileExists(pathfile)) {
const mydbfile = require(pathfile); const mydbfile = require(pathfile);
if (mydbfile && mydbfile.list) { if (mydbfile && mydbfile.list) {
for (const rec of mydbfile.list) { for (const rec of mydbfile.list) {
let obj = {}; let query = {};
obj[field] = rec[field]; query[field] = rec[field];
var mynewrec = new table(rec); if (rec.hasOwnProperty('_id')) {
query._id = rec._id;
if (rec.hasOwnProperty('idapp')) {
obj.idapop = rec['idapp'];
} }
const exist = await table.find(obj); if (rec.hasOwnProperty('idapp')) {
if (exist.length <= 0) { query.idapp = rec.idapp;
try { }
const ris = await mynewrec.save();
if (ris) { 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++; 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) if (numrec > 0 || numupdated > 0) {
console.log('*** Insert', numrec, 'record on ' + tablename); console.log(`*** Inserted ${numrec} and updated ${numupdated} records in ${tablename}`);
}
} }
} }
} catch (e) { } catch (e) {
console.log('error insertIntoDb', e); console.log('Error in insertIntoDb_NoDuplicate:', e);
} }
}, },
async rewriteTable(table) { async rewriteTable(table) {
@@ -85,15 +95,15 @@ module.exports = {
let field = ''; let field = '';
try { try {
const {City} = require('../models/city'); const { City } = require('../models/city');
const {Province} = require('../models/province'); const { Province } = require('../models/province');
const {Sector} = require('../models/sector'); const { Sector } = require('../models/sector');
const {SectorGood} = require('../models/sectorgood'); const { SectorGood } = require('../models/sectorgood');
const {Skill} = require('../models/skill'); const { Skill } = require('../models/skill');
const {Good} = require('../models/good'); const { Good } = require('../models/good');
// const {SubSkill} = require('../models/subskill'); // const {SubSkill} = require('../models/subskill');
const {Contribtype} = require('../models/contribtype'); const { Contribtype } = require('../models/contribtype');
const {Level} = require('../models/level'); const { Level } = require('../models/level');
if (table === 'cities') { if (table === 'cities') {
mytab = City; mytab = City;
@@ -127,11 +137,11 @@ module.exports = {
if (mytab) { if (mytab) {
await mytab.collection.drop(); await mytab.collection.drop();
// mongoose.connection.db.dropCollection(table, function(err) { // mongoose.connection.db.dropCollection(table, function(err) {
console.log('Delete ', table); console.log('Delete ', table);
// await mytab.remove({}); // await mytab.remove({});
this.insertIntoDb_NoDuplicate(false, table, mytab, field); this.insertIntoDb_NoDuplicate(false, table, mytab, field);
// }); // });
} }
return true; return true;
} catch (e) { } catch (e) {

View File

@@ -19,7 +19,8 @@ module.exports = {
{_id: 17, descr: 'Attrezzature', icon: 'fas fa-tools', color: 'blue-7'}, {_id: 17, descr: 'Attrezzature', icon: 'fas fa-tools', color: 'blue-7'},
{_id: 18, descr: 'Animali', icon: 'fas fa-paw', color: 'green-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: 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'},
], ],
}; };

View File

@@ -28,6 +28,11 @@ async function getCircuitRecAdminsInfo(idapp, data) {
if (myuser && myuser.profile) if (myuser && myuser.profile)
admin.profile = { img: myuser.profile.img }; admin.profile = { img: myuser.profile.img };
} }
if (data.admins.length === 0) {
data.admins.push({username: shared_consts.USER_ADMIN_CIRCUITS})
}
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View File

@@ -44,7 +44,8 @@ router.post('/load', authenticate, async (req, res) => {
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif); SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
const whatshow = MyGroup.getWhatToShow(idapp, req.user.username); 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) { if (data.mycircuits) {
@@ -54,7 +55,8 @@ router.post('/load', authenticate, async (req, res) => {
} }
} }
*/ */
if (data.mycircuits) { if (data.mycircuits) {
for (let i = 0; i < data.mycircuits.length; i++) { for (let i = 0; i < data.mycircuits.length; i++) {
const mycirc = await Circuit.findOne({ idapp, name: data.mycircuits[i].circuitname }).lean(); const mycirc = await Circuit.findOne({ idapp, name: data.mycircuits[i].circuitname }).lean();

View File

@@ -503,7 +503,7 @@ const txt = {
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.', MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Si è appena Registrato "%s" (n. %s)\nInvitato da %s', ' 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_ACCEPT_NEWENTRY_INGROUP: '❇️👥 🧍‍♂️ Accetta Ingresso nel GRUPPO %s:',
MSG_FRIENDS_NOT_ACCEPTED_CONFIRMED: '🚫 Hai rifiutato la richiesta di Amicizia di %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 !', 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_EXIT_TELEGRAM: 'La cuenta ha sido desconectada de Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Acaba de registrarse "%s (n. %s)"\n(Invitado de %s)', ' 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_ACCEPT_NEWENTRY_INGROUP: '❇️👥 🧍‍♂️ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!', MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei 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_EXIT_TELEGRAM: 'L\'account a été déconnecté de Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Vous venez à peine de vous inscrire "%s (n. %s) %s', ' 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_ACCEPT_NEWENTRY_INGROUP: '❇️👥 🧍‍♂️ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!', MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei 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_EXIT_TELEGRAM: 'Račun se nahaja v programu Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
'Registracija registracije %s (n. %s)\n(povabil ga %s)', '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_ACCEPT_NEWENTRY_INGROUP: '❇️👥 🧍‍♂️ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!', MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei 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_EXIT_TELEGRAM: 'The account has now been disconnected from this Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' He/She\'s just registered "%s (n. %s)"\n(Invited from %s)', ' 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_ACCEPT_NEWENTRY_INGROUP: '❇️👥 🧍‍♂️ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!', MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei 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_EXIT_TELEGRAM: 'A conta foi agora desconectada deste Telegrama BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Acabou de se registar "%s (n. %s)"\n(Convidado por %s)', ' 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_ACCEPT_NEWENTRY_INGROUP: '❇️👥 🧍‍♂️ Accetta Ingresso nel GRUPPO %s:',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!', MSG_APORTADOR_CONFIRMED: '✅ %s è stato Ammesso correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei 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); await setVerifiedReg(myuser.idapp, myuser.lang, myuser.username, userDest);
} else { } 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) + '<br>' + struserinfomsg; domanda = getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM', myuser.username, nomeapp) + '<br>' + struserinfomsg;
keyb = cl.getInlineKeyboard(myuser.lang, [ 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 = ''; let mystr = '';
@@ -1578,8 +1578,8 @@ function getstr(lang, key, param1) {
if (!mystr || mystr === '') if (!mystr || mystr === '')
mystr = txt[key]; mystr = txt[key];
if (!!param1) { if (params.length > 0) {
mystr = printf(mystr, param1); mystr = printf(mystr, ...params);
} }
return mystr; return mystr;
@@ -2523,7 +2523,10 @@ class Telegram {
async menuRestartSrv(rec, msg, cmd2) { async menuRestartSrv(rec, msg, cmd2) {
if (cmd2 === '6711') { 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'; let file = '~/batch/production_restart_server.sh';
if (process.env.NODE_ENV === 'test') { if (process.env.NODE_ENV === 'test') {
file = '~/batch/test_restart_server.sh'; file = '~/batch/test_restart_server.sh';
@@ -2543,7 +2546,10 @@ class Telegram {
async menuLogSrv(rec, msg, cmd2) { async menuLogSrv(rec, msg, cmd2) {
if (cmd2 === '6711') { 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 { } else {
this.nonAbilitato(msg); this.nonAbilitato(msg);
} }
@@ -4029,7 +4035,7 @@ class Telegram {
return 0; return 0;
});*/ });*/
} }
if (risSendPhoto) { if (risSendPhoto) {
inviato = true; inviato = true;
} }

View File

@@ -47,6 +47,9 @@ const sanitizeHtml = require('sanitize-html');
const { exec } = require('child_process'); const { exec } = require('child_process');
const util = require('util');
const execPromise = util.promisify(exec);
const { spawn } = require('child_process'); const { spawn } = require('child_process');
const readline = require('readline'); const readline = require('readline');
@@ -5348,6 +5351,8 @@ module.exports = {
if (username_telegram) { if (username_telegram) {
contatto_telegram = `@${username_telegram}`; contatto_telegram = `@${username_telegram}`;
contatto = contatto_telegram; contatto = contatto_telegram;
} else {
contatto = myrec.email;
} }
} catch (e) { } catch (e) {
} }
@@ -5937,7 +5942,20 @@ module.exports = {
console.log(JSON.stringify(result, null, 2)); // Stampa il risultato in formato JSON 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;
}
},
}; };

View File

@@ -979,6 +979,7 @@ module.exports = {
username: 1, username: 1,
name: 1, name: 1,
surname: 1, surname: 1,
email: 1,
groupname: 1, groupname: 1,
lasttimeonline: 1, lasttimeonline: 1,
comune: 1, comune: 1,

View File

@@ -1 +1 @@
1.1.17 1.1.18