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

57 lines
1.4 KiB
TypeScript

import { NextResponse } from "next/server";
import { z } from "zod";
import { auth } from "@/app/(auth)/auth";
import {
requireStoryboardTaskAccess,
StoryboardTaskAccessError,
} from "@/lib/video-agent/user-task-access";
const paramsSchema = z.object({
taskId: z.string().uuid(),
});
export async function GET(
_request: Request,
{ params }: { params: Promise<{ taskId: string }> }
) {
try {
const session = await auth();
if (!session?.user?.id) {
return NextResponse.json({ success: false, error: "未登录" }, { status: 401 });
}
const parsed = paramsSchema.parse(await params);
const detail = await requireStoryboardTaskAccess({
taskId: parsed.taskId,
userId: session.user.id,
});
return NextResponse.json({
success: true,
task: detail.task,
shots: detail.shots,
});
} catch (error) {
if (error instanceof StoryboardTaskAccessError) {
return NextResponse.json(
{ success: false, error: error.message },
{ status: error.status }
);
}
if (error instanceof z.ZodError) {
return NextResponse.json(
{ success: false, error: error.message },
{ status: 400 }
);
}
return NextResponse.json(
{
success: false,
error: error instanceof Error ? error.message : "查询任务失败",
},
{ status: 500 }
);
}
}