家庭动态:老人/家属发言、三种可见范围,家庭内部内容不会播给老人。 共同照护:家庭备忘录、任务创建、认领、完成与交接记录。 用药闭环:计划、未来 7 天提醒实例、确认服用、延后、异常反馈。 风险闭环:红橙黄蓝分级、30 分钟去重、推送、认领、处理与误报记录。 报平安:家属发起、老人语音回应、状态同步。 Web 导航升级为守护、家庭、照护、陪伴、我的。 设备接口已升级为设备令牌认证,UUID 不再单独承担认证。
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
|
|
import { markFamilyMessagesAsRead } from "@/lib/monitor-data";
|
|
import { requireDeviceAuth } from "@/lib/device-auth";
|
|
|
|
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 requireDeviceAuth(request, body.deviceUuid);
|
|
await markFamilyMessagesAsRead(body.deviceUuid, messageIds);
|
|
|
|
return NextResponse.json({ ok: true });
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{
|
|
error:
|
|
error instanceof Error ? error.message : "更新留言状态失败,请稍后再试。",
|
|
},
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
}
|