2026-11-26 10:29:49 +00:00
|
|
|
import Link from "next/link";
|
|
|
|
|
import { notFound } from "next/navigation";
|
|
|
|
|
|
2026-11-26 10:48:28 +00:00
|
|
|
import { type ModLogEntry, type ReportEntry, banText, memberHref, threadHref } from "@/lib/forum";
|
2026-11-26 10:29:49 +00:00
|
|
|
import { forumGet } from "@/lib/forumServer";
|
|
|
|
|
|
2026-11-26 10:48:28 +00:00
|
|
|
import { ReportsList } from "./ReportsList";
|
|
|
|
|
|
|
|
|
|
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 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) {
|
|
|
|
|
const log = (await searchParams).nezet === "naplo";
|
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">
|
|
|
|
|
<Link href="/forum/moderalas" aria-current={log ? undefined : "page"}>
|
|
|
|
|
Jelentések
|
|
|
|
|
</Link>
|
|
|
|
|
<Link href="/forum/moderalas?nezet=naplo" aria-current={log ? "page" : undefined}>
|
|
|
|
|
Napló
|
|
|
|
|
</Link>
|
|
|
|
|
</nav>
|
|
|
|
|
{log ? <LogView /> : <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} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|