fix(files_sharing): Handle download permission the same way for public and internal shares

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2024-08-02 14:32:20 +02:00
parent e93ceea804
commit 1d16bc47ff
No known key found for this signature in database
GPG key ID: 45FAE7268762B400
3 changed files with 11 additions and 6 deletions

View file

@ -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<ShareAttribute>
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<ShareAttribute>
const downloadAttribute = shareAttributes.find(({ scope, key }: ShareAttribute) => scope === 'permissions' && key === 'download')
if (downloadAttribute) {
return downloadAttribute.value === true
}
}

View file

@ -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') {

View file

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
Feature: dav-v2-public
Background: