enhance
Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-05-06 13:03:10 +02:00
parent daf95349d2
commit f91b2ad773
2 changed files with 46 additions and 11 deletions
+14
View File
@@ -70,6 +70,8 @@ class Router
$path === '/alerts/search' && $method === 'GET' => $this->searchAlerts(),
preg_match('#^/alerts/(\d+)/ack$#', $path, $m) && $method === 'POST'
=> $this->ackAlert((int) $m[1]),
preg_match('#^/alerts/(\d+)/status$#', $path, $m) && $method === 'POST'
=> $this->updateAlertStatus((int) $m[1]),
preg_match('#^/alerts/counts$#', $path) && $method === 'GET'
=> $this->repo->getAlertCounts(),
@@ -198,6 +200,18 @@ class Router
return ['status' => 'acknowledged', 'id' => $id];
}
private function updateAlertStatus(int $id): array
{
$body = json_decode(file_get_contents('php://input'), true);
$status = AlertStatus::tryFrom($body['status'] ?? '');
if (!$status) {
http_response_code(400);
return ['error' => 'Invalid status. Use: open, acknowledged, resolved'];
}
$this->repo->updateAlertStatus($id, $status);
return ['status' => $status->value, 'id' => $id];
}
private function searchAlerts(): array
{
$query = $_GET['q'] ?? '';