From 1d16bc47ffe7fbbf3f98a773612df6cdfa56f7de Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 2 Aug 2024 14:32:20 +0200 Subject: fix(files_sharing): Handle download permission the same way for public and internal shares Signed-off-by: Ferdinand Thiessen --- apps/files/src/actions/downloadAction.ts | 10 +++++----- apps/files_sharing/lib/Controller/ShareAPIController.php | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/files/src/actions/downloadAction.ts b/apps/files/src/actions/downloadAction.ts index f1bcb97e279..bac5e4adf10 100644 --- a/apps/files/src/actions/downloadAction.ts +++ b/apps/files/src/actions/downloadAction.ts @@ -46,11 +46,11 @@ const isDownloadable = function(node: Node) { } // If the mount type is a share, ensure it got download permissions. - if (node.attributes['mount-type'] === 'shared') { - const shareAttributes = JSON.parse(node.attributes['share-attributes'] ?? '[]') as Array - const downloadAttribute = shareAttributes?.find?.((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download') - if (downloadAttribute !== undefined && downloadAttribute.value === false) { - return false + if (node.attributes['share-attributes']) { + const shareAttributes = JSON.parse(node.attributes['share-attributes'] || '[]') as Array + const downloadAttribute = shareAttributes.find(({ scope, key }: ShareAttribute) => scope === 'permissions' && key === 'download') + if (downloadAttribute) { + return downloadAttribute.value === true } } diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index ea2bb3fa668..3f8062ac2c9 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1221,11 +1221,16 @@ class ShareAPIController extends OCSController { } // Update hide download state + $attributes = $share->getAttributes() ?? $share->newAttributes(); if ($hideDownload === 'true') { $share->setHideDownload(true); + $attributes->setAttribute('permissions', 'download', false); } elseif ($hideDownload === 'false') { $share->setHideDownload(false); + $attributes->setAttribute('permissions', 'download', true); } + $share->setAttributes($attributes); + $newPermissions = null; if ($publicUpload === 'true') { -- cgit v1.2.3