Skip to content

Commit

Permalink
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 dbff13d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion 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 Expand Up @@ -125,7 +141,7 @@ public function index(

$node = array_pop($nodes);

return $this->fetchPreview($node, $x, $y);
return new DataResponse([], Http::STATUS_FORBIDDEN);
}


Expand Down

0 comments on commit dbff13d

Please sign in to comment.