Factorize myserver errorlog check
Noah Zalev committed
Aug 7, 2021 at 00:10 UTC
27a458930605ffadba513060e14628bd9d9c3478
1 file changed
+4
-3
meshuser.js
+4
-3
@@ -5643,10 +5643,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5643
}
5644
5645
function serverCommandServerErrors(command) {
5646
- // Load the server error log
5647
- if (!userHasSiteUpdate()) return;
5648
- if ((domain.myserver === false) || ((domain.myserver != null) && (domain.myserver !== true) && (domain.myserver.errorlog !== true))) return;
5646
+ // Load the server error log
5647
+ if (userHasSiteUpdate() && domainHasMyServerErrorLog()) {
5648
fs.readFile(parent.parent.getConfigFilePath('mesherrors.txt'), 'utf8', function (err, data) { try { ws.send(JSON.stringify({ action: 'servererrors', data: data })); } catch (ex) { } });
5649
+ }
5650
}
5651
5652
function serverCommandServerStats(command) {
@@ -6287,6 +6287,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
6287
}
6288
6289
function userHasSiteUpdate() { return ((user.siteadmin & SITERIGHT_SERVERUPDATE) > 0); }
6290
+ function domainHasMyServerErrorLog() { return !((domain.myserver === false) || ((domain.myserver != null) && (domain.myserver !== true) && (domain.myserver.errorlog !== true))) }
6291
6292
function csvClean(s) { return '\"' + s.split('\"').join('').split(',').join('').split('\r').join('').split('\n').join('') + '\"'; }
6293