import { notFound } from "next/navigation"; import { headers } from "next/headers"; import Link from "next/link"; import { auth } from "@/lib/auth/server"; import { db, conversations, users, eq } from "@epicure/db"; import { ConversationsList } from "@/components/social/conversations-list"; import { MessageThread } from "@/components/social/message-thread"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { isParticipant, otherParticipantId } from "@/lib/messaging"; type Params = { params: Promise<{ id: string }> }; export default async function ConversationPage({ params }: Params) { const { id } = await params; const session = await auth.api.getSession({ headers: await headers() }); if (!session) return null; const conversation = await db.query.conversations.findFirst({ where: eq(conversations.id, id) }); if (!conversation || !isParticipant(conversation, session.user.id)) notFound(); const otherId = otherParticipantId(conversation, session.user.id); const other = await db.query.users.findFirst({ where: eq(users.id, otherId) }); if (!other) notFound(); return (