Added command function handlers for get,set clip
Noah Zalev committed
Jan 9, 2022 at 21:22 UTC
1398ca583b6400dfd55e341a1247edefb0f87329
1 file changed
+28
-26
meshuser.js
+28
-26
@@ -3507,32 +3507,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
3507
delete obj.hardwareKeyRegistrationRequest;
3508
break;
3509
}
3510
- case 'getClip': {
3511
- if (common.validateString(command.nodeid, 1, 1024) == false) break; // Check nodeid
3512
-
3513
- // Get the node and the rights for this node
3514
- parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
3515
- if ((rights & MESHRIGHT_REMOTECONTROL) == 0) return;
3516
-
3517
- // Ask for clipboard data from agent
3518
- var agent = parent.wsagents[node._id];
3519
- if (agent != null) { try { agent.send(JSON.stringify({ action: 'getClip' })); } catch (ex) { } }
3520
- });
3521
- break;
3522
- }
3523
- case 'setClip': {
3524
- if (common.validateString(command.data, 1, 65535) == false) break; // Check
3525
-
3526
- // Get the node and the rights for this node
3527
- parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
3528
- if ((rights & MESHRIGHT_REMOTECONTROL) == 0) return;
3529
-
3530
- // Send clipboard data to the agent
3531
- var agent = parent.wsagents[node._id];
3532
- if (agent != null) { try { agent.send(JSON.stringify({ action: 'setClip', data: command.data })); } catch (ex) { } }
3533
- });
3534
- break;
3535
- }
3510
case 'userWebState': {
3511
if ((user.siteadmin != 0xFFFFFFFF) && ((user.siteadmin & 1024) != 0)) return; // If this account is settings locked, return here.
3512
if (common.validateString(command.state, 1, 30000) == false) break; // Check state size, no more than 30k
@@ -4888,6 +4862,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4862
'confirmPhone': serverCommandConfirmPhone,
4863
'emailuser': serverCommandEmailUser,
4864
'files': serverCommandFiles,
4865
+ 'getClip': serverCommandGetClip,
4866
'getcookie': serverCommandGetCookie,
4867
'getnetworkinfo': serverCommandGetNetworkInfo,
4868
'getsysinfo': serverCommandGetSysInfo,
@@ -4910,6 +4885,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4885
'servertimelinestats': serverCommandServerTimelineStats,
4886
'serverupdate': serverCommandServerUpdate,
4887
'serverversion': serverCommandServerVersion,
4888
+ 'setClip': serverCommandSetClip,
4889
'smsuser': serverCommandSmsUser,
4890
'updateUserImage': serverCommandUpdateUserImage,
4891
'urlargs': serverCommandUrlArgs,
@@ -5690,6 +5666,19 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5666
updateUserFiles(user, ws, domain);
5667
}
5668
5669
+ function serverCommandGetClip(command) {
5670
+ if (common.validateString(command.nodeid, 1, 1024) == false) return; // Check nodeid
5671
+
5672
+ // Get the node and the rights for this node
5673
+ parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
5674
+ if ((rights & MESHRIGHT_REMOTECONTROL) == 0) return;
5675
+
5676
+ // Ask for clipboard data from agent
5677
+ var agent = parent.wsagents[node._id];
5678
+ if (agent != null) { try { agent.send(JSON.stringify({ action: 'getClip' })); } catch (ex) { } }
5679
+ });
5680
+ }
5681
+
5682
function serverCommandGetCookie(command) {
5683
// Check if this user has rights on this nodeid
5684
if (common.validateString(command.nodeid, 1, 1024) == false) return; // Check nodeid
@@ -6042,6 +6031,19 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
6031
parent.parent.getServerTags(function (tags, err) { try { ws.send(JSON.stringify({ action: 'serverversion', tags: tags })); } catch (ex) { } });
6032
}
6033
6034
+ function serverCommandSetClip(command) {
6035
+ if (common.validateString(command.data, 1, 65535) == false) return; // Check
6036
+
6037
+ // Get the node and the rights for this node
6038
+ parent.GetNodeWithRights(domain, user, command.nodeid, function (node, rights, visible) {
6039
+ if ((rights & MESHRIGHT_REMOTECONTROL) == 0) return;
6040
+
6041
+ // Send clipboard data to the agent
6042
+ var agent = parent.wsagents[node._id];
6043
+ if (agent != null) { try { agent.send(JSON.stringify({ action: 'setClip', data: command.data })); } catch (ex) { } }
6044
+ });
6045
+ }
6046
+
6047
function serverCommandSmsUser(command) {
6048
var errMsg = null, smsuser = null;
6049
if (parent.parent.smsserver == null) { errMsg = "SMS gateway not enabled"; }