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

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/52226/head
Ferdinand Thiessen 2025-04-14 14:47:18 +07:00
parent 40fae9ffbd
commit 4314e3f5f7
1 changed files with 15 additions and 2 deletions

@ -14,6 +14,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;
@ -63,6 +64,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-';
@ -390,6 +392,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', '');
});
@ -677,8 +692,6 @@ class FilesPlugin extends ServerPlugin {
return IMetadataValueWrapper::EDIT_REQ_READ_PERMISSION;
}
/**
* @param string $filePath
* @param ?\Sabre\DAV\INode $node