Skip to content

Commit

Permalink
Filter out some permission for public albums
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Oct 25, 2023
1 parent e7243b2 commit f0aae14
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 f0aae14

Please sign in to comment.