import { NextRequest, NextResponse } from 'next/server'; import { getSession } from '@/lib/auth'; import { conversationService } from '@/lib/control-center'; export async function GET( request: NextRequest, { params }: { params: Promise<{ conversationId: string }> } ) { const session = await getSession(); if (!session) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } const { conversationId } = await params; try { const conversation = await conversationService.getById(conversationId); if (!conversation) { return NextResponse.json( { error: 'Conversation not found' }, { status: 404 } ); } // Verify conversation belongs to the requesting user if (conversation.userId !== session.user.id) { return NextResponse.json( { error: 'Conversation not found' }, { status: 404 } ); } return NextResponse.json(conversation); } catch (error) { console.error('Failed to get conversation:', error); return NextResponse.json( { error: 'Failed to fetch conversation' }, { status: 500 } ); } }