Files
2026-03-05 10:25:39 +01:00

37 lines
876 B
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/_bootstrap.php';
require_auth_json(['client','praticien','secretaire','admin']);
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
json_response(['ok'=>false,'error'=>'method_not_allowed'], 405);
}
$input = read_json_body();
$endpoint = trim((string)($input['endpoint'] ?? ''));
if ($endpoint === '') {
json_response(['ok'=>false,'error'=>'bad_params'], 400);
}
try {
$stmt = $pdo->prepare("
UPDATE push_subscriptions
SET is_active = 0, updated_at = NOW()
WHERE endpoint = :e
AND compte_id = :cid
");
$stmt->execute([
':e' => $endpoint,
':cid' => (int)($_SESSION['compte_id'] ?? 0),
]);
json_response(['ok'=>true]);
} catch (Throwable $e) {
error_log('push unsubscribe error: '.$e->getMessage());
json_response(['ok'=>false,'error'=>'server_error'], 500);
}