添加家人绑定

This commit is contained in:
2026-04-17 11:32:17 +08:00
parent 399bdf079b
commit 8c9d86e858
25 changed files with 2631 additions and 87 deletions
+39
View File
@@ -0,0 +1,39 @@
import { NextResponse } from "next/server";
import { markFamilyMessagesAsRead } from "@/lib/monitor-data";
export async function POST(request: Request) {
const body = (await request.json().catch(() => null)) as
| {
deviceUuid?: string;
messageIds?: unknown;
}
| null;
if (!body?.deviceUuid || typeof body.deviceUuid !== "string") {
return NextResponse.json(
{ error: "deviceUuid 是必填项。" },
{ status: 400 },
);
}
const messageIds = Array.isArray(body.messageIds)
? body.messageIds.filter(
(messageId): messageId is string => typeof messageId === "string",
)
: undefined;
try {
await markFamilyMessagesAsRead(body.deviceUuid, messageIds);
return NextResponse.json({ ok: true });
} catch (error) {
return NextResponse.json(
{
error:
error instanceof Error ? error.message : "更新留言状态失败,请稍后再试。",
},
{ status: 400 },
);
}
}