diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-04-18 12:38:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-18 12:38:13 +0200 |
commit | cad83bb22ce9c40fbd9ebcdfc7d697a1dae41e51 (patch) | |
tree | 48ca7c3c2fa5bec01235b469cc5a304521140f3c | |
parent | ae4ffe8c646ed5fa25d221a8ff92946604dd787f (diff) | |
parent | c9d79e467a0d2e843a129e3286b52311efa3cd00 (diff) |
Merge pull request #2439 from nextcloud/backport/2434/stable29v29.0.0rc5
[stable29] 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 87b7c776..b2083173 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\Album\AlbumMapper; use OCA\Photos\AppInfo\Application; 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 d8c4ea7b..c35e8144 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -6,11 +6,20 @@ <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> |