summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-04-18 12:40:18 +0200
committerGitHub <noreply@github.com>2024-04-18 12:40:18 +0200
commit9dedd0ab3386bb52e88bd91b61944d9747b1673f (patch)
treef3ec2a9083892d0736c1e6a8fb9a464de3b5b2e6
parent3f4012b5011b2b95b19f0d452b1648b9fe51f23c (diff)
parentf5fecc94e3bf04d337f650e8eb100af3f2ca366d (diff)
Merge pull request #2437 from nextcloud/backport/2434/stable27v27.1.9rc1
[stable27] Check download attribute when fetching previews
-rw-r--r--lib/Controller/PreviewController.php16
-rw-r--r--tests/psalm-baseline.xml9
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-&gt;getName()), 0, 0, [], $user)</code>
</InvalidArgument>
+
<UndefinedClass occurrences="12">
<code>$e</code>
<code>LoadSidebar</code>