import type { Metadata } from 'next' import { notFound } from 'next/navigation' import { requireUser } from '@/lib/auth/current' import { AccessError } from '@/lib/errors' import { loadChatView } from '@/lib/chat/load' import { db } from '@/lib/db' import { visibleChannelWhere } from '@/lib/access/chatFilter' import { de } from '@/lib/i18n/de' import { Chat } from '@/components/chat/Chat' export const dynamic = 'force-dynamic' export async function generateMetadata({ params, }: { params: Promise<{ key: string }> }): Promise { const { key } = await params return { title: `#${key}` } } export default async function ChannelPage({ params }: { params: Promise<{ key: string }> }) { const user = await requireUser() const { key } = await params const kanal = await db.channel.findFirst({ where: { AND: [visibleChannelWhere(user.permissions), { key, isArchived: false }] }, select: { id: true, key: true, name: true, description: true }, }) // Kein Zugriff heisst 404. if (!kanal) notFound() let ansicht try { ansicht = await loadChatView(user.permissions, { kind: 'channel', key: kanal.key }) } catch (error) { if (error instanceof AccessError) notFound() throw error } return (
#{kanal.key}

{kanal.name}

{kanal.description ? (

{kanal.description}

) : null}

{de.chat.hint}

) }