referenzen auf "credits" entfernt. Kamera-Seite schicker gemacht

This commit is contained in:
Codex Agent
2025-11-13 10:44:16 +01:00
parent a4feb431fb
commit d9a63a6209
14 changed files with 373 additions and 219 deletions

View File

@@ -33,6 +33,7 @@ use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
@@ -1618,6 +1619,10 @@ class EventPublicController extends BaseController
$guestIdentifier = $this->resolveNotificationIdentifier($request);
$limit = max(1, min(50, (int) $request->integer('limit', 35)));
if (! Schema::hasTable('guest_notifications')) {
return $this->emptyNotificationsResponse($request, $event->id, 'disabled');
}
$baseQuery = GuestNotification::query()
->where('event_id', $event->id)
->active()
@@ -1668,6 +1673,30 @@ class EventPublicController extends BaseController
->header('Vary', 'X-Device-Id, Accept-Language');
}
private function emptyNotificationsResponse(Request $request, int $eventId, string $reason = 'empty'): JsonResponse
{
$etag = sha1(sprintf('event:%d:guest_notifications:%s', $eventId, $reason));
$clientEtags = array_map(fn ($tag) => trim($tag, '"'), $request->getETags());
if (in_array($etag, $clientEtags, true)) {
return response()->json([], Response::HTTP_NOT_MODIFIED)
->header('ETag', $etag)
->header('Cache-Control', 'no-store')
->header('Vary', 'X-Device-Id, Accept-Language');
}
return response()->json([
'data' => [],
'meta' => [
'unread_count' => 0,
'poll_after_seconds' => 120,
'reason' => $reason,
],
])->header('ETag', $etag)
->header('Cache-Control', 'no-store')
->header('Vary', 'X-Device-Id, Accept-Language');
}
public function registerPushSubscription(Request $request, string $token)
{
$result = $this->resolvePublishedEvent($request, $token, ['id']);

View File

@@ -12,11 +12,18 @@ use App\Models\GuestNotification;
use App\Models\GuestNotificationReceipt;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
use Throwable;
class GuestNotificationService
{
public function __construct(private readonly Dispatcher $events) {}
private bool $notificationsStorageAvailable;
public function __construct(private readonly Dispatcher $events)
{
$this->notificationsStorageAvailable = $this->detectStorageAvailability();
}
/**
* @param array{payload?: array|null, target_identifier?: string|null, priority?: int|null, expires_at?: \DateTimeInterface|null, status?: GuestNotificationState|null, audience_scope?: GuestNotificationAudience|string|null} $options
@@ -49,6 +56,12 @@ class GuestNotificationService
'expires_at' => $options['expires_at'] ?? null,
]);
if (! $this->notificationsStorageAvailable) {
$this->logStorageWarningOnce();
return $notification;
}
$notification->save();
$this->events->dispatch(new GuestNotificationCreated($notification));
@@ -71,6 +84,16 @@ class GuestNotificationService
$guestIdentifier = $this->sanitizeIdentifier($guestIdentifier) ?? 'anonymous';
/** @var GuestNotificationReceipt $receipt */
if (! $this->notificationsStorageAvailable) {
$this->logStorageWarningOnce();
return new GuestNotificationReceipt([
'guest_notification_id' => $notification->getKey(),
'guest_identifier' => $guestIdentifier,
...$this->buildReceiptAttributes($status),
]);
}
$receipt = GuestNotificationReceipt::query()->updateOrCreate(
[
'guest_notification_id' => $notification->getKey(),
@@ -159,4 +182,25 @@ class GuestNotificationService
return GuestNotificationAudience::ALL;
}
}
private function detectStorageAvailability(): bool
{
try {
return Schema::hasTable('guest_notifications') && Schema::hasTable('guest_notification_receipts');
} catch (Throwable) {
return false;
}
}
private function logStorageWarningOnce(): void
{
static $alreadyWarned = false;
if ($alreadyWarned) {
return;
}
$alreadyWarned = true;
Log::warning('Guest notifications storage tables are missing. Notification persistence skipped.');
}
}