Fixed breaking change in emby 4.9 preventing the parsing of webhook events originating from there.
This commit is contained in:
@@ -36,16 +36,12 @@ class InspectRequest
|
||||
return $this->tryResponse(
|
||||
context: $context,
|
||||
fn: function () use ($request) {
|
||||
$userAgent = ag($request->getServerParams(), 'HTTP_USER_AGENT', '');
|
||||
|
||||
if (false === str_starts_with($userAgent, 'Emby Server/')) {
|
||||
return new Response(status: false);
|
||||
if (null === ($payload = ag($request->getParsedBody() ?? [], 'data', null))) {
|
||||
return new Response(status: false, response: $request);
|
||||
}
|
||||
|
||||
$payload = (string)ag($request->getParsedBody() ?? [], 'data', null);
|
||||
|
||||
$json = json_decode(
|
||||
json: $payload,
|
||||
json: (string)$payload,
|
||||
associative: true,
|
||||
flags: JSON_INVALID_UTF8_IGNORE | JSON_THROW_ON_ERROR
|
||||
);
|
||||
@@ -56,8 +52,8 @@ class InspectRequest
|
||||
'backend' => [
|
||||
'id' => ag($json, 'Server.Id', ''),
|
||||
'name' => ag($json, 'Server.Name'),
|
||||
'client' => before($userAgent, '/'),
|
||||
'version' => ag($json, 'Server.Version', fn() => afterLast($userAgent, '/')),
|
||||
'client' => 'Emby',
|
||||
'version' => ag($json, 'Server.Version', ''),
|
||||
],
|
||||
'user' => [
|
||||
'id' => ag($json, 'User.Id', ''),
|
||||
|
||||
@@ -260,12 +260,12 @@ final class Initializer
|
||||
|
||||
// -- Forward requests to API server.
|
||||
if (true === str_starts_with($requestPath, Config::get('api.prefix', '????'))) {
|
||||
return $this->defaultAPIServer($realRequest);
|
||||
return $this->defaultAPIServer(clone $realRequest);
|
||||
}
|
||||
|
||||
// -- Save request payload.
|
||||
if (true === Config::get('webhook.dumpRequest')) {
|
||||
saveRequestPayload($realRequest);
|
||||
saveRequestPayload(clone $realRequest);
|
||||
}
|
||||
|
||||
$apikey = ag($realRequest->getQueryParams(), 'apikey', $realRequest->getHeaderLine('x-apikey'));
|
||||
@@ -384,7 +384,8 @@ final class Initializer
|
||||
$request,
|
||||
$loglevel ?? Level::Error,
|
||||
$this->formatLog($request, $response, $message),
|
||||
['messages' => $log],
|
||||
['messages' => $log, 'attr' => $attr ?? []],
|
||||
forceContext: true
|
||||
);
|
||||
|
||||
return $response;
|
||||
|
||||
Reference in New Issue
Block a user