Skip to content

Commit

Permalink
fix(Kobo): Get State returns an empty response all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusa87 committed Aug 12, 2024
1 parent 7d45a1f commit eadb42b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 14 additions & 2 deletions src/Controller/Kobo/KoboStateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

Expand Down Expand Up @@ -88,10 +87,23 @@ public function state(KoboDevice $kobo, string $uuid, Request $request): Respons
#[Route('/v1/library/{uuid}/state', name: 'api_endpoint_v1_getstate', requirements: ['uuid' => '^[a-zA-Z0-9\-]+$'], methods: ['GET'])]
public function getState(KoboDevice $kobo, string $uuid, Request $request): Response|JsonResponse
{
// Get State returns an empty response
$response = new JsonResponse([]);
$response->headers->set('x-kobo-api-token', 'e30=');

$book = $this->bookRepository->findByUuidAndKoboDevice($uuid, $kobo);

// Empty response if we know the book
if ($book instanceof Book) {
return $response;
}

// If we do not know the book, we forward the query to the proxy
if ($this->koboStoreProxy->isEnabled()) {
return $this->koboStoreProxy->proxyOrRedirect($request);
}
throw new HttpException(200, 'Not implemented');

return $response->setStatusCode(Response::HTTP_NOT_IMPLEMENTED);
}

private function handleBookmark(KoboDevice $kobo, Book $book, ?Bookmark $currentBookmark): void
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Kobo/KoboTagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public function delete(Request $request, KoboDevice $kobo, string $shelfId): Res
}
$this->shelfRepository->flush();

// TODO Find the response format for this
return new JsonResponse([], Response::HTTP_NOT_IMPLEMENTED);
return new JsonResponse($shelfId, Response::HTTP_CREATED);
}

#[Route('/v1/library/tags')]
Expand Down

0 comments on commit eadb42b

Please sign in to comment.