Can now set expire time for Assistant guest self-sharing. #3347
Ylian Saint-Hilaire committed
Dec 13, 2021 at 17:04 UTC
938ca3574e60bd9782c4c3b7536d3df18eb7a4b5
1 file changed
+9
-2
meshagent.js
+9
-2
@@ -1090,7 +1090,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1090
if (typeof domain.terminal.launchcommand.freebsd == 'string') { serverInfo.termlaunchcommand.freebsd = domain.terminal.launchcommand.freebsd; }
1091
}
1092
// Enable agent self guest sharing if allowed
1093
- if (domain.agentselfguestsharing === true) { serverInfo.agentSelfGuestSharing = true; }
1093
+ if (domain.agentselfguestsharing) { serverInfo.agentSelfGuestSharing = true; }
1094
obj.send(JSON.stringify(serverInfo));
1095
1096
// Plug in handler
@@ -1686,7 +1686,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1686
});
1687
} else {
1688
// Add a new self-share, this will replace any share for this device
1689
- if ((domain.agentselfguestsharing !== true) || (typeof command.flags != 'number')) return; // Check if agent self-sharing is allowed, this is off by default.
1689
+ if ((domain.agentselfguestsharing == null) || (domain.agentselfguestsharing == false) || (typeof command.flags != 'number')) return; // Check if agent self-sharing is allowed, this is off by default.
1690
if ((command.flags & 2) == 0) { command.viewOnly = false; } // Only allow "view only" if desktop is shared.
1691
addGuestSharing(command.flags, command.viewOnly, function (share) {
1692
obj.guestSharing = true;
@@ -1730,6 +1730,13 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1730
1731
// Create a device sharing database entry
1732
var shareEntry = { _id: 'deviceshare-' + publicid, type: 'deviceshare', nodeid: obj.dbNodeKey, p: flags, domain: domain.id, publicid: publicid, guestName: 'Agent', consent: 0x7F, url: url, extrakey: extrakey };
1733
+
1734
+ // Add expire time
1735
+ if ((typeof domain.agentselfguestsharing == 'object') && (typeof domain.agentselfguestsharing.expire == 'number') && (domain.agentselfguestsharing.expire > 0)) {
1736
+ shareEntry.startTime = Date.now();
1737
+ shareEntry.expireTime = Date.now() + (60000 * domain.agentselfguestsharing.expire);
1738
+ }
1739
+
1740
if (viewOnly === true) { shareEntry.viewOnly = true; }
1741
parent.db.Set(shareEntry);
1742