Skip to content

Commit

Permalink
Merge pull request #2103 from nextcloud/artonge/fix/available_action_…
Browse files Browse the repository at this point in the history
…public_album_photos

Filter out some permission for public albums
  • Loading branch information
artonge committed Oct 25, 2023
2 parents e7243b2 + f0aae14 commit 5dd5af6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/Sabre/PropFindPlugin.php
Expand Up @@ -28,6 +28,7 @@
use OCA\Photos\Album\AlbumMapper;
use OCA\Photos\Sabre\Album\AlbumPhoto;
use OCA\Photos\Sabre\Album\AlbumRoot;
use OCA\Photos\Sabre\Album\PublicAlbumPhoto;
use OCA\Photos\Sabre\Place\PlacePhoto;
use OCA\Photos\Sabre\Place\PlaceRoot;
use OCP\Files\DavUtil;
Expand Down Expand Up @@ -109,8 +110,17 @@ 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())));
$propFind->handle(FilesPlugin::PERMISSIONS_PROPERTYNAME, function () use ($node): string {
$permissions = DavUtil::getDavPermissions($node->getFileInfo());
$filteredPermissions = str_replace('R', '', $permissions);

if ($node instanceof PublicAlbumPhoto) {
$filteredPermissions = str_replace('D', '', $filteredPermissions);
$filteredPermissions = str_replace('NV', '', $filteredPermissions);
$filteredPermissions = str_replace('W', '', $filteredPermissions);
}
return $filteredPermissions;
});

if ($this->metadataEnabled) {
$propFind->handle(FilesPlugin::FILE_METADATA_SIZE, function () use ($node) {
Expand Down

0 comments on commit 5dd5af6

Please sign in to comment.