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:
@@ -445,3 +445,56 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
|
||||
.fmodlog { list-style: none; margin: 0; }
|
||||
.fmodlog li { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; }
|
||||
.fmodlog li + li { border-top: 1px solid var(--line); }
|
||||
|
||||
/* --- reports --- */
|
||||
.frep { flex-basis: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 6px; padding: 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); }
|
||||
.frep-kind { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; cursor: pointer; }
|
||||
.frep-kind input { accent-color: var(--gold); width: 18px; height: 18px; flex: none; }
|
||||
.frep-crisis { padding: 10px 12px; border-radius: 10px; background: var(--f-blue-tint); color: var(--ink); font-size: 15px; line-height: 1.45; }
|
||||
.frep-crisis strong { color: var(--harmonic); }
|
||||
.forum-modchip {
|
||||
display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px;
|
||||
background: var(--f-red-tint); border: 1px solid var(--danger); color: var(--danger); font-size: 14px; font-weight: 600;
|
||||
text-decoration: none; white-space: nowrap;
|
||||
}
|
||||
.forum-modchip:hover { color: var(--danger); background: var(--f-tint); }
|
||||
@media (max-width: 759px) { .forum-bar { flex-wrap: wrap; } .forum-modchip { order: 3; } }
|
||||
|
||||
/* --- moderation page --- */
|
||||
.fmod-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); align-self: flex-start; }
|
||||
.fmod-tabs a { min-height: 40px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
|
||||
.fmod-tabs a[aria-current="page"] { background: var(--f-tint-strong); color: var(--gold); }
|
||||
.fmod-report { display: flex; flex-direction: column; gap: 10px; }
|
||||
.fmod-crisis { border-color: var(--harmonic); box-shadow: 0 0 0 1px var(--harmonic); }
|
||||
.fmod-report-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
|
||||
.fmod-note { color: var(--ink-2); font-style: italic; }
|
||||
.fmod-target { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
|
||||
.fmod-target .fp-body { font-size: 15px; }
|
||||
.fmod-chat { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
|
||||
.fmod-chat-reported { padding: 4px 8px; border-radius: 6px; background: var(--f-red-tint); }
|
||||
|
||||
/* --- private messages --- */
|
||||
.fmsg-h { font-family: var(--font-body) !important; font-size: 16px; font-weight: 600; color: var(--ink-2); }
|
||||
.fmsg-request { display: flex; flex-direction: column; gap: 12px; }
|
||||
.fmsg-intro { font-style: italic; color: var(--ink-2); }
|
||||
.fmsg-actions { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.ft-row.fmsg-row { display: flex; }
|
||||
.fmsg-when { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 13px; color: var(--muted); flex: none; }
|
||||
.freq { display: flex; flex-direction: column; gap: 8px; align-self: stretch; }
|
||||
.freq label { font-size: 14px; font-weight: 500; }
|
||||
.fchat { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 820px; margin: 0 auto; }
|
||||
.fchat-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
|
||||
.fchat-who { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; flex: 1; min-width: 0; }
|
||||
.fchat-intro { font-size: 15px; color: var(--ink-2); font-style: italic; }
|
||||
.fchat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
|
||||
.fchat-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 86%; }
|
||||
.fchat-mine { align-self: flex-end; align-items: flex-end; }
|
||||
.fchat-bubble { padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--panel); border: 1px solid var(--line); }
|
||||
.fchat-mine .fchat-bubble { border-radius: 16px 16px 4px 16px; background: var(--f-tint-strong); border-color: transparent; }
|
||||
.fchat-bubble .fp-body { font-size: 16px; line-height: 1.5; }
|
||||
.fchat-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
|
||||
.fchat-report { min-height: 32px; padding: 0 6px; border: 0; background: none; color: var(--muted); font: 400 12px var(--font-body); cursor: pointer; }
|
||||
.fchat-report:hover { color: var(--danger); }
|
||||
.fchat-msg .frep { width: min(420px, 86vw); }
|
||||
.fchat-compose { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
|
||||
@media (min-width: 760px) { .forum-nav .fn-item { padding: 0 12px; } }
|
||||
|
||||
@@ -6,7 +6,7 @@ import { notFound } from "next/navigation";
|
||||
import { ForumNav } from "@/components/forum/ForumNav";
|
||||
import { ThemeToggle } from "@/components/forum/ThemeToggle";
|
||||
import { PublicHeader } from "@/components/SiteHeader";
|
||||
import { FORUM_THEME_COOKIE, type ForumTheme, type ForumViewer } from "@/lib/forum";
|
||||
import { FORUM_THEME_COOKIE, type ForumNavData, type ForumTheme } from "@/lib/forum";
|
||||
import { forumEnabled, forumGet } from "@/lib/forumServer";
|
||||
|
||||
import "./forum.css";
|
||||
@@ -23,10 +23,7 @@ export const metadata: Metadata = {
|
||||
*/
|
||||
export default async function ForumLayout({ children }: { children: React.ReactNode }) {
|
||||
if (!forumEnabled()) notFound();
|
||||
const [nav, jar] = await Promise.all([
|
||||
forumGet<{ viewer: ForumViewer; followed: { new_replies: number } | null }>("/v1/forum/nav"),
|
||||
cookies(),
|
||||
]);
|
||||
const [nav, jar] = await Promise.all([forumGet<ForumNavData>("/v1/forum/nav"), cookies()]);
|
||||
const viewer = nav.ok ? nav.data.viewer : null;
|
||||
const theme: ForumTheme = jar.get(FORUM_THEME_COOKIE)?.value === "dark" ? "dark" : "light";
|
||||
return (
|
||||
@@ -42,7 +39,13 @@ export default async function ForumLayout({ children }: { children: React.ReactN
|
||||
member={viewer?.member?.nickname ?? null}
|
||||
loggedIn={viewer?.logged_in ?? false}
|
||||
unread={nav.ok ? (nav.data.followed?.new_replies ?? 0) : 0}
|
||||
messages={nav.ok ? (nav.data.messages ?? 0) : 0}
|
||||
/>
|
||||
{nav.ok && nav.data.reports ? (
|
||||
<Link href="/forum/moderalas" className="forum-modchip">
|
||||
Jelentés: {nav.data.reports}
|
||||
</Link>
|
||||
) : null}
|
||||
<ThemeToggle initial={theme} />
|
||||
</div>
|
||||
<main className="forum-main">{children}</main>
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { PostBody } from "@/components/forum/PostBody";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import { REPORT_KINDS, type ReportEntry, ago, memberHref, threadHref } from "@/lib/forum";
|
||||
|
||||
const STATUS: Record<string, string> = { resolved: "Lezárva", dismissed: "Alaptalan" };
|
||||
|
||||
/** The reports: open ones first (a possible crisis on top), with what was reported and the actions. */
|
||||
export function ReportsList({ initial }: { initial: ReportEntry[] }) {
|
||||
const router = useRouter();
|
||||
const [busy, setBusy] = useState<number | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const open = initial.filter((r) => r.status === "open");
|
||||
const handled = initial.filter((r) => r.status !== "open");
|
||||
|
||||
async function act(r: ReportEntry, work: () => Promise<unknown>) {
|
||||
setBusy(r.id);
|
||||
setError(null);
|
||||
try {
|
||||
await work();
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
} finally {
|
||||
setBusy(null);
|
||||
}
|
||||
}
|
||||
|
||||
function removePost(r: ReportEntry) {
|
||||
if (r.target?.type !== "post") return;
|
||||
const reason = window.prompt("Miért távolítod el? Az indoklás a hozzászólás helyén látszik.");
|
||||
if (!reason) return;
|
||||
const id = r.target.id;
|
||||
void act(r, () => api(`/forum/posts/${id}`, { method: "DELETE", body: { reason } }));
|
||||
}
|
||||
|
||||
const card = (r: ReportEntry) => {
|
||||
const kind = REPORT_KINDS.find((k) => k.kind === r.kind)?.label ?? r.kind;
|
||||
const t = r.target;
|
||||
return (
|
||||
<article
|
||||
key={r.id}
|
||||
className={
|
||||
r.kind === "crisis" && r.status === "open" ? "fh-card fmod-report fmod-crisis" : "fh-card fmod-report"
|
||||
}
|
||||
>
|
||||
<div className="fmod-report-head">
|
||||
<strong>{kind}</strong>
|
||||
<span className="hint">
|
||||
{r.reporter} ·{" "}
|
||||
<time suppressHydrationWarning dateTime={r.created_at}>
|
||||
{ago(r.created_at)}
|
||||
</time>
|
||||
{r.open_reports_of_target > 1 && r.status === "open" && ` · ${r.open_reports_of_target} jelentés`}
|
||||
</span>
|
||||
</div>
|
||||
{r.note && <p className="fmod-note">„{r.note}”</p>}
|
||||
{r.kind === "crisis" && r.status === "open" && (
|
||||
<p className="hint warn">
|
||||
Lehet, hogy valaki bajban van. Ha a hozzászólás közvetlen veszélyre utal, ne csak moderálj: írj neki
|
||||
kedvesen, és mutasd meg a 116-123-as lelki elsősegély-számot.
|
||||
</p>
|
||||
)}
|
||||
{t?.type === "post" && (
|
||||
<div className="fmod-target">
|
||||
<span className="hint">
|
||||
Hozzászólás:{" "}
|
||||
{t.author ? <Link href={memberHref(t.author.nickname)}>{t.author.nickname}</Link> : "törölt tag"} ·{" "}
|
||||
<Link href={threadHref(t.thread, t.id)}>{t.thread.title}</Link>
|
||||
{t.deleted && " · már eltávolítva"}
|
||||
</span>
|
||||
<PostBody text={t.body} />
|
||||
</div>
|
||||
)}
|
||||
{t?.type === "message" && (
|
||||
<div className="fmod-target">
|
||||
<span className="hint">Privát üzenet, az előzményeivel (csak a jelentés miatt látod):</span>
|
||||
<ol className="fmod-chat">
|
||||
{t.messages.map((m) => (
|
||||
<li key={m.id} className={m.reported ? "fmod-chat-reported" : undefined}>
|
||||
<strong>{m.sender?.nickname ?? "Törölt tag"}:</strong> {m.body}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
)}
|
||||
{r.status === "open" ? (
|
||||
<div className="fmsg-actions">
|
||||
{t?.type === "post" && !t.deleted && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-danger"
|
||||
disabled={busy === r.id}
|
||||
onClick={() => removePost(r)}
|
||||
>
|
||||
Eltávolítás
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm"
|
||||
disabled={busy === r.id}
|
||||
onClick={() => act(r, () => api(`/forum/mod/reports/${r.id}`, { body: { action: "resolve" } }))}
|
||||
>
|
||||
Kezeltem, lezárom
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-ghost"
|
||||
disabled={busy === r.id}
|
||||
onClick={() => act(r, () => api(`/forum/mod/reports/${r.id}`, { body: { action: "dismiss" } }))}
|
||||
>
|
||||
Alaptalan
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<p className="hint">
|
||||
{STATUS[r.status]}
|
||||
{r.handled_by && ` · ${r.handled_by}`}
|
||||
</p>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<section className="fh-section" aria-labelledby="fmod-open">
|
||||
<h2 id="fmod-open" className="fmsg-h">
|
||||
Nyitott jelentések ({open.length})
|
||||
</h2>
|
||||
{open.length === 0 ? <p className="fh-card fh-empty">Nincs nyitott jelentés.</p> : open.map(card)}
|
||||
</section>
|
||||
{handled.length > 0 && (
|
||||
<section className="fh-section" aria-labelledby="fmod-done">
|
||||
<h2 id="fmod-done" className="fmsg-h">
|
||||
Az elmúlt 30 nap lezárt jelentései
|
||||
</h2>
|
||||
{handled.map(card)}
|
||||
</section>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { type ModLogEntry, banText, memberHref, threadHref } from "@/lib/forum";
|
||||
import { type ModLogEntry, type ReportEntry, banText, memberHref, threadHref } from "@/lib/forum";
|
||||
import { forumGet } from "@/lib/forumServer";
|
||||
|
||||
export const metadata = { title: "Moderálási napló", robots: { index: false } };
|
||||
import { ReportsList } from "./ReportsList";
|
||||
|
||||
export const metadata = { title: "Moderálás", robots: { index: false } };
|
||||
|
||||
const ACTIONS: Record<string, string> = {
|
||||
delete_post: "hozzászólást távolított el",
|
||||
@@ -17,48 +19,70 @@ const ACTIONS: Record<string, string> = {
|
||||
unlock: "feloldotta a szálat",
|
||||
pin: "kitűzte a szálat",
|
||||
unpin: "levette a kitűzést",
|
||||
resolve_report: "lezárt egy jelentést",
|
||||
dismiss_report: "alaptalannak ítélt egy jelentést",
|
||||
};
|
||||
|
||||
/** Every moderation step: who, what, why (moderators only). */
|
||||
export default async function ModLogPage() {
|
||||
const res = await forumGet<{ entries: ModLogEntry[] }>("/v1/forum/mod/log");
|
||||
if (!res.ok) notFound();
|
||||
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";
|
||||
return (
|
||||
<div className="fh">
|
||||
<h1 className="fpage-title">Moderálási napló</h1>
|
||||
{res.data.entries.length === 0 ? (
|
||||
<p className="fh-card fh-empty">Még nem volt moderálás.</p>
|
||||
) : (
|
||||
<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>
|
||||
)}
|
||||
<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 />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ export default async function ForumHomePage() {
|
||||
)}
|
||||
{viewer.moderator && (
|
||||
<Link href="/forum/moderalas" className="fh-side-link o-8">
|
||||
Moderálási napló
|
||||
Moderálás: jelentések és napló
|
||||
</Link>
|
||||
)}
|
||||
</aside>
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import type { MemberRelation } from "@/lib/forum";
|
||||
|
||||
const INTRO_MAX = 200;
|
||||
|
||||
/**
|
||||
* Starting a private conversation from a profile: a request with a short
|
||||
* introduction. Shows instead where things stand (sent, open, waiting for
|
||||
* the viewer's answer), or why the viewer cannot start one yet.
|
||||
*/
|
||||
export function RequestPanel({ nickname, relation }: { nickname: string; relation: MemberRelation }) {
|
||||
const router = useRouter();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [intro, setIntro] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const id = relation.conversation_id;
|
||||
|
||||
if (relation.state === "accepted" && id) {
|
||||
return (
|
||||
<Link href={`/forum/uzenetek/${id}`} className="btn btn-sm">
|
||||
Üzenetek
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
if (relation.state === "incoming" && id) {
|
||||
return (
|
||||
<Link href={`/forum/uzenetek/${id}`} className="btn btn-sm btn-primary">
|
||||
Beszélgetni szeretne veled: válaszolj
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
if (relation.state === "outgoing") return <p className="hint">Beszélgetési kérésed elküldve, válaszra vár.</p>;
|
||||
if (relation.state === "blocked_by_me")
|
||||
return <p className="hint">Letiltottad. A tiltást az üzeneteidnél oldhatod fel.</p>;
|
||||
if (!relation.eligible) {
|
||||
return <p className="hint">Beszélgetést a Kereső rangtól kezdeményezhetsz, ha már írtál a fórumba.</p>;
|
||||
}
|
||||
if (!relation.can_request) return null;
|
||||
|
||||
async function submit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const res = await api<{ id: number }>("/forum/conversations", { body: { to: nickname, intro } });
|
||||
router.push(`/forum/uzenetek/${res.id}`);
|
||||
router.refresh();
|
||||
} catch (err) {
|
||||
setError(errorText(err));
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
return (
|
||||
<button type="button" className="btn btn-sm" onClick={() => setOpen(true)}>
|
||||
Beszélgetést kezdeményezek
|
||||
</button>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<form className="freq" onSubmit={submit}>
|
||||
<label htmlFor="freq-intro">Pár szó magadról és arról, miért írnál neki</label>
|
||||
<textarea
|
||||
id="freq-intro"
|
||||
className="fc-text"
|
||||
rows={3}
|
||||
maxLength={INTRO_MAX}
|
||||
value={intro}
|
||||
onChange={(e) => setIntro(e.target.value)}
|
||||
placeholder="Szia! Olvastam a hozzászólásodat a…"
|
||||
/>
|
||||
<span className="hint">
|
||||
{intro.length}/{INTRO_MAX} · link nélkül. Ha elfogadja, beszélgethettek; ha nem, erről nem kapsz értesítést.
|
||||
</span>
|
||||
{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 || intro.trim().length < 3}>
|
||||
{busy ? "Küldés…" : "Kérés küldése"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { type MemberProfile, ago, banText, threadHref } from "@/lib/forum";
|
||||
import { forumGet } from "@/lib/forumServer";
|
||||
|
||||
import { BanPanel } from "./BanPanel";
|
||||
import { RequestPanel } from "./RequestPanel";
|
||||
|
||||
type Props = { params: Promise<{ nev: string }> };
|
||||
|
||||
@@ -60,6 +61,7 @@ export default async function MemberPage({ params }: Props) {
|
||||
Eltiltva ({banText(member.banned_until)}).{member.ban_reason && ` Indok: ${member.ban_reason}`}
|
||||
</p>
|
||||
)}
|
||||
{res.data.relation && <RequestPanel nickname={a.nickname} relation={res.data.relation} />}
|
||||
{member.own && (
|
||||
<Link href="/forum/beallitasok" className="btn btn-sm">
|
||||
Profil szerkesztése
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { AuthorLine } from "@/components/forum/AuthorLine";
|
||||
import { Avatar } from "@/components/forum/Avatar";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import { type ConversationItem, ago } from "@/lib/forum";
|
||||
|
||||
export function Conversations({ initial }: { initial: ConversationItem[] }) {
|
||||
const router = useRouter();
|
||||
const [items, setItems] = useState(initial);
|
||||
const [busy, setBusy] = useState<number | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
async function answer(c: ConversationItem, action: "accept" | "decline" | "block" | "unblock") {
|
||||
setBusy(c.id);
|
||||
setError(null);
|
||||
try {
|
||||
await api(`/forum/conversations/${c.id}/${action === "unblock" ? "block" : action}`, {
|
||||
method: action === "unblock" ? "DELETE" : "POST",
|
||||
});
|
||||
if (action === "accept") {
|
||||
router.push(`/forum/uzenetek/${c.id}`);
|
||||
router.refresh();
|
||||
return;
|
||||
}
|
||||
setItems((list) => list.filter((x) => x.id !== c.id));
|
||||
router.refresh();
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
} finally {
|
||||
setBusy(null);
|
||||
}
|
||||
}
|
||||
|
||||
const incoming = items.filter((c) => c.state === "incoming");
|
||||
const open = items.filter((c) => c.state === "accepted");
|
||||
const sent = items.filter((c) => c.state === "outgoing" || c.state === "expired");
|
||||
const blocked = items.filter((c) => c.state === "blocked_by_me");
|
||||
|
||||
return (
|
||||
<>
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{incoming.length > 0 && (
|
||||
<section className="fh-section" aria-labelledby="fmsg-in">
|
||||
<h2 id="fmsg-in" className="fmsg-h">
|
||||
Kérések
|
||||
</h2>
|
||||
{incoming.map((c) => (
|
||||
<article key={c.id} className="fh-card fmsg-request">
|
||||
<AuthorLine author={c.other} time={c.created_at} />
|
||||
<p className="fmsg-intro">„{c.intro}”</p>
|
||||
<div className="fmsg-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-sm"
|
||||
disabled={busy === c.id}
|
||||
onClick={() => answer(c, "accept")}
|
||||
>
|
||||
Elfogadom
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm"
|
||||
disabled={busy === c.id}
|
||||
onClick={() => answer(c, "decline")}
|
||||
>
|
||||
Nem most
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-ghost btn-sm"
|
||||
disabled={busy === c.id}
|
||||
onClick={() => window.confirm("Letiltod? Nem küldhet neked több kérést.") && answer(c, "block")}
|
||||
>
|
||||
Letiltom
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="fh-section" aria-labelledby="fmsg-open">
|
||||
<h2 id="fmsg-open" className="fmsg-h">
|
||||
Beszélgetések
|
||||
</h2>
|
||||
{open.length === 0 ? (
|
||||
<p className="fh-card fh-empty">
|
||||
Még nincs beszélgetésed. Egy tag profilján kezdeményezhetsz egyet, ha már elérted a Kereső rangot.
|
||||
</p>
|
||||
) : (
|
||||
<ul className="fh-card fh-flush ft-list">
|
||||
{open.map((c) => (
|
||||
<li key={c.id}>
|
||||
<Link href={`/forum/uzenetek/${c.id}`} className="ft-row fmsg-row">
|
||||
<Avatar avatar={c.other?.avatar} size={40} online={c.other?.online} />
|
||||
<span className="ft-main">
|
||||
<span className="ft-title">{c.other?.nickname ?? "Törölt tag"}</span>
|
||||
<span className="ft-excerpt">
|
||||
{c.last_message
|
||||
? `${c.last_message.mine ? "Te: " : ""}${c.last_message.excerpt}`
|
||||
: "Még nincs üzenet."}
|
||||
</span>
|
||||
</span>
|
||||
<span className="fmsg-when">
|
||||
{c.last_message_at && (
|
||||
<time suppressHydrationWarning dateTime={c.last_message_at}>
|
||||
{ago(c.last_message_at)}
|
||||
</time>
|
||||
)}
|
||||
{c.unread > 0 && <span className="ft-new">{c.unread} új</span>}
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{sent.length > 0 && (
|
||||
<section className="fh-section" aria-labelledby="fmsg-sent">
|
||||
<h2 id="fmsg-sent" className="fmsg-h">
|
||||
Elküldött kérések
|
||||
</h2>
|
||||
<ul className="fh-card fh-flush ft-list">
|
||||
{sent.map((c) => (
|
||||
<li key={c.id} className="ft-row fmsg-row">
|
||||
<Avatar avatar={c.other?.avatar} size={32} />
|
||||
<span className="ft-main">
|
||||
<span className="ft-title">{c.other?.nickname ?? "Törölt tag"}</span>
|
||||
<span className="ft-excerpt">„{c.intro}”</span>
|
||||
</span>
|
||||
<span className="hint">{c.state === "expired" ? "Lejárt" : "Válaszra vár"}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{blocked.length > 0 && (
|
||||
<section className="fh-section" aria-labelledby="fmsg-blocked">
|
||||
<h2 id="fmsg-blocked" className="fmsg-h">
|
||||
Letiltottak
|
||||
</h2>
|
||||
<ul className="fh-card fh-flush ft-list">
|
||||
{blocked.map((c) => (
|
||||
<li key={c.id} className="ft-row fmsg-row">
|
||||
<Avatar avatar={c.other?.avatar} size={32} />
|
||||
<span className="ft-main">
|
||||
<span className="ft-title">{c.other?.nickname ?? "Törölt tag"}</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm"
|
||||
disabled={busy === c.id}
|
||||
onClick={() => answer(c, "unblock")}
|
||||
>
|
||||
Tiltás feloldása
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
|
||||
import { Avatar } from "@/components/forum/Avatar";
|
||||
import { Composer } from "@/components/forum/Composer";
|
||||
import { PostBody } from "@/components/forum/PostBody";
|
||||
import { ReportButton } from "@/components/forum/ReportButton";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import { type ChatMessage, type ConversationPage, memberHref } from "@/lib/forum";
|
||||
|
||||
/** How often an open conversation looks for new messages (while in front). */
|
||||
const POLL_MS = 15_000;
|
||||
|
||||
function when(iso: string) {
|
||||
return new Date(iso).toLocaleString("hu-HU", {
|
||||
timeZone: "Europe/Budapest",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
}
|
||||
|
||||
/** One private conversation: the request (to answer, or waiting), then the messages. */
|
||||
export function Chat({ initial }: { initial: ConversationPage }) {
|
||||
const router = useRouter();
|
||||
const [page, setPage] = useState(initial);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const bottom = useRef<HTMLDivElement>(null);
|
||||
const { conversation: c, messages } = page;
|
||||
const base = `/forum/conversations/${c.id}`;
|
||||
const lastId = messages.length ? messages[messages.length - 1].id : 0;
|
||||
const other = c.other?.nickname ?? "Törölt tag";
|
||||
|
||||
useEffect(() => {
|
||||
if (lastId) api(`${base}/read`, { body: { message_id: lastId } }).catch(() => {});
|
||||
bottom.current?.scrollIntoView({ block: "end" });
|
||||
}, [base, lastId]);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
try {
|
||||
setPage(await api<ConversationPage>(base));
|
||||
} catch {
|
||||
/* retried on the next round */
|
||||
}
|
||||
}, [base]);
|
||||
|
||||
useEffect(() => {
|
||||
if (c.state !== "accepted") return;
|
||||
const timer = window.setInterval(() => {
|
||||
if (document.visibilityState === "visible") void refresh();
|
||||
}, POLL_MS);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [c.state, refresh]);
|
||||
|
||||
async function run(work: () => Promise<unknown>) {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
await work();
|
||||
return true;
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
return false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function send(text: string) {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const msg = await api<ChatMessage>(`${base}/messages`, { body: { body: text } });
|
||||
setPage((p) => ({ ...p, messages: [...p.messages, msg] }));
|
||||
return true;
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
return false;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function answer(action: "accept" | "decline" | "block" | "unblock") {
|
||||
const ok = await run(() =>
|
||||
api(`${base}/${action === "unblock" ? "block" : action}`, { method: action === "unblock" ? "DELETE" : "POST" }),
|
||||
);
|
||||
if (!ok) return;
|
||||
if (action === "decline") {
|
||||
router.push("/forum/uzenetek");
|
||||
router.refresh();
|
||||
return;
|
||||
}
|
||||
await refresh();
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fchat">
|
||||
<nav className="forum-crumbs" aria-label="Morzsamenü">
|
||||
<Link href="/forum/uzenetek">Üzenetek</Link>
|
||||
</nav>
|
||||
<header className="fchat-head">
|
||||
<Avatar avatar={c.other?.avatar} size={44} online={c.other?.online} />
|
||||
<div className="fchat-who">
|
||||
{c.other ? (
|
||||
<Link href={memberHref(c.other.nickname)} className="fa-name">
|
||||
{other}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="fa-name muted">{other}</span>
|
||||
)}
|
||||
{c.other && <span className="fa-rank">{c.other.rank_name}</span>}
|
||||
</div>
|
||||
{c.state === "accepted" && (
|
||||
<details className="ftv-mod">
|
||||
<summary className="btn btn-sm btn-ghost">Továbbiak</summary>
|
||||
<div className="ftv-mod-menu">
|
||||
<button
|
||||
type="button"
|
||||
className="danger"
|
||||
onClick={() => window.confirm(`Letiltod ${other} tagot? Nem írhat neked többet.`) && answer("block")}
|
||||
>
|
||||
Letiltás
|
||||
</button>
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<p className="fchat-intro">
|
||||
<span className="hint">{c.requested_by_me ? "A kérésed" : `${other} kérése`}:</span> „{c.intro}”
|
||||
</p>
|
||||
|
||||
{c.state === "incoming" && (
|
||||
<div className="fh-card fmsg-request">
|
||||
<p>{other} szeretne beszélgetni veled.</p>
|
||||
<div className="fmsg-actions">
|
||||
<button type="button" className="btn btn-primary btn-sm" disabled={busy} onClick={() => answer("accept")}>
|
||||
Elfogadom
|
||||
</button>
|
||||
<button type="button" className="btn btn-sm" disabled={busy} onClick={() => answer("decline")}>
|
||||
Nem most
|
||||
</button>
|
||||
<button type="button" className="btn btn-ghost btn-sm" disabled={busy} onClick={() => answer("block")}>
|
||||
Letiltom
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{(c.state === "outgoing" || c.state === "expired") && (
|
||||
<p className="fh-card fh-empty">
|
||||
{c.state === "expired"
|
||||
? "A kérésedre nem jött válasz, és lejárt."
|
||||
: `A kérésedet elküldtük. Ha ${other} elfogadja, itt tudtok beszélgetni.`}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{messages.length > 0 && (
|
||||
<ol className="fchat-list">
|
||||
{messages.map((m) => (
|
||||
<li key={m.id} className={m.mine ? "fchat-msg fchat-mine" : "fchat-msg"}>
|
||||
<div className="fchat-bubble">
|
||||
<PostBody text={m.body} />
|
||||
</div>
|
||||
<span className="fchat-meta">
|
||||
<time suppressHydrationWarning dateTime={m.created_at}>
|
||||
{when(m.created_at)}
|
||||
</time>
|
||||
{!m.mine && <ReportButton path={`/forum/messages/${m.id}/report`} className="fchat-report" />}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
)}
|
||||
<div ref={bottom} />
|
||||
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{c.state === "accepted" && (
|
||||
<div className="fchat-compose">
|
||||
<Composer id="uzenet" label="Üzeneted" placeholder="Írj üzenetet…" rows={2} busy={busy} onSubmit={send} />
|
||||
<p className="hint">
|
||||
Csak szöveg és emoji. A linkek nem kattinthatók. A moderátorok csak jelentett üzenetet látnak.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{c.state === "blocked_by_me" && (
|
||||
<div className="fh-card">
|
||||
<p>Letiltottad. Nem írhat neked, és te sem neki.</p>
|
||||
<button type="button" className="btn btn-sm" disabled={busy} onClick={() => answer("unblock")}>
|
||||
Tiltás feloldása
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
|
||||
import type { ConversationPage } from "@/lib/forum";
|
||||
import { forumGet } from "@/lib/forumServer";
|
||||
|
||||
import { Chat } from "./Chat";
|
||||
|
||||
export const metadata = { title: "Beszélgetés", robots: { index: false } };
|
||||
|
||||
type Props = { params: Promise<{ id: string }> };
|
||||
|
||||
export default async function ConversationView({ params }: Props) {
|
||||
const { id } = await params;
|
||||
if (!/^\d{1,15}$/.test(id)) notFound();
|
||||
const res = await forumGet<ConversationPage>(`/v1/forum/conversations/${id}`);
|
||||
if (!res.ok) {
|
||||
if (res.status === 401) redirect(`/belepes?vissza=/forum/uzenetek/${id}`);
|
||||
notFound();
|
||||
}
|
||||
return <Chat initial={res.data} />;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import type { ConversationItem } from "@/lib/forum";
|
||||
import { forumGet } from "@/lib/forumServer";
|
||||
|
||||
import { Conversations } from "./Conversations";
|
||||
|
||||
export const metadata = { title: "Üzenetek", robots: { index: false } };
|
||||
|
||||
/** Private messages: requests to answer, conversations, requests sent. */
|
||||
export default async function MessagesPage() {
|
||||
const res = await forumGet<{ conversations: ConversationItem[] }>("/v1/forum/conversations");
|
||||
if (!res.ok) redirect("/belepes?vissza=/forum/uzenetek");
|
||||
return (
|
||||
<div className="fh fmsg-page">
|
||||
<h1 className="fpage-title">Üzenetek</h1>
|
||||
<p className="muted">
|
||||
Privát beszélgetés csak kéréssel indulhat. A kérést elfogadhatod, csendben elutasíthatod (a küldő ezt nem
|
||||
látja), vagy letilthatod a küldőt.
|
||||
</p>
|
||||
<Conversations initial={res.data.conversations} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -142,6 +142,7 @@ export interface ForumMe {
|
||||
|
||||
export interface MemberProfile {
|
||||
viewer: ForumViewer;
|
||||
relation: MemberRelation | null;
|
||||
member: {
|
||||
author: ForumAuthor;
|
||||
bio: string;
|
||||
@@ -257,3 +258,91 @@ export function banText(until: string | null): string {
|
||||
if (until === "infinity") return "véglegesen";
|
||||
return `eddig: ${new Date(until).toLocaleString("hu-HU", { timeZone: "Europe/Budapest", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" })}`;
|
||||
}
|
||||
|
||||
/** The viewer's relation to a member (profile page). */
|
||||
export interface MemberRelation {
|
||||
conversation_id: number | null;
|
||||
state: ConversationState | null;
|
||||
can_request: boolean;
|
||||
eligible: boolean;
|
||||
}
|
||||
|
||||
export type ConversationState = "accepted" | "incoming" | "outgoing" | "expired" | "blocked_by_me" | "closed";
|
||||
|
||||
export interface ConversationItem {
|
||||
id: number;
|
||||
other: ForumAuthor | null;
|
||||
state: ConversationState;
|
||||
intro: string;
|
||||
created_at: string;
|
||||
last_message_at: string | null;
|
||||
last_message: { excerpt: string; mine: boolean } | null;
|
||||
unread: number;
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
id: number;
|
||||
mine: boolean;
|
||||
body: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ConversationPage {
|
||||
viewer: ForumViewer;
|
||||
conversation: {
|
||||
id: number;
|
||||
other: ForumAuthor | null;
|
||||
state: ConversationState;
|
||||
intro: string;
|
||||
requested_by_me: boolean;
|
||||
created_at: string;
|
||||
};
|
||||
messages: ChatMessage[];
|
||||
}
|
||||
|
||||
export type ReportKind = "spam" | "ad" | "rude" | "crisis" | "illegal" | "other";
|
||||
|
||||
export const REPORT_KINDS: { kind: ReportKind; label: string }[] = [
|
||||
{ kind: "rude", label: "Bántó, kioktató vagy sértő" },
|
||||
{ kind: "ad", label: "Szolgáltatást hirdet (jóslás, gyógyítás, tanfolyam)" },
|
||||
{ kind: "spam", label: "Kéretlen reklám, spam" },
|
||||
{ kind: "crisis", label: "Aggódom érte: lelki krízisben lehet" },
|
||||
{ kind: "illegal", label: "Jogsértő tartalom" },
|
||||
{ kind: "other", label: "Más (írd le)" },
|
||||
];
|
||||
|
||||
export interface ReportEntry {
|
||||
id: number;
|
||||
kind: ReportKind;
|
||||
note: string;
|
||||
reporter: string;
|
||||
status: "open" | "resolved" | "dismissed";
|
||||
handled_by: string | null;
|
||||
handled_at: string | null;
|
||||
created_at: string;
|
||||
open_reports_of_target: number;
|
||||
target:
|
||||
| {
|
||||
type: "post";
|
||||
id: number;
|
||||
thread: { id: number; title: string; slug: string };
|
||||
author: ForumAuthor | null;
|
||||
body: string;
|
||||
deleted: boolean;
|
||||
}
|
||||
| {
|
||||
type: "message";
|
||||
id: number;
|
||||
conversation_id: number | null;
|
||||
messages: { id: number; sender: ForumAuthor | null; body: string; created_at: string; reported: boolean }[];
|
||||
}
|
||||
| null;
|
||||
}
|
||||
|
||||
/** The forum menu's counts. */
|
||||
export interface ForumNavData {
|
||||
viewer: ForumViewer;
|
||||
followed: { new_replies: number } | null;
|
||||
messages: number | null;
|
||||
reports: number | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user