Skip to content

Commit

Permalink
feat: Check download attribute when fetching previews
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>

[skip ci]
  • Loading branch information
artonge authored and backportbot[bot] committed Apr 18, 2024
1 parent 3f4012b commit e386f8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/Controller/PreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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 = [];
Expand Down
9 changes: 9 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit e386f8a

Please sign in to comment.