Unified logging

This commit is contained in:
2024-03-11 01:20:45 +01:00
parent 56ddab0cd5
commit c31c55fafd
3 changed files with 35 additions and 11 deletions

View File

@ -91,7 +91,7 @@ class MercureHandler
code: RequestException::ERR_INVALID_REQUEST_DATA
);
[ $name, $value ] = array_map('urldecode', explode("=", $param, 2));
if ($name === 'topic') $topics[] = $value;
if ($name === 'topic' || $name === 'topic[]') $topics[] = $value;
}
// Grab the JWT token from the requests authorization attribute
@ -142,7 +142,9 @@ class MercureHandler
// Parse out the urlencoded body. Pretty sure there is a better way to do this?
$body = explode("&", (string)$request->getBody());
$data = [];
$data = [
'topic' => []
];
foreach ($body as $param) {
if (!str_contains($param, "="))
throw new RequestException(
@ -150,10 +152,8 @@ class MercureHandler
code: RequestException::ERR_INVALID_REQUEST_DATA
);
[ $name, $value ] = array_map('urldecode', explode("=", $param, 2));
if (in_array($name, [ 'topic' ])) {
if (!isset($data[$name]))
$data[$name] = [];
$data[$name][] = $value;
if ($name === 'topic' || $name === 'topic[]') {
$data['topic'][] = $value;
} else {
$data[$name] = $value;
}