Nachrichten 1.1.0: Schnittstelle für die App, Verbindung prüfen
- /api/v1/chat: config, Gruppenchats, verlassen, bearbeiten, löschen, Reaktionen, „Gibt es Neues?“, „schreibt …“, GIFs, Echtzeit-Anmeldung und Anhänge mit Token - Anhang-Adressen zeigen bei API-Aufrufen auf die API (Token statt Sitzung) - Backend: „Echtzeit prüfen“ und „GIPHY prüfen“ melden sofort, ob die Zugangsdaten stimmen - README: Schritt-für-Schritt-Einrichtung für pusher.com und GIPHY Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2844452002
commit
5f71c3e250
9 changed files with 207 additions and 26 deletions
28
src/Gifs.php
28
src/Gifs.php
|
|
@ -56,6 +56,34 @@ class Gifs
|
|||
return $path === '' ? Storage::disk(self::DISK)->url(self::FOLDER) : Storage::disk(self::DISK)->url($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schlüssel prüfen (Backend) – ein Abruf der Trends.
|
||||
*
|
||||
* @return array{ok: bool, message: string}
|
||||
*/
|
||||
public function checkGiphy(): array
|
||||
{
|
||||
if (! $this->giphyEnabled()) {
|
||||
return ['ok' => false, 'message' => 'Es ist kein GIPHY-Schlüssel gespeichert.'];
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::timeout(5)->acceptJson()->get('https://api.giphy.com/v1/gifs/trending', [
|
||||
'api_key' => Crypt::decryptString((string) $this->settings->get('chat.giphy_key')),
|
||||
'limit' => 1,
|
||||
]);
|
||||
} catch (Throwable $e) {
|
||||
return ['ok' => false, 'message' => 'GIPHY ist nicht erreichbar: '.mb_substr($e->getMessage(), 0, 160)];
|
||||
}
|
||||
|
||||
return match (true) {
|
||||
$response->successful() => ['ok' => true, 'message' => 'Der Schlüssel funktioniert – die GIF-Suche im Chat findet jetzt auch GIPHY.'],
|
||||
in_array($response->status(), [401, 403], true) => ['ok' => false, 'message' => 'GIPHY lehnt den Schlüssel ab – bitte prüfen.'],
|
||||
$response->status() === 429 => ['ok' => false, 'message' => 'Der Schlüssel funktioniert, das Kontingent ist aber gerade aufgebraucht (Beta-Schlüssel: 100 Abrufe pro Stunde).'],
|
||||
default => ['ok' => false, 'message' => 'Unerwartete Antwort von GIPHY (HTTP '.$response->status().').'],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue