Skip to content

Commit

Permalink
Merge pull request #2434 from nextcloud/artonge/feat/check_download_a…
Browse files Browse the repository at this point in the history
…ttribute_when_sharing

Check download attribute when fetching previews
  • Loading branch information
nickvergessen authored Apr 18, 2024
2 parents 1b4e3b5 + a6c2e30 commit 1de86bf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/Controller/PreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace OCA\Photos\Controller;

use OCA\Files_Sharing\SharedStorage;
use OCA\Photos\Album\AlbumMapper;
use OCA\Photos\AppInfo\Application;
use OCP\AppFramework\Controller;
Expand Down Expand Up @@ -90,6 +91,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,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-&gt;getName()), 0, 0, [], $user)</code>
</InvalidArgument>

<UndefinedClass occurrences="12">
<code>$e</code>
<code>LoadSidebar</code>
Expand Down

0 comments on commit 1de86bf

Please sign in to comment.