2026-11-26 10:29:49 +00:00
|
|
|
import Link from "next/link";
|
|
|
|
|
import { notFound } from "next/navigation";
|
|
|
|
|
|
2026-11-26 13:02:38 +00:00
|
|
|
import {
|
|
|
|
|
type ForumTopic,
|
|
|
|
|
type ModLogEntry,
|
|
|
|
|
type ReportEntry,
|
|
|
|
|
type TopicRequest,
|
|
|
|
|
banText,
|
|
|
|
|
memberHref,
|
|
|
|
|
threadHref,
|
|
|
|
|
} from "@/lib/forum";
|
2026-11-26 10:29:49 +00:00
|
|
|
import { forumGet } from "@/lib/forumServer";
|
2026-11-26 13:02:38 +00:00
|
|
|
import { getMe } from "@/lib/server";
|
2026-11-26 10:29:49 +00:00
|
|
|
|
2026-11-26 10:48:28 +00:00
|
|
|
import { ReportsList } from "./ReportsList";
|
2026-11-26 13:02:38 +00:00
|
|
|
import { TopicsAdmin } from "./TopicsAdmin";
|
2026-11-26 10:48:28 +00:00
|
|
|
|
|
|
|
|
export const metadata = { title: "Moderálás", robots: { index: false } };
|
2026-11-26 10:29:49 +00:00
|
|
|
|
|
|
|
|
const ACTIONS: Record<string, string> = {
|
|
|
|
|
delete_post: "hozzászólást távolított el",
|
|
|
|
|
restore_post: "hozzászólást állított vissza",
|
|
|
|
|
delete_thread: "szálat távolított el",
|
|
|
|
|
restore_thread: "szálat állított vissza",
|
|
|
|
|
ban: "eltiltotta",
|
|
|
|
|
unban: "feloldotta az eltiltását",
|
|
|
|
|
lock: "lezárta a szálat",
|
|
|
|
|
unlock: "feloldotta a szálat",
|
|
|
|
|
pin: "kitűzte a szálat",
|
|
|
|
|
unpin: "levette a kitűzést",
|
2026-11-26 10:48:28 +00:00
|
|
|
resolve_report: "lezárt egy jelentést",
|
|
|
|
|
dismiss_report: "alaptalannak ítélt egy jelentést",
|
2026-11-26 13:02:38 +00:00
|
|
|
approve_member: "felvette egy zárt témába",
|
|
|
|
|
reject_member: "elutasította a jelentkezését",
|
|
|
|
|
remove_member: "eltávolította egy zárt témából",
|
|
|
|
|
reset_avatar: "eltávolította a saját képét",
|
|
|
|
|
topic: "témát kezelt",
|
2026-11-26 10:29:49 +00:00
|
|
|
};
|
|
|
|
|
|
2026-11-26 10:48:28 +00:00
|
|
|
type Props = { searchParams: Promise<{ nezet?: string }> };
|
|
|
|
|
|
|
|
|
|
/** Moderators: the open reports, and the log of every moderation step. */
|
|
|
|
|
export default async function ModerationPage({ searchParams }: Props) {
|
2026-11-26 13:02:38 +00:00
|
|
|
const view = (await searchParams).nezet;
|
|
|
|
|
const log = view === "naplo";
|
|
|
|
|
const topics = view === "temak";
|
2026-11-26 10:29:49 +00:00
|
|
|
return (
|
|
|
|
|
<div className="fh">
|
2026-11-26 10:48:28 +00:00
|
|
|
<h1 className="fpage-title">Moderálás</h1>
|
|
|
|
|
<nav className="fmod-tabs" aria-label="Moderálás">
|
2026-11-26 13:02:38 +00:00
|
|
|
<Link href="/forum/moderalas" aria-current={log || topics ? undefined : "page"}>
|
2026-11-26 10:48:28 +00:00
|
|
|
Jelentések
|
|
|
|
|
</Link>
|
2026-11-26 13:02:38 +00:00
|
|
|
<Link href="/forum/moderalas?nezet=temak" aria-current={topics ? "page" : undefined}>
|
|
|
|
|
Témák
|
|
|
|
|
</Link>
|
2026-11-26 10:48:28 +00:00
|
|
|
<Link href="/forum/moderalas?nezet=naplo" aria-current={log ? "page" : undefined}>
|
|
|
|
|
Napló
|
|
|
|
|
</Link>
|
|
|
|
|
</nav>
|
2026-11-26 13:02:38 +00:00
|
|
|
{log ? <LogView /> : topics ? <TopicsView /> : <ReportsView />}
|
2026-11-26 10:29:49 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-11-26 10:48:28 +00:00
|
|
|
|
|
|
|
|
async function ReportsView() {
|
|
|
|
|
const res = await forumGet<{ reports: ReportEntry[] }>("/v1/forum/mod/reports");
|
|
|
|
|
if (!res.ok) notFound();
|
|
|
|
|
return <ReportsList initial={res.data.reports} />;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-26 13:02:38 +00:00
|
|
|
async function TopicsView() {
|
|
|
|
|
const [requests, list, me] = await Promise.all([
|
|
|
|
|
forumGet<{ requests: TopicRequest[] }>("/v1/forum/mod/topic-requests"),
|
|
|
|
|
forumGet<{ topics: ForumTopic[] }>("/v1/forum/topics"),
|
|
|
|
|
getMe(),
|
|
|
|
|
]);
|
|
|
|
|
if (!requests.ok) notFound();
|
|
|
|
|
return (
|
|
|
|
|
<TopicsAdmin
|
|
|
|
|
requests={requests.data.requests}
|
|
|
|
|
topics={list.ok ? list.data.topics : []}
|
|
|
|
|
admin={me?.user.roles.includes("admin") ?? false}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-26 10:48:28 +00:00
|
|
|
async function LogView() {
|
|
|
|
|
const res = await forumGet<{ entries: ModLogEntry[] }>("/v1/forum/mod/log");
|
|
|
|
|
if (!res.ok) notFound();
|
|
|
|
|
if (res.data.entries.length === 0) return <p className="fh-card fh-empty">Még nem volt moderálás.</p>;
|
|
|
|
|
return (
|
|
|
|
|
<ul className="fh-card fh-flush fmodlog">
|
|
|
|
|
{res.data.entries.map((e) => (
|
|
|
|
|
<li key={e.id}>
|
|
|
|
|
<span className="hint">
|
|
|
|
|
{new Date(e.created_at).toLocaleString("hu-HU", { timeZone: "Europe/Budapest" })}
|
|
|
|
|
{e.actor_kind === "ai" && " · AI"}
|
|
|
|
|
</span>
|
|
|
|
|
<span>
|
|
|
|
|
<strong>{e.actor ?? "?"}</strong> {ACTIONS[e.action] ?? e.action}
|
|
|
|
|
{e.target && (
|
|
|
|
|
<>
|
|
|
|
|
{" "}
|
|
|
|
|
(<Link href={memberHref(e.target)}>{e.target}</Link>)
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{e.thread && (
|
|
|
|
|
<>
|
|
|
|
|
{": "}
|
|
|
|
|
<Link href={threadHref({ id: e.thread.id, slug: "" }, e.post_id ?? undefined)}>
|
|
|
|
|
{e.thread.title ?? `#${e.thread.id}`}
|
|
|
|
|
</Link>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{e.until && ` · ${banText(e.until)}`}
|
|
|
|
|
</span>
|
|
|
|
|
{e.reason && <span className="hint">Ok: {e.reason}</span>}
|
|
|
|
|
</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
);
|
|
|
|
|
}
|