refactor(files): use new `hide-download` WebDAV property for download action

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/52180/head
Ferdinand Thiessen 6 months ago
parent ba3c504812
commit 11594df799
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
  1. 2
      apps/files/src/actions/downloadAction.ts
  2. 7
      apps/files/src/utils/permissions.ts
  3. 4
      apps/files_sharing/src/init.ts
  4. 1
      apps/files_sharing/src/services/SharingService.ts

@ -88,7 +88,7 @@ export const action = new FileAction({
}
// We can only download dav files and folders.
if (nodes.some(node => !node.isDavRessource)) {
if (nodes.some(node => !node.isDavResource)) {
return false
}

@ -17,6 +17,13 @@ export function isDownloadable(node: Node): boolean {
return false
}
// check hide-download property of shares
if (node.attributes['hide-download'] === true
|| node.attributes['hide-download'] === 'true'
) {
return false
}
// If the mount type is a share, ensure it got download permissions.
if (node.attributes['share-attributes']) {
const shareAttributes = JSON.parse(node.attributes['share-attributes'] || '[]') as Array<ShareAttribute>

@ -2,7 +2,8 @@
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { addNewFileMenuEntry, registerDavProperty } from '@nextcloud/files'
import { addNewFileMenuEntry } from '@nextcloud/files'
import { registerDavProperty } from '@nextcloud/files/dav'
import { registerAccountFilter } from './files_filters/AccountFilter'
import { entry as newFileRequest } from './files_newMenu/newFileRequest'
@ -21,6 +22,7 @@ addNewFileMenuEntry(newFileRequest)
registerDavProperty('nc:note', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('nc:sharees', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('nc:hide-download', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('nc:share-attributes', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('oc:share-types', { oc: 'http://owncloud.org/ns' })
registerDavProperty('ocs:share-permissions', { ocs: 'http://open-collaboration-services.org/ns' })

@ -94,6 +94,7 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
attributes: {
...ocsEntry,
'has-preview': hasPreview,
'hide-download': ocsEntry?.hide_download === 1,
// Also check the sharingStatusAction.ts code
'owner-id': ocsEntry?.uid_owner,
'owner-display-name': ocsEntry?.displayname_owner,

Loading…
Cancel
Save