Skip to content

Commit

Permalink
Merge pull request #2105 from nextcloud/backport/2103/stable27
Browse files Browse the repository at this point in the history
[stable27] Filter out some permission for public albums
  • Loading branch information
blizzz authored Nov 15, 2023
2 parents 13e7a3b + e358bc5 commit d6962ab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/Sabre/PropFindPlugin.php
Original file line number Diff line number Diff line change
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 d6962ab

Please sign in to comment.