feat: add LiveKit join flow with waiting room and host admission
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e26cfe624d
commit
3c19455bdd
16 files changed
+1367
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
import { prisma } from "@/lib/prisma"
|
||||
import { isHostOrCoHost } from "@/lib/meeting-auth"
|
||||
|
||||
export async function POST(
|
||||
_request: Request,
|
||||
{ params }: { params: Promise<{ meetingUuid: string; participantId: string }> }
|
||||
) {
|
||||
const { meetingUuid, participantId } = await params
|
||||
|
||||
const session = await auth()
|
||||
if (!session?.user?.id) {
|
||||
return NextResponse.json({ error: "No autenticado" }, { status: 401 })
|
||||
}
|
||||
|
||||
const meeting = await prisma.meeting.findUnique({
|
||||
where: { uuid: meetingUuid },
|
||||
})
|
||||
|
||||
if (!meeting) {
|
||||
return NextResponse.json(
|
||||
{ error: "Reunión no encontrada" },
|
||||
{ status: 404 }
|
||||
)
|
||||
}
|
||||
|
||||
const userId = Number(session.user.id)
|
||||
if (!(await isHostOrCoHost(meeting, userId))) {
|
||||
return NextResponse.json(
|
||||
{ error: "No tienes permiso para admitir participantes" },
|
||||
{ status: 403 }
|
||||
)
|
||||
}
|
||||
|
||||
const participant = await prisma.meetingParticipant.findUnique({
|
||||
where: { id: Number(participantId) },
|
||||
})
|
||||
|
||||
if (!participant || participant.meetingId !== meeting.id) {
|
||||
return NextResponse.json(
|
||||
{ error: "Participante no encontrado" },
|
||||
{ status: 404 }
|
||||
)
|
||||
}
|
||||
|
||||
const updated = await prisma.meetingParticipant.update({
|
||||
where: { id: participant.id },
|
||||
data: { status: "admitted", admittedAt: new Date() },
|
||||
})
|
||||
|
||||
return NextResponse.json({ id: updated.id, status: updated.status })
|
||||
}
|
||||
Reference in new issue
Block a user