diff --git a/meshagent.js b/meshagent.js index 6b09f683..8d680ce9 100644 --- a/meshagent.js +++ b/meshagent.js @@ -1670,16 +1670,16 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { break; } case 'guestShare': { - if ((domain.agentselfguestsharing !== true) || (typeof command.flags != 'number')) return; // Check if agent self-sharing is allowed, this is off by default. - if (command.flags == 0) { - // Stop any current self-share + if ((command.flags == null) || (command.flags == 0)) { + // Stop any current self-share, this is allowed even if self guest sharing is not allows so to clear any old shares. removeGuestSharing(function () { delete obj.guestSharing; obj.send(JSON.stringify({ action: 'guestShare', flags: command.flags, url: null, viewOnly: false })); }); } else { // Add a new self-share, this will replace any share for this device - if ((command.flags & 1) == 0) { command.viewOnly = false; } // Only allow "view only" if desktop is shared. + if ((domain.agentselfguestsharing !== true) || (typeof command.flags != 'number')) return; // Check if agent self-sharing is allowed, this is off by default. + if ((command.flags & 2) == 0) { command.viewOnly = false; } // Only allow "view only" if desktop is shared. addGuestSharing(command.flags, command.viewOnly, function (share) { obj.guestSharing = true; obj.send(JSON.stringify({ action: 'guestShare', url: share.url, flags: share.flags, viewOnly: share.viewOnly })); diff --git a/meshuser.js b/meshuser.js index bb6d0748..7cca3148 100644 --- a/meshuser.js +++ b/meshuser.js @@ -402,6 +402,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use else if (event == 'resubscribe') { user.subscriptions = parent.subscribe(user._id, ws); } else if (event == 'updatefiles') { updateUserFiles(user, ws, domain); } else { + // If updating guest device shares, if we are updating a user that is not creator of the share, remove the URL. + if (event.action == 'deviceShareUpdate') { + event = common.Clone(event); + for (var i in event.deviceShares) { if (event.deviceShares[i].userid != user._id) { delete event.deviceShares[i].url; } } + } + // Because of the device group "Show Self Events Only", we need to do more checks here. if (id.startsWith('mesh/')) { // Check if we have rights to get this message. If we have limited events on this mesh, don't send the event to the user. @@ -430,7 +436,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use ws.send(JSON.stringify({ action: 'event', event: event })); } } - } catch (e) { } + } catch (ex) { console.log(ex); } } }; @@ -4613,6 +4619,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } else { // This share is ok, remove extra data we don't need to send. delete doc._id; delete doc.domain; delete doc.nodeid; delete doc.type; + if (doc.userid != user._id) { delete doc.url; } // If this is not the user who created this link, don't give the link. okDocs.push(doc); } } diff --git a/views/default.handlebars b/views/default.handlebars index a83f5a88..62a27967 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -7096,19 +7096,22 @@ x += '
'; count = 1; for (var i = 0; i < deviceShares.length; i++) { - var dshare = deviceShares[i]; - var trash = ''; + var dshare = deviceShares[i], trash = ''; + if (dshare.url != null) { trash += ' '; } + trash += ''; var type = ['', "Terminal", "Desktop", "Desktop + Terminal", "Files", "Terminal + Files", "Desktop + Files", "Desktop + Terminal + Files"][dshare.p]; var details = type; if ((dshare.startTime != null) && (dshare.expireTime != null)) { details = format("{0}, {1} to {2}", type, printFlexDateTime(new Date(dshare.startTime)), printFlexDateTime(new Date(dshare.expireTime))); } - if (dshare.viewOnly === true) { details += ", View only"; } + if (((dshare.p & 2) != 0) && (dshare.viewOnly === true)) { details += ", View only desktop"; } if (dshare.consent != null) { if (dshare.consent == 0) { details += ", No Consent"; } else { if ((dshare.consent & 0x0038) != 0) { details += ", Prompt for consent"; } if ((dshare.consent & 0x0040) != 0) { details += ", Toolbar"; } } } - x += ''; + var guestName = EscapeHtml(dshare.guestName); + if (dshare.publicid.startsWith('AS:node/')) { guestName = '' + "Agent Self-Share" + ''; } + x += ''; } x += '
' + "Active Device Sharing" + '
 ' + dshare.guestName + '
' + trash + '
' + details + '
 ' + guestName + '
' + trash + '
' + details + '
'; }