@@ -67,6 +67,7 @@ class Router
|
||||
=> $this->deleteEntity('rule', (int) $m[1]),
|
||||
|
||||
$path === '/alerts' && $method === 'GET' => $this->getAlerts(),
|
||||
$path === '/alerts/search' && $method === 'GET' => $this->searchAlerts(),
|
||||
preg_match('#^/alerts/(\d+)/ack$#', $path, $m) && $method === 'POST'
|
||||
=> $this->ackAlert((int) $m[1]),
|
||||
preg_match('#^/alerts/counts$#', $path) && $method === 'GET'
|
||||
@@ -193,6 +194,16 @@ class Router
|
||||
return ['status' => 'acknowledged', 'id' => $id];
|
||||
}
|
||||
|
||||
private function searchAlerts(): array
|
||||
{
|
||||
$query = $_GET['q'] ?? '';
|
||||
if (empty($query)) {
|
||||
return [];
|
||||
}
|
||||
$limit = (int) ($_GET['limit'] ?? 100);
|
||||
return $this->repo->searchAlerts($query, $limit);
|
||||
}
|
||||
|
||||
private function updateAllowedTokens(): array
|
||||
{
|
||||
$body = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
Reference in New Issue
Block a user