public: prevent 500 for unindexed share (fix #711)

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/743/head
Varun Patil 2023-06-29 08:42:56 -07:00
parent f1819d8ac6
commit c1cc0c695a
2 changed files with 17 additions and 3 deletions

View File

@ -222,9 +222,18 @@ class PublicController extends AuthPublicShareController
exit; // no other way to do this due to typing of super class
}
/** Get initial state of single item */
/**
* Get initial state of single item.
*
* @throws NotFoundException if file not found in index
*/
private function getSingleItemInitialState(\OCP\Files\File $file): array
{
return $this->timelineQuery->getSingleItem($file->getId());
$data = $this->timelineQuery->getSingleItem($file->getId());
if (null === $data) {
throw new NotFoundException();
}
return $data;
}
}

View File

@ -13,7 +13,7 @@ trait TimelineQuerySingleItem
{
protected IDBConnection $connection;
public function getSingleItem(int $fileId)
public function getSingleItem(int $fileId): ?array
{
$query = $this->connection->getQueryBuilder();
$query->select('m.fileid', ...TimelineQuery::TIMELINE_SELECT)
@ -30,6 +30,11 @@ trait TimelineQuerySingleItem
// FETCH the photo
$photo = $query->executeQuery()->fetch();
// Check if photo was found
if (false === $photo) {
return null;
}
// Post process the record
$this->processDayPhoto($photo);