aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-08-22 10:02:37 +0200
committerskjnldsv <skjnldsv@protonmail.com>2024-09-11 13:17:42 +0200
commitbb37954abb8f2d497c48dd3195644e5bb068bcec (patch)
tree5023656c82db19a99f199599aacafb678d3d519b /apps/files_sharing/lib/Controller
parentc43353d6e6d999996a0645a84f7b88b72a5e0345 (diff)
downloadnextcloud-server-bb37954abb8f2d497c48dd3195644e5bb068bcec.tar.gz
nextcloud-server-bb37954abb8f2d497c48dd3195644e5bb068bcec.zip
fix(files_sharing): adjust permissions from custom edit and delete check methods
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/lib/Controller')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index d40b3d862ee..9ca9774013c 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -158,6 +158,23 @@ class ShareAPIController extends OCSController {
if ($isOwnShare) {
$result['item_permissions'] = $node->getPermissions();
}
+
+ // If we're on the recipient side, the node permissions
+ // are bound to the share permissions. So we need to
+ // adjust the permissions to the share permissions if necessary.
+ if (!$isOwnShare) {
+ $result['item_permissions'] = $share->getPermissions();
+
+ // For some reason, single files share are forbidden to have the delete permission
+ // since we have custom methods to check those, let's adjust straight away.
+ // DAV permissions does not have that issue though.
+ if ($this->canDeleteShare($share) || $this->canDeleteShareFromSelf($share)) {
+ $result['item_permissions'] |= Constants::PERMISSION_DELETE;
+ }
+ if ($this->canEditShare($share)) {
+ $result['item_permissions'] |= Constants::PERMISSION_UPDATE;
+ }
+ }
// See MOUNT_ROOT_PROPERTYNAME dav property
$result['is-mount-root'] = $node->getInternalPath() === '';