feat(files_sharing): add WebDAV property for the `hide-download` state of shares

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/52180/head
Ferdinand Thiessen 2025-04-14 14:47:18 +07:00
parent 85d2ee5262
commit ba3c504812
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
1 changed files with 15 additions and 2 deletions

@ -15,6 +15,7 @@ use OCP\Constants;
use OCP\Files\ForbiddenException;
use OCP\Files\IFilenameValidator;
use OCP\Files\InvalidPathException;
use OCP\Files\Storage\ISharedStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\FilesMetadata\Exceptions\FilesMetadataException;
use OCP\FilesMetadata\Exceptions\FilesMetadataNotFoundException;
@ -64,6 +65,7 @@ class FilesPlugin extends ServerPlugin {
public const UPLOAD_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}upload_time';
public const CREATION_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}creation_time';
public const SHARE_NOTE = '{http://nextcloud.org/ns}note';
public const SHARE_HIDE_DOWNLOAD_PROPERTYNAME = '{http://nextcloud.org/ns}hide-download';
public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-folder-count';
public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count';
public const FILE_METADATA_PREFIX = '{http://nextcloud.org/ns}metadata-';
@ -391,6 +393,19 @@ class FilesPlugin extends ServerPlugin {
);
});
$propFind->handle(self::SHARE_HIDE_DOWNLOAD_PROPERTYNAME, function () use ($node) {
$storage = $node->getNode()->getStorage();
if ($storage->instanceOfStorage(ISharedStorage::class)) {
/** @var ISharedStorage $storage */
return match($storage->getShare()->getHideDownload()) {
true => 'true',
false => 'false',
};
} else {
return null;
}
});
$propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function () {
return $this->config->getSystemValue('data-fingerprint', '');
});
@ -678,8 +693,6 @@ class FilesPlugin extends ServerPlugin {
return IMetadataValueWrapper::EDIT_REQ_READ_PERMISSION;
}
/**
* @param string $filePath
* @param ?\Sabre\DAV\INode $node