0, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => true, 'samesite' => 'Lax' ]); session_start(); header('Content-Type: application/json'); error_reporting(E_ALL); ini_set('display_errors', '0'); if (empty($_SESSION['user_logged_in'])) { http_response_code(401); echo json_encode(['error' => 'Nicht eingeloggt']); exit; } include_once(__DIR__ . '/../../../controller/DatabaseController.php'); include_once(__DIR__ . '/../../../controller/NotifyController.php'); $daten = json_decode(file_get_contents('php://input'), true) ?? []; $action = $daten['action'] ?? ''; try { switch ($action) { case 'mark_seen': { $nachrichtId = $daten['nachricht_id'] ?? null; if (!is_numeric($nachrichtId)) { throw new InvalidArgumentException('Ungültige Nachrichten-ID'); } $notificationCtl = new Notification(); $notificationCtl->markAsSeen((int)$nachrichtId); echo json_encode(['success' => true]); break; } default: throw new InvalidArgumentException("Unbekannte Aktion: $action"); } } catch (InvalidArgumentException $e) { http_response_code(400); echo json_encode(['error' => $e->getMessage()]); } catch (Throwable $e) { http_response_code(500); error_log($e->getMessage()); echo json_encode(['error' => 'Serverfehler']); }