Fixed report msgid filter
Noah Zalev committed
Dec 7, 2021 at 17:59 UTC
5aa8e2660778ed9021c90bd65a14fd8f3d165f20
1 file changed
+6
-4
meshuser.js
+6
-4
@@ -5663,6 +5663,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5663
const manageAllDeviceGroups = ((user.siteadmin == 0xFFFFFFFF) && (parent.parent.config.settings.managealldevicegroups.indexOf(user._id) >= 0));
5664
if ((command.devGroup != null) && (manageAllDeviceGroups == false) && ((user.links == null) || (user.links[command.devGroup] == null))) break; // Asking for a device group that is not allowed
5665
5666
+ const msgIdFilter = [5, 10, 11, 12, 122, 123, 124, 125, 126];
5667
+
5668
if (command.type == 1) { // This is the remote session report. Shows desktop, terminal, files...
5669
// If we are not user administrator on this site, only search for events with our own user id.
5670
var ids = [user._id];
@@ -5676,7 +5678,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5678
5679
// Get the events in the time range
5680
// MySQL or MariaDB query will ignore the MsgID filter.
5679
- db.GetEventsTimeRange(ids, domain.id, [5, 10, 11, 12, 122, 123, 124, 125, 126], new Date(command.start * 1000), new Date(command.end * 1000), function (err, docs) {
5681
+ db.GetEventsTimeRange(ids, domain.id, msgIdFilter, new Date(command.start * 1000), new Date(command.end * 1000), function (err, docs) {
5682
if (err != null) return;
5683
var data = { groups: {} };
5684
var guestNamePresent = false;
@@ -5701,7 +5703,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5703
// Rows
5704
for (var i in docs) {
5705
// If MySQL or MariaDB query, we can't filter on MsgID, so we have to do it here.
5704
- if ((docs[i].msgid != 5) && (docs[i].msgid != 10) && (docs[i].msgid != 11) && (docs[i].msgid != 12) && ((docs[i].msgid < 122) && (docs[i].msgid > 126))) continue;
5706
+ if (msgIdFilter.indexOf(docs[i].msgid) < 0) continue;
5707
if ((command.devGroup != null) && (docs[i].ids != null) && (docs[i].ids.indexOf(command.devGroup) == -1)) continue;
5708
5709
var entry = { time: docs[i].time.valueOf() };
@@ -5769,7 +5771,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5771
5772
// Get the events in the time range
5773
// MySQL or MariaDB query will ignore the MsgID filter.
5772
- db.GetEventsTimeRange(ids, domain.id, [5, 10, 11, 12, 122, 123, 124, 125, 126], new Date(command.start * 1000), new Date(command.end * 1000), function (err, docs) {
5774
+ db.GetEventsTimeRange(ids, domain.id, msgIdFilter, new Date(command.start * 1000), new Date(command.end * 1000), function (err, docs) {
5775
if (err != null) return;
5776
var data = { groups: { 0: { entries: [] } } };
5777
data.columns = [{ id: 'userid', title: "user", format: 'user' }, { id: 'length', title: "length", format: 'seconds', align: 'center', sumBy: true }, { id: 'bytesin', title: "bytesin", format: 'bytes', align: 'center', sumBy: true }, { id: 'bytesout', title: "bytesout", format: 'bytes', align: 'center', sumBy: true }];
@@ -5778,7 +5780,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5780
// Sum all entry logs for each user
5781
for (var i in docs) {
5782
// If MySQL or MariaDB query, we can't filter on MsgID, so we have to do it here.
5781
- if ((docs[i].msgid != 5) && (docs[i].msgid != 10) && (docs[i].msgid != 11) && (docs[i].msgid != 12) && ((docs[i].msgid < 122) && (docs[i].msgid > 126))) continue;
5783
+ if (msgIdFilter.indexOf(docs[i].msgid) < 0) continue;
5784
if ((command.devGroup != null) && (docs[i].ids != null) && (docs[i].ids.indexOf(command.devGroup) == -1)) continue;
5785
5786
// Fetch or create the user entry