Factorize urlargs, intersession
Noah Zalev committed
Dec 7, 2021 at 23:47 UTC
bb81de62dbf74513512130b9d6a90a8ad3045d2b
1 file changed
+18
-20
meshuser.js
+18
-20
@@ -631,26 +631,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
631
// pass through to switch statement until refactoring complete
632
633
switch (command.action) {
634
- case 'urlargs':
635
- {
636
- console.log(req.query);
637
- console.log(command.args);
638
- break;
639
- }
640
- case 'intersession':
641
- {
642
- // Sends data between sessions of the same user
643
- var sessions = parent.wssessions[obj.user._id];
644
- if (sessions == null) break;
645
-
646
- // Create the notification message and send on all sessions except our own (no echo back).
647
- var notification = JSON.stringify(command);
648
- for (var i in sessions) { if (sessions[i] != obj.ws) { try { sessions[i].send(notification); } catch (ex) { } } }
649
-
650
- // TODO: Send the message of user sessions connected to other servers.
651
-
652
- break;
653
- }
634
case 'interuser':
635
{
636
// Sends data between users only if allowed. Only a user in the "interUserMessaging": [] list, in the settings section of the config.json can receive and send inter-user messages from and to all users.
@@ -5477,6 +5457,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5457
'files': serverCommandFiles,
5458
'getnetworkinfo': serverCommandGetNetworkInfo,
5459
'getsysinfo': serverCommandGetSysInfo,
5460
+ 'intersession': serverCommandInterSession,
5461
'lastconnect': serverCommandLastConnect,
5462
'lastconnects': serverCommandLastConnects,
5463
'meshes': serverCommandMeshes,
@@ -5491,6 +5472,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5472
'serverstats': serverCommandServerStats,
5473
'serverupdate': serverCommandServerUpdate,
5474
'serverversion': serverCommandServerVersion,
5475
+ 'urlargs': serverCommandUrlArgs,
5476
'users': serverCommandUsers
5477
};
5478
@@ -5901,6 +5883,17 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5883
});
5884
}
5885
5886
+ function serverCommandInterSession(command) {
5887
+ // Sends data between sessions of the same user
5888
+ var sessions = parent.wssessions[obj.user._id];
5889
+ if (sessions == null) return;
5890
+
5891
+ // Create the notification message and send on all sessions except our own (no echo back).
5892
+ var notification = JSON.stringify(command);
5893
+ for (var i in sessions) { if (sessions[i] != obj.ws) { try { sessions[i].send(notification); } catch (ex) { } } }
5894
+ // TODO: Send the message of user sessions connected to other servers.
5895
+ }
5896
+
5897
function serverCommandLastConnect(command) {
5898
if (!validNodeIdAndDomain(command)) return;
5899
@@ -6114,6 +6107,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
6107
parent.parent.getServerTags(function (tags, err) { try { ws.send(JSON.stringify({ action: 'serverversion', tags: tags })); } catch (ex) { } });
6108
}
6109
6110
+ function serverCommandUrlArgs(command) {
6111
+ console.log(req.query);
6112
+ console.log(command.args);
6113
+ }
6114
+
6115
function serverCommandUsers(command) {
6116
// Request a list of all users
6117
if ((user.siteadmin & 2) == 0) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'users', responseid: command.responseid, result: 'Access denied' })); } catch (ex) { } } return; }