summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis <louis@chmn.me>2024-04-18 14:13:26 +0200
committerGitHub <noreply@github.com>2024-04-18 14:13:26 +0200
commit945347be27ee8b1b0291947442117325ba7f1ecd (patch)
treeab0467b7a25bb416ba2db2f358e3443cf7ee2962
parent070a75c555d7cf23aab33140ed41292b73346bb4 (diff)
parente3b7363a2c6561c306dc4bbdd9357d59c57bc375 (diff)
Merge pull request #2435 from nextcloud/backport/2434/stable25stable25
[stable25] Check download attribute when fetching previews
-rw-r--r--.github/workflows/phpunit-sqlite.yml2
-rw-r--r--lib/Controller/PreviewController.php16
-rw-r--r--tests/psalm-baseline.xml9
3 files changed, 26 insertions, 1 deletions
diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml
index de1bcf0a..b46fa494 100644
--- a/.github/workflows/phpunit-sqlite.yml
+++ b/.github/workflows/phpunit-sqlite.yml
@@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
php-versions: ["8.0"]
- server-versions: ["master"]
+ server-versions: ["stable25"]
steps:
- name: Set app env
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>