Herzen, Reichweite und App-Anbindung (0.30.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m10s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 6m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m25s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m28s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m27s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m26s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m27s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m12s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 12:24:11 +00:00
parent d9fcc7a9b4
commit b3e2b525e1
161 changed files with 1249 additions and 342 deletions

52
app/Push/ExpoPush.php Normal file
View file

@ -0,0 +1,52 @@
<?php
namespace App\Push;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Http;
/**
* Push an die Inhaus-App über den Push-Dienst von Expo (leitet an Apple und Google weiter).
* Übertragen werden nur Titel, Kurztext und der Link – wie bei Web-Push.
*/
class ExpoPush
{
public const ENDPOINT = 'https://exp.host/--/api/v2/push/send';
/**
* @param Collection<int, AppDevice> $devices
* @param array<string, mixed> $payload
*/
public function send(Collection $devices, array $payload): void
{
foreach ($devices->chunk(100) as $chunk) {
$chunk = $chunk->values();
$response = Http::timeout(15)->acceptJson()->post(self::ENDPOINT, $chunk->map(fn (AppDevice $device) => [
'to' => $device->push_token,
'title' => $payload['title'] ?? '',
'body' => $payload['body'] ?? '',
'data' => ['url' => $payload['url'] ?? '/'],
'sound' => 'default',
])->all());
if (! $response->successful()) {
continue;
}
// Antwort in derselben Reihenfolge: abgemeldete Geräte entfernen
foreach ((array) $response->json('data') as $i => $ticket) {
$device = $chunk[$i] ?? null;
if (! $device) {
continue;
}
if (($ticket['status'] ?? null) === 'error' && ($ticket['details']['error'] ?? null) === 'DeviceNotRegistered') {
$device->delete();
} elseif (($ticket['status'] ?? null) === 'ok') {
$device->forceFill(['last_used_at' => now()])->save();
}
}
}
}
}