diff options
author | Louis <louis@chmn.me> | 2024-04-18 13:33:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-18 13:33:29 +0200 |
commit | e3d3f17ac01772b46615fec4892ba1327c21eba7 (patch) | |
tree | 1ee4686710377444d23e4800b6de5a87350d6861 | |
parent | eb5bcae0ede87b9eaf19e33d7f686a08437f5cd6 (diff) | |
parent | eb046a0ea87613f3006e05cab8bde706882547ae (diff) |
Merge pull request #2436 from nextcloud/backport/2434/stable26stable26
[stable26] Check download attribute when fetching previews
-rw-r--r-- | lib/Controller/PreviewController.php | 16 | ||||
-rw-r--r-- | tests/psalm-baseline.xml | 9 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/Controller/PreviewController.php b/lib/Controller/PreviewController.php index c19ea36e..6fd79d68 100644 --- a/lib/Controller/PreviewController.php +++ b/lib/Controller/PreviewController.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace OCA\Photos\Controller; +use OCA\Files_Sharing\SharedStorage; use OCA\Photos\AppInfo\Application; use OCA\Photos\Album\AlbumMapper; use OCP\AppFramework\Controller; @@ -90,6 +91,21 @@ class PreviewController extends Controller { } $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 3e9dbb51..0478a8d0 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -6,10 +6,19 @@ <code>\OCA\GroupFolders\Mount\GroupFolderStorage</code> </UndefinedClass> </file> + <file src="lib/Controller/PreviewController.php"> + <UndefinedDocblockClass occurrences="4"> + <code>OCA\Files_Sharing\SharedStorage</code> + </UndefinedDocblockClass> + <UndefinedClass occurrences="1"> + <code>SharedStorage</code> + </UndefinedClass> + </file> <file src="lib/Controller/PageController.php"> <InvalidArgument occurrences="1"> <code>new SearchQuery(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'systemtag', $tag->getName()), 0, 0, [], $user)</code> </InvalidArgument> + <UndefinedClass occurrences="12"> <code>$e</code> <code>LoadSidebar</code> |