IT-Service: /api/ex ergänzen, HTML-Antworten als Fehler, Kategorie und Standort Pflicht
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m35s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m54s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m53s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m1s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m17s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m31s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m11s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m33s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 20:17:39 +00:00
parent df7ebfa6cd
commit 7969a7ac83
108 changed files with 525 additions and 445 deletions

View file

@ -134,7 +134,16 @@ class Client
*/
private function json(Response $response): array
{
$data = (array) $response->json();
$decoded = $response->json();
// Eine HTML-Seite (falsche Adresse, Anmeldeseite …) ist keine leere Liste.
if ($response->successful() && ! is_array($decoded)) {
Log::warning('OpenNIT lieferte keine JSON-Antwort', ['body' => mb_substr($response->body(), 0, 300)]);
throw new OpenNitException('Der IT-Service hat keine gültige API-Antwort geliefert. Bitte die API-Adresse prüfen (sie endet auf „/api/ex“).', 502);
}
$data = (array) $decoded;
if (! $response->successful()) {
Log::info("OpenNIT antwortete {$response->status()}", ['body' => mb_substr($response->body(), 0, 500)]);

View file

@ -26,7 +26,21 @@ class Settings
public function url(): string
{
return rtrim((string) $this->settings->get(self::URL, ''), '/');
return self::normalizeUrl((string) $this->settings->get(self::URL, ''));
}
/**
* Nur die Adresse des Servers eingetragen? Dann gehört „/api/ex“ dazu.
*/
public static function normalizeUrl(string $url): string
{
$url = rtrim(trim($url), '/');
if ($url !== '' && in_array((string) parse_url($url, PHP_URL_PATH), ['', '/'], true)) {
$url .= '/api/ex';
}
return $url;
}
public function token(): string
@ -61,7 +75,7 @@ class Settings
*/
public function save(array $data): void
{
$this->settings->set(self::URL, rtrim(trim($data['url']), '/'));
$this->settings->set(self::URL, self::normalizeUrl($data['url']));
foreach ([self::TOKEN => $data['token'] ?? null, self::SECRET => $data['secret'] ?? null] as $key => $value) {
if (filled($value)) {