From 5cba01057ef6b28af1cb03aac2a55742c50fe98b Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 15 Mar 2023 15:27:14 +0100 Subject: [PATCH] Expose DAV permissions on album and places photos Signed-off-by: Louis Chemineau --- lib/Sabre/Album/PropFindPlugin.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Sabre/Album/PropFindPlugin.php b/lib/Sabre/Album/PropFindPlugin.php index 9f3572cef..034d19ba1 100644 --- a/lib/Sabre/Album/PropFindPlugin.php +++ b/lib/Sabre/Album/PropFindPlugin.php @@ -26,6 +26,7 @@ use OC\Metadata\IMetadataManager; use OCA\DAV\Connector\Sabre\FilesPlugin; use OCA\Photos\Album\AlbumMapper; +use OCP\Files\DavUtil; use OCP\IConfig; use OCP\IPreview; use OCP\Files\NotFoundException; @@ -45,6 +46,7 @@ class PropFindPlugin extends ServerPlugin { public const LAST_PHOTO_PROPERTYNAME = '{http://nextcloud.org/ns}last-photo'; public const NBITEMS_PROPERTYNAME = '{http://nextcloud.org/ns}nbItems'; public const COLLABORATORS_PROPERTYNAME = '{http://nextcloud.org/ns}collaborators'; + public const PERMISSIONS_PROPERTYNAME = '{http://owncloud.org/ns}permissions'; public const TAG_FAVORITE = '_$!!$_'; @@ -105,6 +107,8 @@ public function propFind(PropFind $propFind, INode $node): void { $propFind->handle(self::FILE_NAME_PROPERTYNAME, fn () => $node->getFile()->getName()); $propFind->handle(self::FAVORITE_PROPERTYNAME, fn () => $node->isFavorite() ? 1 : 0); $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, fn () => json_encode($this->previewManager->isAvailable($fileInfo))); + // Remove G permission as it does not make sense in the context of photos. + $propFind->handle(FilesPlugin::PERMISSIONS_PROPERTYNAME, fn () => str_replace('G', '', DavUtil::getDavPermissions($node->getFileInfo()))); if ($this->metadataEnabled) { $propFind->handle(FilesPlugin::FILE_METADATA_SIZE, function () use ($node) {