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>
  • Loading branch information
artonge committed Apr 17, 2024
1 parent 1b4e3b5 commit ebbf23e
Show file tree
Hide file tree
Showing 2 changed files with 22 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();

Check failure on line 103 in lib/Controller/PreviewController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedDocblockClass

lib/Controller/PreviewController.php:103:5: UndefinedDocblockClass: Docblock-defined class, interface or enum named OCA\Files_Sharing\SharedStorage does not exist (see https://psalm.dev/200)

Check failure on line 103 in lib/Controller/PreviewController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedDocblockClass

lib/Controller/PreviewController.php:103:14: UndefinedDocblockClass: Docblock-defined class, interface or enum named OCA\Files_Sharing\SharedStorage does not exist (see https://psalm.dev/200)
$attributes = $share->getAttributes();

return $attributes === null || $attributes->getAttribute('permissions', 'download') !== false;
},
);

/** @var \OCA\Photos\Album\AlbumInfo[] */
$checkedAlbums = [];
Expand Down
6 changes: 6 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<code>\OCA\GroupFolders\Mount\GroupFolderStorage</code>
</UndefinedClass>
</file>
<file src="lib/Controller/PreviewController.php">
<UndefinedClass occurrences="2">
<code>SharedStorage</code>
<code>\OCA\GroupFolders\Mount\GroupFolderStorage</code>
</UndefinedClass>
</file>
<file src="lib/Controller/PageController.php">
<InvalidArgument occurrences="1">
<code>new SearchQuery(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'systemtag',
Expand Down

0 comments on commit ebbf23e

Please sign in to comment.