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 += '