Forum: reports for moderators and private messages by request

Any logged-in user can report a post, or a private message received; a
possible crisis shows the helplines at once. Moderators get the open
reports (crisis first) with what was reported, remove or close them, and
every step goes to the log; the operator gets a Telegram notice of each
new report (kind and link only). Private conversations start with a
request and a short introduction (from the Kereső rank, a few a day); the
recipient accepts, declines silently or blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-26 10:48:28 +00:00
co-authored by Claude Opus 5.5
parent 36b38525c3
commit 4def9569b1
28 changed files with 2322 additions and 58 deletions
@@ -22,7 +22,7 @@ function usePresence(member: boolean) {
}, [member]);
}
function Icon({ name }: { name: "forum" | "followed" | "new" | "profile" }) {
function Icon({ name }: { name: "forum" | "followed" | "new" | "messages" | "profile" }) {
return (
<svg viewBox="0 0 24 24" aria-hidden="true" className="fn-icon">
{name === "forum" && (
@@ -43,6 +43,12 @@ function Icon({ name }: { name: "forum" | "followed" | "new" | "profile" }) {
<path d="M12 8v8M8 12h8" />
</>
)}
{name === "messages" && (
<>
<rect x="3" y="5.5" width="18" height="13" rx="2" />
<path d="M3.5 7l8.5 6 8.5-6" />
</>
)}
{name === "profile" && (
<>
<circle cx="12" cy="8" r="4" />
@@ -57,7 +63,17 @@ function Icon({ name }: { name: "forum" | "followed" | "new" | "profile" }) {
* The forum's own menu: a bar at the bottom of the screen on phones, tabs
* above the content on wider screens. `unread`: new replies in followed threads.
*/
export function ForumNav({ member, loggedIn, unread }: { member: string | null; loggedIn: boolean; unread: number }) {
export function ForumNav({
member,
loggedIn,
unread,
messages,
}: {
member: string | null;
loggedIn: boolean;
unread: number;
messages: number;
}) {
const path = usePathname();
usePresence(member !== null);
const items = [
@@ -80,6 +96,17 @@ export function ForumNav({ member, loggedIn, unread }: { member: string | null;
icon: "new" as const,
current: path.startsWith("/forum/uj"),
},
{
href: member
? "/forum/uzenetek"
: loggedIn
? "/forum/beallitasok?vissza=/forum/uzenetek"
: "/belepes?vissza=/forum/uzenetek",
label: "Üzenetek",
icon: "messages" as const,
current: path.startsWith("/forum/uzenetek"),
badge: messages,
},
{
href: member
? `/forum/tag/${encodeURIComponent(member)}`
@@ -0,0 +1,99 @@
"use client";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
import { REPORT_KINDS, type ReportKind } from "@/lib/forum";
/** What to do when someone may be in danger: shown right after a crisis report. */
export function CrisisHelp() {
return (
<p className="frep-crisis" role="note">
Ha azonnali veszélyt látsz, hívd a <strong>112</strong>-t. A lelki elsősegély-szolgálat ingyenes, éjjel-nappal
hívható száma: <strong>116-123</strong>.
</p>
);
}
/**
* "Jelentés" on a post or a private message: what the problem is, an
* optional note, and a thank-you (with the helpline for a crisis report).
*/
export function ReportButton({ path, className = "fp-tool" }: { path: string; className?: string }) {
const [open, setOpen] = useState(false);
const [kind, setKind] = useState<ReportKind | "">("");
const [note, setNote] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [done, setDone] = useState<{ crisis: boolean } | null>(null);
async function submit(e: React.FormEvent) {
e.preventDefault();
if (!kind) return;
setBusy(true);
setError(null);
try {
const res = await api<{ crisis: boolean }>(path, { body: { kind, note } });
setDone(res);
} catch (err) {
setError(errorText(err));
} finally {
setBusy(false);
}
}
if (done) {
return (
<div className="frep" role="status">
<p>Köszönjük, a moderátorok megnézik.</p>
{done.crisis && <CrisisHelp />}
</div>
);
}
if (!open) {
return (
<button type="button" className={className} onClick={() => setOpen(true)}>
Jelentés
</button>
);
}
return (
<form className="frep" onSubmit={submit}>
<fieldset className="fnew-set">
<legend>Mi a gond?</legend>
{REPORT_KINDS.map((k) => (
<label key={k.kind} className="frep-kind">
<input type="radio" name="report-kind" checked={kind === k.kind} onChange={() => setKind(k.kind)} />
<span>{k.label}</span>
</label>
))}
</fieldset>
{kind === "crisis" && <CrisisHelp />}
<label className="sr-only" htmlFor={`${path}-note`}>
Megjegyzés
</label>
<textarea
id={`${path}-note`}
className="fc-text"
rows={2}
maxLength={500}
value={note}
onChange={(e) => setNote(e.target.value)}
placeholder={kind === "other" ? "Írd le röviden, mi a gond." : "Megjegyzés (nem kötelező)"}
/>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<div className="fc-actions">
<button type="button" className="btn btn-ghost btn-sm" onClick={() => setOpen(false)}>
Mégse
</button>
<button type="submit" className="btn btn-primary btn-sm" disabled={busy || !kind}>
{busy ? "Küldés…" : "Jelentés küldése"}
</button>
</div>
</form>
);
}
@@ -10,6 +10,7 @@ import { AuthorLine, signsText } from "./AuthorLine";
import { Avatar } from "./Avatar";
import { Composer } from "./Composer";
import { PostBody } from "./PostBody";
import { ReportButton } from "./ReportButton";
/** How often the open thread looks for new replies (while the page is in front). */
const POLL_MS = 30_000;
@@ -294,6 +295,7 @@ function PostCard({
Törlés
</button>
)}
{viewer.logged_in && !post.own && <ReportButton path={`/forum/posts/${post.id}/report`} />}
{viewer.moderator && !post.own && (
<button type="button" className="fp-tool fp-tool-mod" onClick={() => actions.remove(post)}>
Eltávolítás