mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
- Implemented edit dialog for updating video title and description. - Added functionality to create new video versions with URL validation. - Included delete confirmation dialog for video removal. - Enhanced UI with loading indicators and error handling. - Updated video card layout for better user interaction. feat(youtube): extend YT namespace with playback rate methods - Added methods to set and get playback rate. - Included method to retrieve available playback rates.
65 lines
2.3 KiB
TypeScript
65 lines
2.3 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { db } from '@/lib/db';
|
|
import { auth } from '@/lib/auth';
|
|
|
|
type RouteParams = { params: Promise<{ videoId: string }> };
|
|
|
|
// GET /api/watch/[videoId] - Public watch endpoint (no projectId needed)
|
|
export async function GET(request: NextRequest, { params }: RouteParams) {
|
|
try {
|
|
const session = await auth();
|
|
const { videoId } = await params;
|
|
|
|
const video = await db.video.findUnique({
|
|
where: { id: videoId },
|
|
include: {
|
|
project: {
|
|
include: {
|
|
members: { where: { userId: session?.user?.id || '' } },
|
|
},
|
|
},
|
|
versions: {
|
|
orderBy: { versionNumber: 'desc' },
|
|
include: {
|
|
comments: {
|
|
orderBy: { timestamp: 'asc' },
|
|
where: { parentId: null },
|
|
include: {
|
|
author: { select: { id: true, name: true, image: true } },
|
|
replies: {
|
|
orderBy: { createdAt: 'asc' },
|
|
include: {
|
|
author: { select: { id: true, name: true, image: true } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
_count: { select: { comments: true } },
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!video) {
|
|
return NextResponse.json({ error: 'Video not found' }, { status: 404 });
|
|
}
|
|
|
|
// Check access
|
|
const isOwner = session?.user?.id === video.project.ownerId;
|
|
const isMember = video.project.members.length > 0;
|
|
const isPublic = video.project.visibility === 'PUBLIC';
|
|
|
|
if (!isOwner && !isMember && !isPublic) {
|
|
return NextResponse.json({ error: 'Access denied' }, { status: 403 });
|
|
}
|
|
|
|
return NextResponse.json(video);
|
|
} catch (error) {
|
|
console.error('Error fetching video:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch video' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|