diff --git a/public/index.html b/public/index.html index e00351a..b005b77 100644 --- a/public/index.html +++ b/public/index.html @@ -1036,7 +1036,8 @@ let fpItems = []; async function loadFalsePositives() { try { - fpItems = (await api('/false-positives')) || []; + const res = await api('/false-positives'); + fpItems = res.data || res || []; renderFalsePositives(); } catch (e) { console.error('fp load error', e); } } diff --git a/src/Api/Router.php b/src/Api/Router.php index a2ca876..84fad2b 100644 --- a/src/Api/Router.php +++ b/src/Api/Router.php @@ -95,7 +95,7 @@ class Router => $this->updateTelegramConfig(), $path === '/false-positives' && $method === 'GET' - => $this->repo->getFalsePositives(), + => $this->getFalsePositives(), $path === '/false-positives' && $method === 'POST' => $this->createFalsePositive(), preg_match('#^/false-positives/(\d+)$#', $path, $m) && $method === 'DELETE' @@ -337,6 +337,11 @@ class Router return $this->repo->createFalsePositive($pattern, $description); } + private function getFalsePositives(): array + { + return ['data' => $this->repo->getFalsePositives()]; + } + private function deleteFalsePositive(int $id): array { $this->repo->deleteFalsePositive($id);