diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-02 14:30:52 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-12 11:28:03 +0200 |
commit | cb1b366baf75da4c578bc534884eefa7f6b4b3d2 (patch) | |
tree | bdb367d502a6990c39165960a76d3268270162ef /apps/dav/lib/Connector | |
parent | 1a7acf061e26d938e2162f791afb262dc7c2b90d (diff) | |
download | nextcloud-server-cb1b366baf75da4c578bc534884eefa7f6b4b3d2.tar.gz nextcloud-server-cb1b366baf75da4c578bc534884eefa7f6b4b3d2.zip |
fix(dav): Ensure share properties are also set on public remote endpoint
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/FilesPlugin.php | 7 | ||||
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Node.php | 34 |
2 files changed, 17 insertions, 24 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 3b96f67a82b..13244004993 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -345,13 +345,10 @@ class FilesPlugin extends ServerPlugin { return $node->getNode()->getInternalPath() === '' ? 'true' : 'false'; }); - $propFind->handle(self::SHARE_NOTE, function () use ($node, $httpRequest): ?string { + $propFind->handle(self::SHARE_NOTE, function () use ($node, $httpRequest): string { $user = $this->userSession->getUser(); - if ($user === null) { - return null; - } return $node->getNoteFromShare( - $user->getUID() + $user?->getUID() ); }); diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 379574b30d6..075ea2dd65b 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -15,6 +15,7 @@ use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCP\Files\DavUtil; use OCP\Files\FileInfo; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\Files\StorageNotAvailableException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; @@ -298,15 +299,14 @@ abstract class Node implements \Sabre\DAV\INode { * @return array */ public function getShareAttributes(): array { - $attributes = []; - try { - $storage = $this->info->getStorage(); - } catch (StorageNotAvailableException $e) { - $storage = null; + $storage = $this->node->getStorage(); + } catch (NotFoundException $e) { + return []; } - if ($storage && $storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { + $attributes = []; + if (method_exists($storage, 'getShare')) { /** @var \OCA\Files_Sharing\SharedStorage $storage */ $attributes = $storage->getShare()->getAttributes(); if ($attributes === null) { @@ -319,29 +319,25 @@ abstract class Node implements \Sabre\DAV\INode { return $attributes; } - /** - * @param string $user - * @return string - */ - public function getNoteFromShare($user) { - if ($user === null) { + public function getNoteFromShare(?string $user): string { + try { + $storage = $this->node->getStorage(); + } catch (NotFoundException) { return ''; } - // Retrieve note from the share object already loaded into - // memory, to avoid additional database queries. - $storage = $this->getNode()->getStorage(); - if (!$storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { + if (!method_exists($storage, 'getShare')) { return ''; } /** @var \OCA\Files_Sharing\SharedStorage $storage */ $share = $storage->getShare(); $note = $share->getNote(); - if ($share->getShareOwner() !== $user) { - return $note; + if ($user === $share->getShareOwner()) { + // Note is only for recipient not the owner + return ''; } - return ''; + return $note; } /** |