Skip to content

Commit

Permalink
fix(Kobo): Remove a book from shelf should not proxy it
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusa87 committed Aug 12, 2024
1 parent cfba902 commit aeadabd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Controller/Kobo/KoboTagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ public function __construct(
* @throws GuzzleException
* Yep, a POST for a DELETE, it's how Kobo does it
*/
#[Route('/v1/library/tags/{tagId}/items/delete', methods: ['POST'])]
public function delete(Request $request, KoboDevice $kobo, string $tagId): Response
#[Route('/v1/library/tags/{shelfId}/items/delete', methods: ['POST'])]
public function delete(Request $request, KoboDevice $kobo, string $shelfId): Response
{
if ($this->koboStoreProxy->isEnabled()) {
$shelf = $this->shelfRepository->findByKoboAndUuid($kobo, $shelfId);

// Proxy query if we do not know the shelf
if ($this->koboStoreProxy->isEnabled() && !$shelf instanceof Shelf) {
return $this->koboStoreProxy->proxy($request);
}

Expand All @@ -46,12 +49,11 @@ public function delete(Request $request, KoboDevice $kobo, string $tagId): Respo
$this->logger->debug('Tag delete request', ['request' => $deleteRequest]);

try {
$shelf = $this->shelfRepository->findByKoboAndUuid($kobo, $tagId);
if (!$shelf instanceof Shelf) {
throw $this->createNotFoundException(sprintf('Shelf with uuid %s not found', $tagId));
throw $this->createNotFoundException(sprintf('Shelf with uuid %s not found', $shelfId));
}
} catch (NonUniqueResultException $e) {
throw new BadRequestException('Invalid tag id', 0, $e);
throw new BadRequestException('Invalid shelf id', 0, $e);
}

foreach ($shelf->getBooks() as $book) {
Expand Down

0 comments on commit aeadabd

Please sign in to comment.