mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-12-03 02:37:06 +03:00
send notice ids in the request body (#25142)
Notice ids went into the URL path, and nginx decodes the path, merges slashes, and resolves dot segments before proxying. A detector named zmq:tcp://host:5555 came through as tcp:/host, so its notice 404'd and couldn't be acknowledged or muted. The same happened to failed_login notices for usernames containing // or /../. Acknowledge, mute, and unhide now take the id in a JSON body at /notices/acknowledge, /notices/mute, and /notices/unhide.
This commit is contained in:
Vendored
+34
-28
@@ -4346,7 +4346,7 @@ paths:
|
|||||||
security:
|
security:
|
||||||
- frigateAdminAuth: []
|
- frigateAdminAuth: []
|
||||||
x-required-role: admin
|
x-required-role: admin
|
||||||
/notices/{notice_id}/acknowledge:
|
/notices/acknowledge:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- Notices
|
- Notices
|
||||||
@@ -4358,14 +4358,13 @@ paths:
|
|||||||
|
|
||||||
Config and stream check rows and the update notice never repeat, so they
|
Config and stream check rows and the update notice never repeat, so they
|
||||||
can only be muted.
|
can only be muted.
|
||||||
operationId: acknowledge_notice_notices__notice_id__acknowledge_post
|
operationId: acknowledge_notice_notices_acknowledge_post
|
||||||
parameters:
|
requestBody:
|
||||||
- name: notice_id
|
required: true
|
||||||
in: path
|
content:
|
||||||
required: true
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
$ref: '#/components/schemas/NoticeIdBody'
|
||||||
title: Notice Id
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successful Response
|
description: Successful Response
|
||||||
@@ -4381,7 +4380,7 @@ paths:
|
|||||||
security:
|
security:
|
||||||
- frigateAdminAuth: []
|
- frigateAdminAuth: []
|
||||||
x-required-role: admin
|
x-required-role: admin
|
||||||
/notices/{notice_id}/mute:
|
/notices/mute:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- Notices
|
- Notices
|
||||||
@@ -4390,14 +4389,13 @@ paths:
|
|||||||
**Access:** Admin role required.
|
**Access:** Admin role required.
|
||||||
|
|
||||||
Hide a notice or a config or stream check row for good.
|
Hide a notice or a config or stream check row for good.
|
||||||
operationId: mute_notice_notices__notice_id__mute_post
|
operationId: mute_notice_notices_mute_post
|
||||||
parameters:
|
requestBody:
|
||||||
- name: notice_id
|
required: true
|
||||||
in: path
|
content:
|
||||||
required: true
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
$ref: '#/components/schemas/NoticeIdBody'
|
||||||
title: Notice Id
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successful Response
|
description: Successful Response
|
||||||
@@ -4413,8 +4411,8 @@ paths:
|
|||||||
security:
|
security:
|
||||||
- frigateAdminAuth: []
|
- frigateAdminAuth: []
|
||||||
x-required-role: admin
|
x-required-role: admin
|
||||||
/notices/{notice_id}/hidden:
|
/notices/unhide:
|
||||||
delete:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- Notices
|
- Notices
|
||||||
summary: Unhide Notice
|
summary: Unhide Notice
|
||||||
@@ -4422,14 +4420,13 @@ paths:
|
|||||||
**Access:** Admin role required.
|
**Access:** Admin role required.
|
||||||
|
|
||||||
Show an acknowledged or muted notice or check row again.
|
Show an acknowledged or muted notice or check row again.
|
||||||
operationId: unhide_notice_notices__notice_id__hidden_delete
|
operationId: unhide_notice_notices_unhide_post
|
||||||
parameters:
|
requestBody:
|
||||||
- name: notice_id
|
required: true
|
||||||
in: path
|
content:
|
||||||
required: true
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
$ref: '#/components/schemas/NoticeIdBody'
|
||||||
title: Notice Id
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successful Response
|
description: Successful Response
|
||||||
@@ -9324,6 +9321,15 @@ components:
|
|||||||
- status
|
- status
|
||||||
title: MotionSearchStatusResponse
|
title: MotionSearchStatusResponse
|
||||||
description: Response containing job status and results.
|
description: Response containing job status and results.
|
||||||
|
NoticeIdBody:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
title: Notice or check row id
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
title: NoticeIdBody
|
||||||
PlaybackSourceEnum:
|
PlaybackSourceEnum:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
|
class NoticeIdBody(BaseModel):
|
||||||
|
id: str = Field(title="Notice or check row id")
|
||||||
+13
-11
@@ -6,6 +6,7 @@ from fastapi import APIRouter, Depends, Request
|
|||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
|
|
||||||
from frigate.api.auth import require_role
|
from frigate.api.auth import require_role
|
||||||
|
from frigate.api.defs.request.notice_body import NoticeIdBody
|
||||||
from frigate.api.defs.tags import Tags
|
from frigate.api.defs.tags import Tags
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -48,18 +49,19 @@ def unhide_all_notices(request: Request) -> JSONResponse:
|
|||||||
return JSONResponse(content={"success": True, "message": "Notices shown again"})
|
return JSONResponse(content={"success": True, "message": "Notices shown again"})
|
||||||
|
|
||||||
|
|
||||||
# model notice ids contain a slash, so the id is a path parameter
|
# the id goes in the body because nginx merges slashes and resolves dot segments
|
||||||
|
# in the path after decoding it
|
||||||
@router.post(
|
@router.post(
|
||||||
"/notices/{notice_id:path}/acknowledge",
|
"/notices/acknowledge",
|
||||||
dependencies=[Depends(require_role(["admin"]))],
|
dependencies=[Depends(require_role(["admin"]))],
|
||||||
)
|
)
|
||||||
def acknowledge_notice(request: Request, notice_id: str) -> JSONResponse:
|
def acknowledge_notice(request: Request, body: NoticeIdBody) -> JSONResponse:
|
||||||
"""Hide a notice until it happens again.
|
"""Hide a notice until it happens again.
|
||||||
|
|
||||||
Config and stream check rows and the update notice never repeat, so they
|
Config and stream check rows and the update notice never repeat, so they
|
||||||
can only be muted.
|
can only be muted.
|
||||||
"""
|
"""
|
||||||
if not request.app.notice_registry.acknowledge(notice_id):
|
if not request.app.notice_registry.acknowledge(body.id):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={"success": False, "message": "Notice not found"},
|
content={"success": False, "message": "Notice not found"},
|
||||||
status_code=404,
|
status_code=404,
|
||||||
@@ -69,12 +71,12 @@ def acknowledge_notice(request: Request, notice_id: str) -> JSONResponse:
|
|||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/notices/{notice_id:path}/mute",
|
"/notices/mute",
|
||||||
dependencies=[Depends(require_role(["admin"]))],
|
dependencies=[Depends(require_role(["admin"]))],
|
||||||
)
|
)
|
||||||
def mute_notice(request: Request, notice_id: str) -> JSONResponse:
|
def mute_notice(request: Request, body: NoticeIdBody) -> JSONResponse:
|
||||||
"""Hide a notice or a config or stream check row for good."""
|
"""Hide a notice or a config or stream check row for good."""
|
||||||
if not request.app.notice_registry.mute(notice_id):
|
if not request.app.notice_registry.mute(body.id):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={"success": False, "message": "Notice not found"},
|
content={"success": False, "message": "Notice not found"},
|
||||||
status_code=404,
|
status_code=404,
|
||||||
@@ -83,13 +85,13 @@ def mute_notice(request: Request, notice_id: str) -> JSONResponse:
|
|||||||
return JSONResponse(content={"success": True, "message": "Notice muted"})
|
return JSONResponse(content={"success": True, "message": "Notice muted"})
|
||||||
|
|
||||||
|
|
||||||
@router.delete(
|
@router.post(
|
||||||
"/notices/{notice_id:path}/hidden",
|
"/notices/unhide",
|
||||||
dependencies=[Depends(require_role(["admin"]))],
|
dependencies=[Depends(require_role(["admin"]))],
|
||||||
)
|
)
|
||||||
def unhide_notice(request: Request, notice_id: str) -> JSONResponse:
|
def unhide_notice(request: Request, body: NoticeIdBody) -> JSONResponse:
|
||||||
"""Show an acknowledged or muted notice or check row again."""
|
"""Show an acknowledged or muted notice or check row again."""
|
||||||
if not request.app.notice_registry.unhide(notice_id):
|
if not request.app.notice_registry.unhide(body.id):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={"success": False, "message": "Notice not found"},
|
content={"success": False, "message": "Notice not found"},
|
||||||
status_code=404,
|
status_code=404,
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ class TestHttpNotices(BaseTestHttp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with self.client() as client:
|
with self.client() as client:
|
||||||
response = client.post("/notices/detector_stuck:ov/acknowledge")
|
response = client.post(
|
||||||
|
"/notices/acknowledge", json={"id": "detector_stuck:ov"}
|
||||||
|
)
|
||||||
listed = client.get("/notices").json()
|
listed = client.get("/notices").json()
|
||||||
hidden = client.get("/notices", params={"include_hidden": True}).json()
|
hidden = client.get("/notices", params={"include_hidden": True}).json()
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ class TestHttpNotices(BaseTestHttp):
|
|||||||
|
|
||||||
def test_acknowledging_a_check_is_404(self):
|
def test_acknowledging_a_check_is_404(self):
|
||||||
with self.client() as client:
|
with self.client() as client:
|
||||||
response = client.post(f"/notices/{CONFIG_CHECK}/acknowledge")
|
response = client.post("/notices/acknowledge", json={"id": CONFIG_CHECK})
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
@@ -81,32 +83,49 @@ class TestHttpNotices(BaseTestHttp):
|
|||||||
|
|
||||||
with self.client() as client:
|
with self.client() as client:
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/notices/model_download_failed:yolo/model.onnx/mute"
|
"/notices/mute", json={"id": "model_download_failed:yolo/model.onnx"}
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(self.registry.active(), [])
|
self.assertEqual(self.registry.active(), [])
|
||||||
|
|
||||||
|
def test_ids_that_path_handling_would_mangle(self):
|
||||||
|
scopes = ["zmq:tcp://wildcat-test:5555", "openvino:GPU#2", "a/../b?c%2F"]
|
||||||
|
for scope in scopes:
|
||||||
|
self.registry.raise_notice("detector_stuck", scope=scope, params={})
|
||||||
|
|
||||||
|
with self.client() as client:
|
||||||
|
responses = [
|
||||||
|
client.post(
|
||||||
|
"/notices/acknowledge", json={"id": f"detector_stuck:{scope}"}
|
||||||
|
)
|
||||||
|
for scope in scopes
|
||||||
|
]
|
||||||
|
|
||||||
|
self.assertEqual([r.status_code for r in responses], [200] * 3)
|
||||||
|
self.assertEqual(self.registry.active(), [])
|
||||||
|
|
||||||
def test_unknown_ids_are_404(self):
|
def test_unknown_ids_are_404(self):
|
||||||
with self.client() as client:
|
with self.client() as client:
|
||||||
responses = [
|
responses = [
|
||||||
client.post("/notices/nope/acknowledge"),
|
client.post("/notices/acknowledge", json={"id": "nope"}),
|
||||||
client.post("/notices/nope/mute"),
|
client.post("/notices/mute", json={"id": "nope"}),
|
||||||
client.delete("/notices/nope/hidden"),
|
client.post("/notices/unhide", json={"id": "nope"}),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.assertEqual([r.status_code for r in responses], [404, 404, 404])
|
self.assertEqual([r.status_code for r in responses], [404, 404, 404])
|
||||||
|
|
||||||
def test_requires_admin(self):
|
def test_requires_admin(self):
|
||||||
viewer = {"remote-user": "viewer", "remote-role": "viewer"}
|
viewer = {"remote-user": "viewer", "remote-role": "viewer"}
|
||||||
|
ov = {"id": "detector_stuck:ov"}
|
||||||
|
|
||||||
with TestClient(self.app) as client:
|
with TestClient(self.app) as client:
|
||||||
responses = [
|
responses = [
|
||||||
client.get("/notices", headers=viewer),
|
client.get("/notices", headers=viewer),
|
||||||
client.get("/notices/muted_checks", headers=viewer),
|
client.get("/notices/muted_checks", headers=viewer),
|
||||||
client.post("/notices/detector_stuck:ov/acknowledge", headers=viewer),
|
client.post("/notices/acknowledge", json=ov, headers=viewer),
|
||||||
client.post("/notices/detector_stuck:ov/mute", headers=viewer),
|
client.post("/notices/mute", json=ov, headers=viewer),
|
||||||
client.delete("/notices/detector_stuck:ov/hidden", headers=viewer),
|
client.post("/notices/unhide", json=ov, headers=viewer),
|
||||||
client.delete("/notices/hidden", headers=viewer),
|
client.delete("/notices/hidden", headers=viewer),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -114,8 +133,8 @@ class TestHttpNotices(BaseTestHttp):
|
|||||||
|
|
||||||
def test_muted_checks_are_listed_once(self):
|
def test_muted_checks_are_listed_once(self):
|
||||||
with self.client() as client:
|
with self.client() as client:
|
||||||
first = client.post(f"/notices/{CONFIG_CHECK}/mute")
|
first = client.post("/notices/mute", json={"id": CONFIG_CHECK})
|
||||||
again = client.post(f"/notices/{CONFIG_CHECK}/mute")
|
again = client.post("/notices/mute", json={"id": CONFIG_CHECK})
|
||||||
listed = client.get("/notices/muted_checks").json()
|
listed = client.get("/notices/muted_checks").json()
|
||||||
hidden = client.get("/notices", params={"include_hidden": True}).json()
|
hidden = client.get("/notices", params={"include_hidden": True}).json()
|
||||||
|
|
||||||
@@ -134,8 +153,8 @@ class TestHttpNotices(BaseTestHttp):
|
|||||||
self.registry.mute(CONFIG_CHECK)
|
self.registry.mute(CONFIG_CHECK)
|
||||||
|
|
||||||
with self.client() as client:
|
with self.client() as client:
|
||||||
notice = client.delete("/notices/detector_stuck:ov/hidden")
|
notice = client.post("/notices/unhide", json={"id": "detector_stuck:ov"})
|
||||||
check = client.delete(f"/notices/{CONFIG_CHECK}/hidden")
|
check = client.post("/notices/unhide", json={"id": CONFIG_CHECK})
|
||||||
listed = client.get("/notices").json()
|
listed = client.get("/notices").json()
|
||||||
checks = client.get("/notices/muted_checks").json()
|
checks = client.get("/notices/muted_checks").json()
|
||||||
|
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ const EVENT_NOTICE = {
|
|||||||
muted_at: null,
|
muted_at: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// a repeated device gets a '#2' suffix, which a raw URL would cut off as a fragment
|
// nginx would merge the slashes if this id went in the URL path
|
||||||
const SUFFIXED_NOTICE = {
|
const ZMQ_NOTICE = {
|
||||||
...EVENT_NOTICE,
|
...EVENT_NOTICE,
|
||||||
id: "detector_stuck:openvino:GPU#2",
|
id: "detector_stuck:zmq:tcp://host:5555",
|
||||||
scope: "openvino:GPU#2",
|
scope: "zmq:tcp://host:5555",
|
||||||
params: { detector: "openvino:GPU#2" },
|
params: { detector: "zmq:tcp://host:5555" },
|
||||||
};
|
};
|
||||||
|
|
||||||
test.describe("System — Health tab @medium", () => {
|
test.describe("System — Health tab @medium", () => {
|
||||||
@@ -103,17 +103,17 @@ test.describe("System — Health tab @medium", () => {
|
|||||||
|
|
||||||
for (const action of ["acknowledge", "mute"] as const) {
|
for (const action of ["acknowledge", "mute"] as const) {
|
||||||
test(`${action} posts and removes the row`, async ({ frigateApp }) => {
|
test(`${action} posts and removes the row`, async ({ frigateApp }) => {
|
||||||
const path = `/api/notices/${encodeURIComponent(SUFFIXED_NOTICE.id)}/${action}`;
|
const path = `/api/notices/${action}`;
|
||||||
await frigateApp.installDefaults({
|
await frigateApp.installDefaults({
|
||||||
config: RESTREAMED,
|
config: RESTREAMED,
|
||||||
stats: QUIET_STATS,
|
stats: QUIET_STATS,
|
||||||
notices: [SUFFIXED_NOTICE],
|
notices: [ZMQ_NOTICE],
|
||||||
});
|
});
|
||||||
|
|
||||||
// the list shrinks after the POST so the refetch shows the row gone
|
// the list shrinks after the POST so the refetch shows the row gone
|
||||||
let hidden = false;
|
let hidden = false;
|
||||||
await frigateApp.page.route("**/api/notices", (route) =>
|
await frigateApp.page.route("**/api/notices", (route) =>
|
||||||
route.fulfill({ json: hidden ? [] : [SUFFIXED_NOTICE] }),
|
route.fulfill({ json: hidden ? [] : [ZMQ_NOTICE] }),
|
||||||
);
|
);
|
||||||
await frigateApp.page.route(
|
await frigateApp.page.route(
|
||||||
(url) => url.pathname.endsWith(path),
|
(url) => url.pathname.endsWith(path),
|
||||||
@@ -126,10 +126,12 @@ test.describe("System — Health tab @medium", () => {
|
|||||||
await frigateApp.goto("/system#health");
|
await frigateApp.goto("/system#health");
|
||||||
const request = frigateApp.page.waitForRequest(
|
const request = frigateApp.page.waitForRequest(
|
||||||
(req) =>
|
(req) =>
|
||||||
new URL(req.url()).pathname.endsWith(path) && req.method() === "POST",
|
new URL(req.url()).pathname.endsWith(path) &&
|
||||||
|
req.method() === "POST" &&
|
||||||
|
req.postDataJSON()?.id === ZMQ_NOTICE.id,
|
||||||
);
|
);
|
||||||
await frigateApp.page
|
await frigateApp.page
|
||||||
.getByTestId(`health-problem-notice:${SUFFIXED_NOTICE.id}`)
|
.getByTestId(`health-problem-notice:${ZMQ_NOTICE.id}`)
|
||||||
.getByRole("button", {
|
.getByRole("button", {
|
||||||
name: action === "mute" ? "Mute" : "Acknowledge",
|
name: action === "mute" ? "Mute" : "Acknowledge",
|
||||||
exact: true,
|
exact: true,
|
||||||
@@ -272,7 +274,7 @@ test.describe("System — Health tab @medium", () => {
|
|||||||
url.searchParams.get("include_hidden") === "true",
|
url.searchParams.get("include_hidden") === "true",
|
||||||
(route) => route.fulfill({ json: [MUTED_NOTICE] }),
|
(route) => route.fulfill({ json: [MUTED_NOTICE] }),
|
||||||
);
|
);
|
||||||
const path = `/api/notices/${encodeURIComponent(MUTED_NOTICE.id)}/hidden`;
|
const path = "/api/notices/unhide";
|
||||||
await frigateApp.page.route(
|
await frigateApp.page.route(
|
||||||
(url) => url.pathname.endsWith(path),
|
(url) => url.pathname.endsWith(path),
|
||||||
(route) => route.fulfill({ json: { success: true } }),
|
(route) => route.fulfill({ json: { success: true } }),
|
||||||
@@ -285,7 +287,9 @@ test.describe("System — Health tab @medium", () => {
|
|||||||
|
|
||||||
const request = frigateApp.page.waitForRequest(
|
const request = frigateApp.page.waitForRequest(
|
||||||
(req) =>
|
(req) =>
|
||||||
new URL(req.url()).pathname.endsWith(path) && req.method() === "DELETE",
|
new URL(req.url()).pathname.endsWith(path) &&
|
||||||
|
req.method() === "POST" &&
|
||||||
|
req.postDataJSON()?.id === MUTED_NOTICE.id,
|
||||||
);
|
);
|
||||||
await frigateApp.page
|
await frigateApp.page
|
||||||
.getByTestId(
|
.getByTestId(
|
||||||
@@ -1356,7 +1360,7 @@ test.describe("System — Health notices sources @medium", () => {
|
|||||||
|
|
||||||
// the list gains the mute after the POST so the refetch hides the row
|
// the list gains the mute after the POST so the refetch hides the row
|
||||||
let muted = false;
|
let muted = false;
|
||||||
const path = `/api/notices/${encodeURIComponent(id)}/mute`;
|
const path = "/api/notices/mute";
|
||||||
await frigateApp.page.route(
|
await frigateApp.page.route(
|
||||||
(url) => url.pathname.endsWith(path),
|
(url) => url.pathname.endsWith(path),
|
||||||
(route) => {
|
(route) => {
|
||||||
@@ -1376,7 +1380,9 @@ test.describe("System — Health notices sources @medium", () => {
|
|||||||
);
|
);
|
||||||
const request = frigateApp.page.waitForRequest(
|
const request = frigateApp.page.waitForRequest(
|
||||||
(req) =>
|
(req) =>
|
||||||
new URL(req.url()).pathname.endsWith(path) && req.method() === "POST",
|
new URL(req.url()).pathname.endsWith(path) &&
|
||||||
|
req.method() === "POST" &&
|
||||||
|
req.postDataJSON()?.id === id,
|
||||||
);
|
);
|
||||||
await row.getByRole("button", { name: "Mute", exact: true }).click();
|
await row.getByRole("button", { name: "Mute", exact: true }).click();
|
||||||
await request;
|
await request;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export function useHealthProblems(
|
|||||||
|
|
||||||
const muteCheck = useCallback(
|
const muteCheck = useCallback(
|
||||||
async (id: string) => {
|
async (id: string) => {
|
||||||
await axios.post(`notices/${encodeURIComponent(id)}/mute`);
|
await axios.post("notices/mute", { id });
|
||||||
mutateMutedChecks();
|
mutateMutedChecks();
|
||||||
},
|
},
|
||||||
[mutateMutedChecks],
|
[mutateMutedChecks],
|
||||||
@@ -66,7 +66,7 @@ export function useHealthProblems(
|
|||||||
|
|
||||||
const unmuteCheck = useCallback(
|
const unmuteCheck = useCallback(
|
||||||
async (id: string) => {
|
async (id: string) => {
|
||||||
await axios.delete(`notices/${encodeURIComponent(id)}/hidden`);
|
await axios.post("notices/unhide", { id });
|
||||||
mutateMutedChecks();
|
mutateMutedChecks();
|
||||||
},
|
},
|
||||||
[mutateMutedChecks],
|
[mutateMutedChecks],
|
||||||
|
|||||||
@@ -60,17 +60,15 @@ export function useNotices(showHidden: boolean) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const acknowledge = useCallback(
|
const acknowledge = useCallback(
|
||||||
(id: string) =>
|
(id: string) => act(axios.post("notices/acknowledge", { id })),
|
||||||
act(axios.post(`notices/${encodeURIComponent(id)}/acknowledge`)),
|
|
||||||
[act],
|
[act],
|
||||||
);
|
);
|
||||||
const mute = useCallback(
|
const mute = useCallback(
|
||||||
(id: string) => act(axios.post(`notices/${encodeURIComponent(id)}/mute`)),
|
(id: string) => act(axios.post("notices/mute", { id })),
|
||||||
[act],
|
[act],
|
||||||
);
|
);
|
||||||
const unhide = useCallback(
|
const unhide = useCallback(
|
||||||
(id: string) =>
|
(id: string) => act(axios.post("notices/unhide", { id })),
|
||||||
act(axios.delete(`notices/${encodeURIComponent(id)}/hidden`)),
|
|
||||||
[act],
|
[act],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user