From c9d79e467a0d2e843a129e3286b52311efa3cd00 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 17 Apr 2024 17:15:26 +0200 Subject: [PATCH] feat: Check download attribute when fetching previews Signed-off-by: Louis Chemineau --- lib/Controller/PreviewController.php | 16 ++++++++++++++++ tests/psalm-baseline.xml | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/Controller/PreviewController.php b/lib/Controller/PreviewController.php index 87b7c7769..b20831730 100644 --- a/lib/Controller/PreviewController.php +++ b/lib/Controller/PreviewController.php @@ -25,6 +25,7 @@ namespace OCA\Photos\Controller; +use OCA\Files_Sharing\SharedStorage; use OCA\Photos\Album\AlbumMapper; use OCA\Photos\AppInfo\Application; use OCP\AppFramework\Controller; @@ -90,6 +91,21 @@ public function index( } $nodes = $this->userFolder->getById($fileId); + $nodes = array_filter( + $nodes, + function ($node) { + $storage = $node->getStorage(); + if (!$storage->instanceOfStorage(SharedStorage::class)) { + return true; + } + + /** @var SharedStorage $storage */ + $share = $storage->getShare(); + $attributes = $share->getAttributes(); + + return $attributes === null || $attributes->getAttribute('permissions', 'download') !== false; + }, + ); /** @var \OCA\Photos\Album\AlbumInfo[] */ $checkedAlbums = []; diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index d8c4ea7b5..c35e81446 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -6,11 +6,20 @@ \OCA\GroupFolders\Mount\GroupFolderStorage + + + OCA\Files_Sharing\SharedStorage + + + SharedStorage + + new SearchQuery(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'systemtag', $tag->getName()), 0, 0, [], $user) + $e LoadSidebar