Make Kitsu auth token error easier to recover from
This commit is contained in:
parent
545984bb18
commit
80b2495c11
@ -44,6 +44,7 @@ use Aviat\Ion\{
|
|||||||
use Generator;
|
use Generator;
|
||||||
use function Amp\Promise\wait;
|
use function Amp\Promise\wait;
|
||||||
use function Aviat\AnimeClient\getApiClient;
|
use function Aviat\AnimeClient\getApiClient;
|
||||||
|
use const Aviat\AnimeClient\SESSION_SEGMENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kitsu API Model
|
* Kitsu API Model
|
||||||
@ -707,9 +708,14 @@ final class Model {
|
|||||||
|
|
||||||
$rawData = Json::decode($json);
|
$rawData = Json::decode($json);
|
||||||
$data = $rawData['data']['findProfileBySlug']['library']['all'] ?? [];
|
$data = $rawData['data']['findProfileBySlug']['library']['all'] ?? [];
|
||||||
$page = $data['pageInfo'];
|
$page = $data['pageInfo'] ?? [];
|
||||||
if (empty($data))
|
if (empty($data))
|
||||||
{
|
{
|
||||||
|
// Clear session, in case the error is an invalid token.
|
||||||
|
$segment = $this->container->get('session')
|
||||||
|
->getSegment(SESSION_SEGMENT);
|
||||||
|
$segment->clear();
|
||||||
|
|
||||||
// @TODO Proper Error logging
|
// @TODO Proper Error logging
|
||||||
dump($rawData);
|
dump($rawData);
|
||||||
die();
|
die();
|
||||||
@ -719,7 +725,7 @@ final class Model {
|
|||||||
|
|
||||||
yield $emit($data['nodes']);
|
yield $emit($data['nodes']);
|
||||||
|
|
||||||
if ($page['hasNextPage'] === FALSE)
|
if ($page['hasNextPage'] !== TRUE)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ final class AnimeTransformer extends AbstractTransformer {
|
|||||||
'show_type' => $base['subtype'],
|
'show_type' => $base['subtype'],
|
||||||
'status' => Kitsu::getAiringStatus($base['startDate'], $base['endDate']),
|
'status' => Kitsu::getAiringStatus($base['startDate'], $base['endDate']),
|
||||||
'streaming_links' => Kitsu::parseStreamingLinks($base['streamingLinks']['nodes'] ?? []),
|
'streaming_links' => Kitsu::parseStreamingLinks($base['streamingLinks']['nodes'] ?? []),
|
||||||
'synopsis' => $base['description']['en'],
|
'synopsis' => $base['description']['en'] ?? '',
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'titles' => $titles,
|
'titles' => $titles,
|
||||||
'titles_more' => $titles_more,
|
'titles_more' => $titles_more,
|
||||||
|
Loading…
Reference in New Issue
Block a user