fixes for body parsing.
This commit is contained in:
@@ -61,7 +61,7 @@ class EmbyServer extends JellyfinServer
|
||||
return $request;
|
||||
}
|
||||
|
||||
$payload = ag($request->getParsedBody(), 'data', null);
|
||||
$payload = ag($request->getParsedBody() ?? [], 'data', null);
|
||||
|
||||
if (null === $payload || null === ($json = json_decode((string)$payload, true))) {
|
||||
return $request;
|
||||
|
||||
@@ -16,7 +16,6 @@ use Closure;
|
||||
use DateTimeInterface;
|
||||
use JsonException;
|
||||
use JsonMachine\Items;
|
||||
use Nyholm\Psr7\Stream;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -123,13 +122,12 @@ class JellyfinServer implements ServerInterface
|
||||
|
||||
$body = $request->getBody()->getContents();
|
||||
|
||||
// -- re-attach body to request.
|
||||
$request = $request->withBody(Stream::create($body));
|
||||
|
||||
if (null === ($json = json_decode($body, true))) {
|
||||
return $request;
|
||||
}
|
||||
|
||||
$request = $request->withParsedBody($json);
|
||||
|
||||
$attributes = [
|
||||
'SERVER_ID' => ag($json, 'ServerId', ''),
|
||||
'SERVER_NAME' => ag($json, 'ServerName', ''),
|
||||
@@ -147,7 +145,7 @@ class JellyfinServer implements ServerInterface
|
||||
|
||||
public function parseWebhook(ServerRequestInterface $request): StateInterface
|
||||
{
|
||||
if (null === ($json = json_decode($request->getBody()->getContents(), true))) {
|
||||
if (null === ($json = $request->getParsedBody())) {
|
||||
throw new HttpException(sprintf('%s: No payload.', afterLast(__CLASS__, '\\')), 400);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ class PlexServer implements ServerInterface
|
||||
return $request;
|
||||
}
|
||||
|
||||
$payload = ag($request->getParsedBody(), 'payload', null);
|
||||
$payload = ag($request->getParsedBody() ?? [], 'payload', null);
|
||||
|
||||
if (null === $payload || null === ($json = json_decode((string)$payload, true))) {
|
||||
return $request;
|
||||
|
||||
Reference in New Issue
Block a user