import { redirect } from "next/navigation"; import { cookies } from "next/headers"; import type { Metadata } from "next"; import { authCookieHeader } from "@/lib/cookies"; import { getMeCached, getPublicSettingsCached } from "@/lib/serverData"; import { fetchChatRooms } from "@/lib/api"; import ChatShell from "./ChatShell"; import MessagesUnsupported from "@/components/MessagesUnsupported"; export const metadata: Metadata = { title: "消息", description: "私聊与群聊,实时交流。", }; export default async function ChatListPage() { if ((await getPublicSettingsCached()).allow_messages === false) { return ; } const cookie = authCookieHeader(await cookies()); const me = await getMeCached(cookie || undefined); if (!me.user) { redirect(`/login?redirect=${encodeURIComponent("/chat")}`); } let rooms: Awaited>["rooms"] = []; try { const data = await fetchChatRooms(1, 50, "", cookie, "joined"); rooms = data.rooms || []; } catch { rooms = []; } return ( ); }