ai-chatbot/lib/video-agent/user-task-access.ts
Your Name ec988be30a
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
Update agent workflow and video task handling
2026-03-13 11:21:42 +08:00

30 lines
711 B
TypeScript

import "server-only";
import { getVideoStoryboardTaskDetail } from "@/lib/video-agent/task-store";
export class StoryboardTaskAccessError extends Error {
status: number;
constructor(message: string, status: number) {
super(message);
this.status = status;
}
}
export async function requireStoryboardTaskAccess(params: {
taskId: string;
userId: string;
}) {
const detail = await getVideoStoryboardTaskDetail(params.taskId);
if (!detail) {
throw new StoryboardTaskAccessError("任务不存在", 404);
}
if (String((detail.task as any).userId || "").trim() !== params.userId) {
throw new StoryboardTaskAccessError("无权访问该分镜任务", 403);
}
return detail;
}