feat: 后台增加开放消息开关
关闭后前台隐藏私聊/群聊入口并由后端拦截;同步去掉公告页重复计数胶囊。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,10 +2,11 @@ import type { Metadata } from "next";
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
import { cookies } from "next/headers";
|
||||
import { authCookieHeader } from "@/lib/cookies";
|
||||
import { getMeCached } from "@/lib/serverData";
|
||||
import { getMeCached, getPublicSettingsCached } from "@/lib/serverData";
|
||||
import { fetchChatRoom, fetchChatMessages, fetchChatRooms } from "@/lib/api";
|
||||
import ChatShell from "../ChatShell";
|
||||
import ChatRoomClient from "./ChatRoomClient";
|
||||
import MessagesUnsupported from "@/components/MessagesUnsupported";
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ id: string }>;
|
||||
@@ -13,6 +14,9 @@ interface PageProps {
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const { id } = await params;
|
||||
if ((await getPublicSettingsCached()).allow_messages === false) {
|
||||
return { title: "本站不支持消息" };
|
||||
}
|
||||
try {
|
||||
const { room } = await fetchChatRoom(id, authCookieHeader(await cookies()));
|
||||
const title =
|
||||
@@ -27,6 +31,9 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
|
||||
|
||||
export default async function ChatRoomPage({ params }: PageProps) {
|
||||
const { id } = await params;
|
||||
if ((await getPublicSettingsCached()).allow_messages === false) {
|
||||
return <MessagesUnsupported />;
|
||||
}
|
||||
const cookie = authCookieHeader(await cookies());
|
||||
const me = await getMeCached(cookie || undefined);
|
||||
if (!me.user) {
|
||||
|
||||
Reference in New Issue
Block a user