Forum: search, muting members, archived topics, the public threads in the sitemap

- Search (/forum/kereses, the magnifier in the forum bar): thread titles
  and posts the viewer may read, Hungarian stems and word beginnings
  without accents ("alvas" finds "alvásban"), one result per thread with
  the matching words marked.
- Muting a member (post menu, profile; the list in the settings): their
  threads leave the lists, their posts fold up, their replies and mentions
  no longer count or send e-mails. They are not told.
- The admin archives a topic (Moderálás → Témák): it stays readable but
  takes no new threads or replies, and folds away on the front page.
- The public topics and threads are in the sitemap; the forum's own pages
  are kept from robots.
- A reply e-mail goes to the one answered, also on the second level.
- Migration 0043 also prepares charts attached to a forum question.

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 14:31:05 +00:00
co-authored by Claude Opus 5.5
parent 4800a30e6d
commit 9ca3f478be
30 changed files with 879 additions and 105 deletions
@@ -60,13 +60,24 @@ export default async function TopicPageView({ params, searchParams }: Props) {
: "Zárt kör: ezt a témát csak a jóváhagyott tagjai látják."}
</p>
)}
{topic.archived && (
<p className="ftopic-private">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="3.5" y="4.5" width="17" height="4.5" rx="1" />
<path d="M5 9v9.5a1.5 1.5 0 0 0 1.5 1.5h11a1.5 1.5 0 0 0 1.5-1.5V9M10 13h4" />
</svg>
Archivált téma: a szálak olvashatók, de új szál és hozzászólás már nem írható.
</p>
)}
</div>
<Link
href={viewer.logged_in ? `/forum/uj?tema=${topic.slug}` : `/belepes?vissza=/forum/uj?tema=${topic.slug}`}
className="btn btn-primary"
>
Új szál
</Link>
{!topic.archived && (
<Link
href={viewer.logged_in ? `/forum/uj?tema=${topic.slug}` : `/belepes?vissza=/forum/uj?tema=${topic.slug}`}
className="btn btn-primary"
>
Új szál
</Link>
)}
</header>
{threads.length === 0 ? (
<p className="fh-card fh-empty">Ebben a témában még nincs szál. Nyisd meg te az elsőt!</p>
@@ -0,0 +1,46 @@
"use client";
import { useEffect, useState } from "react";
import { Avatar } from "@/components/forum/Avatar";
import { api } from "@/lib/api";
import type { ForumAuthor } from "@/lib/forum";
/** The members the viewer muted, each with "Feloldás". */
export function MutedList() {
const [muted, setMuted] = useState<ForumAuthor[] | null>(null);
useEffect(() => {
api<{ muted: ForumAuthor[] }>("/forum/me/mutes")
.then((res) => setMuted(res.muted))
.catch(() => setMuted([]));
}, []);
if (!muted || muted.length === 0) return null;
return (
<fieldset className="fnew-set">
<legend>Elnémított tagok</legend>
<ul className="fmuted">
{muted.map((m) => (
<li key={m.nickname}>
<span className="fh-online-item">
<Avatar avatar={m.avatar} size={28} />
{m.nickname}
</span>
<button
type="button"
className="btn btn-sm btn-ghost"
onClick={async () => {
await api(`/forum/members/${encodeURIComponent(m.nickname)}/mute`, { method: "DELETE" });
setMuted((list) => (list ?? []).filter((x) => x.nickname !== m.nickname));
}}
>
Feloldás
</button>
</li>
))}
</ul>
<span className="hint">
Az elnémított tagok szálai nem jelennek meg a listáidban, és nem kapsz értesítést tőlük.
</span>
</fieldset>
);
}
@@ -9,6 +9,8 @@ import { api, errorText } from "@/lib/api";
import { withEmoji } from "@/lib/emoticons";
import { type ChartShare, type EmailSettings, type ForumMe, banText, memberHref } from "@/lib/forum";
import { MutedList } from "./MutedList";
const SHARE_LEVELS: { value: ChartShare; label: string }[] = [
{ value: "none", label: "Semmit" },
{ value: "sun", label: "Csak a Nap-jegyemet" },
@@ -347,6 +349,8 @@ export function ProfileForm({ me, back }: { me: ForumMe; back: string | null })
</span>
</fieldset>
{member && <MutedList />}
{member && (
<div className="fprof-rank">
<span className="eyebrow">Rangod</span>
+27
View File
@@ -86,6 +86,8 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.forum-theme:hover { color: var(--gold); border-color: var(--f-border-hover); }
.forum-theme svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.forum-theme-label { display: none; }
.forum-tools { display: flex; align-items: center; gap: 8px; }
.forum-search { padding: 0; width: 44px; }
/* The forum's menu: a bar at the bottom on phones, tabs in the forum bar on wider screens. */
.forum-nav {
@@ -121,6 +123,7 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.fn-item[aria-current="page"] { background: var(--f-tint); }
.fn-icon { width: 20px; height: 20px; }
.forum-theme { padding: 0 14px; }
.forum-search { padding: 0; }
.forum-theme-label { display: inline; }
}
@@ -660,3 +663,27 @@ a.fh-online-item:hover { color: var(--gold); }
/* The same row at the foot of a card, or framed inside one. */
.fh-link-foot { margin: 14px -18px -18px; border-top: 1px solid var(--line); border-radius: 0 0 16px 16px; }
.fh-link-boxed { min-height: 52px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
/* --- search --- */
.fsearch-form { display: flex; gap: 8px; }
.fsearch-form .inp { flex: 1; min-width: 0; }
.fsearch-results { list-style: none; margin: 0; padding: 0; }
.fsearch-results li + li { border-top: 1px solid var(--line); }
.fsearch-hit { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; color: var(--ink); text-decoration: none; }
.fsearch-hit:hover { background: var(--f-hover); }
.fsearch-title { font-size: 17px; font-weight: 600; }
.fsearch-meta { font-size: 13px; color: var(--muted); }
.fsearch-snippet { font-size: 15px; color: var(--ink-2); }
.fsearch-snippet mark { background: var(--f-tint-strong); color: var(--ink); border-radius: 3px; padding: 0 2px; }
/* --- muted members --- */
.fp-muted { padding: 4px 0; }
.fmute { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fmuted { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fmuted li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* --- archived topics --- */
.fh-archived { margin-top: 10px; }
.fh-archived summary { min-height: 44px; display: flex; align-items: center; color: var(--ink-2); font-size: 15px; cursor: pointer; }
.fh-archived .fh-links { list-style: none; margin: 0; padding: 0; }
.fh-archived li + li .fh-link { border-top: 1px solid var(--line); }
@@ -0,0 +1,103 @@
import type { Metadata } from "next";
import Link from "next/link";
import { ago, threadHref } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
export const metadata: Metadata = { title: "Keresés a fórumban", robots: { index: false, follow: true } };
interface SearchResult {
thread: { id: number; title: string; slug: string };
topic: { slug: string; name: string };
author: { nickname: string } | null;
last_post_at: string;
reply_count: number;
post_id: number | null;
/** The matching words between ⟦ and ⟧. */
snippet: string | null;
}
/** The words the search found, marked. */
function Marked({ text }: { text: string }) {
return (
<>
{text
.split(/(⟦[^⟧]*⟧)/)
.map((part, i) =>
part.startsWith("⟦") ? <mark key={i}>{part.slice(1, -1)}</mark> : <span key={i}>{part}</span>,
)}
</>
);
}
/** Search in the threads and posts the visitor may read. */
export default async function SearchPage({ searchParams }: { searchParams: Promise<{ q?: string; oldal?: string }> }) {
const params = await searchParams;
const q = (params.q ?? "").trim();
const page = Math.max(1, Number(params.oldal) || 1);
const res =
q.length >= 2
? await forumGet<{ results: SearchResult[]; more: boolean }>(
`/v1/forum/search?q=${encodeURIComponent(q)}&page=${page}`,
)
: null;
const results = res?.ok ? res.data.results : [];
const more = res?.ok ? res.data.more : false;
const link = (p: number) => `/forum/kereses?q=${encodeURIComponent(q)}&oldal=${p}`;
return (
<div className="fh">
<h1 className="fpage-title">Keresés</h1>
<form className="fsearch-form" action="/forum/kereses" role="search">
<label htmlFor="fsearch-q" className="sr-only">
Mit keresel?
</label>
<input
id="fsearch-q"
name="q"
type="search"
className="inp"
defaultValue={q}
placeholder="Mit keresel? Például: alvás, telihold, gyász"
minLength={2}
maxLength={100}
autoFocus={!q}
/>
<button type="submit" className="btn btn-primary">
Keresés
</button>
</form>
{q.length >= 2 &&
(results.length === 0 ? (
<p className="fh-card fh-empty">Erre nincs találat. Próbáld más szóval, vagy rövidebben.</p>
) : (
<ul className="fh-card fh-flush fsearch-results">
{results.map((r) => (
<li key={r.thread.id}>
<Link href={threadHref(r.thread, r.post_id ?? undefined)} className="fsearch-hit">
<span className="fsearch-title">{r.thread.title}</span>
<span className="fsearch-meta">
{r.topic.name} · {r.author?.nickname ?? "Törölt tag"} · {r.reply_count} válasz · utoljára{" "}
<time suppressHydrationWarning dateTime={r.last_post_at}>
{ago(r.last_post_at)}
</time>
</span>
{r.snippet && (
<span className="fsearch-snippet">
<Marked text={r.snippet} />
</span>
)}
</Link>
</li>
))}
</ul>
))}
{(page > 1 || more) && (
<nav className="forum-pager" aria-label="Lapozás">
{page > 1 ? <Link href={link(page - 1)}>‹ Előző</Link> : <span />}
<span className="hint">{page}. oldal</span>
{more ? <Link href={link(page + 1)}>Következő ›</Link> : <span />}
</nav>
)}
</div>
);
}
+9 -1
View File
@@ -48,7 +48,15 @@ export default async function ForumLayout({ children }: { children: React.ReactN
}}
wsUrl={process.env.FORUM_WS_URL || "/api/v1/forum/ws"}
/>
<ThemeToggle initial={theme} />
<div className="forum-tools">
<Link href="/forum/kereses" className="forum-theme forum-search" aria-label="Keresés a fórumban">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="11" cy="11" r="6.5" />
<path d="M16 16l4.5 4.5" />
</svg>
</Link>
<ThemeToggle initial={theme} />
</div>
</div>
<main className="forum-main">{children}</main>
</div>
@@ -145,7 +145,22 @@ export function TopicsAdmin({
<li key={t.slug} className="ftop-member">
<span>
<strong>{t.name}</strong> <span className="hint">· {VISIBILITY[t.visibility] ?? t.visibility}</span>
{t.archived && <span className="hint"> · archivált</span>}
</span>
<button
type="button"
className="btn btn-sm btn-ghost"
disabled={busy}
onClick={() =>
(t.archived ||
window.confirm(
`Archiválod a(z) „${t.name}” témát? A szálai olvashatók maradnak, de új szál és hozzászólás nem írható bele, és lekerül a főoldalról.`,
)) &&
act(() => api(`/forum/topics/${t.slug}`, { method: "PATCH", body: { archived: !t.archived } }))
}
>
{t.archived ? "Visszaállítás" : "Archiválás"}
</button>
<select
className="inp ftop-vis"
aria-label={`${t.name} láthatósága`}
+84 -58
View File
@@ -173,73 +173,99 @@ export default async function ForumHomePage() {
<h2 id="fh-topics">Témák</h2>
</div>
<ul className="fh-card fh-flush fh-topics">
{topics.map((t) =>
t.visibility === "restricted" && !t.readable ? (
<li key={t.slug}>
<div className="fh-topic fh-topic-closed">
<span className="fh-topic-icon">
<TopicIcon slug={t.slug} />
</span>
<span className="fh-topic-text">
<span className="fh-topic-name">
{t.name}
<svg viewBox="0 0 24 24" className="fh-lock" role="img" aria-label="Zárt téma">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
{topics
.filter((t) => !t.archived)
.map((t) =>
t.visibility === "restricted" && !t.readable ? (
<li key={t.slug}>
<div className="fh-topic fh-topic-closed">
<span className="fh-topic-icon">
<TopicIcon slug={t.slug} />
</span>
<span className="fh-topic-desc">{t.description}</span>
<span className="fh-topic-last">Zárt kör: jóváhagyás után olvasható</span>
</span>
{viewer.member && <JoinTopic slug={t.slug} pending={t.membership === "pending"} />}
</div>
</li>
) : (
<li key={t.slug}>
<Link
href={t.readable ? `/forum/${t.slug}` : `/belepes?vissza=/forum/${t.slug}`}
className="fh-topic"
>
<span className="fh-topic-icon">
<TopicIcon slug={t.slug} />
</span>
<span className="fh-topic-text">
<span className="fh-topic-name">
{t.name}
{t.visibility !== "public" && (
<svg viewBox="0 0 24 24" className="fh-lock" role="img" aria-label="Csak tagoknak">
<span className="fh-topic-text">
<span className="fh-topic-name">
{t.name}
<svg viewBox="0 0 24 24" className="fh-lock" role="img" aria-label="Zárt téma">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
)}
</span>
<span className="fh-topic-desc">{t.description}</span>
<span className="fh-topic-last">Zárt kör: jóváhagyás után olvasható</span>
</span>
<span className="fh-topic-desc">{t.description}</span>
{t.readable && t.last && (
<span className="fh-topic-last">
{t.last.author && (
<Avatar avatar={t.last.author.avatar} size={18} online={t.last.author.online} />
{viewer.member && <JoinTopic slug={t.slug} pending={t.membership === "pending"} />}
</div>
</li>
) : (
<li key={t.slug}>
<Link
href={t.readable ? `/forum/${t.slug}` : `/belepes?vissza=/forum/${t.slug}`}
className="fh-topic"
>
<span className="fh-topic-icon">
<TopicIcon slug={t.slug} />
</span>
<span className="fh-topic-text">
<span className="fh-topic-name">
{t.name}
{t.visibility !== "public" && (
<svg viewBox="0 0 24 24" className="fh-lock" role="img" aria-label="Csak tagoknak">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
)}
{t.last.author?.nickname ?? "Törölt tag"},{" "}
<time suppressHydrationWarning dateTime={t.last.at}>
{ago(t.last.at)}
</time>
</span>
<span className="fh-topic-desc">{t.description}</span>
{t.readable && t.last && (
<span className="fh-topic-last">
{t.last.author && (
<Avatar avatar={t.last.author.avatar} size={18} online={t.last.author.online} />
)}
{t.last.author?.nickname ?? "Törölt tag"},{" "}
<time suppressHydrationWarning dateTime={t.last.at}>
{ago(t.last.at)}
</time>
</span>
)}
{!t.readable && <span className="fh-topic-last">Belépés után olvasható</span>}
</span>
{t.readable && (
<span className="fh-topic-count">
<strong>{t.thread_count ?? 0}</strong> szál
</span>
)}
{!t.readable && <span className="fh-topic-last">Belépés után olvasható</span>}
</span>
{t.readable && (
<span className="fh-topic-count">
<strong>{t.thread_count ?? 0}</strong> szál
</span>
)}
{t.readable && t.new_count ? (
<span className="ft-new">{t.new_count > 99 ? "99+" : t.new_count} új</span>
) : null}
</Link>
</li>
),
)}
{t.readable && t.new_count ? (
<span className="ft-new">{t.new_count > 99 ? "99+" : t.new_count} új</span>
) : null}
</Link>
</li>
),
)}
</ul>
{topics.some((t) => t.archived) && (
<details className="fh-archived">
<summary>Archivált témák ({topics.filter((t) => t.archived).length})</summary>
<ul className="fh-card fh-flush fh-links">
{topics
.filter((t) => t.archived && t.readable)
.map((t) => (
<li key={t.slug}>
<Link href={`/forum/${t.slug}`} className="fh-link">
<span className="fh-link-text">
{t.name}
<span className="hint">
{t.description} · {t.thread_count ?? 0} szál
</span>
</span>
<span className="fh-link-arrow" aria-hidden="true">
›
</span>
</Link>
</li>
))}
</ul>
</details>
)}
</section>
</div>
@@ -0,0 +1,49 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
/** "Némítás" on a member's profile: their threads, posts and notices step out of the viewer's way. */
export function MuteButton({ nickname, muted }: { nickname: string; muted: boolean }) {
const router = useRouter();
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
return (
<div className="fmute">
<button
type="button"
className="btn btn-sm btn-ghost"
disabled={busy}
onClick={async () => {
if (
!muted &&
!window.confirm(
`Elnémítod ${nickname} tagot? A szálai eltűnnek a listáidból, a hozzászólásai összecsukva látszanak, és nem kapsz értesítést tőle. Ő erről nem tud.`,
)
)
return;
setBusy(true);
setError(null);
try {
await api(`/forum/members/${encodeURIComponent(nickname)}/mute`, { method: muted ? "DELETE" : "PUT" });
router.refresh();
} catch (e) {
setError(errorText(e));
} finally {
setBusy(false);
}
}}
>
{muted ? "Némítás feloldása" : "Némítás"}
</button>
{muted && <span className="hint">Elnémítottad: a szálai és az értesítései nem jelennek meg nálad.</span>}
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
</div>
);
}
@@ -10,6 +10,7 @@ import { type MemberProfile, ago, banText, threadHref } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
import { BanPanel } from "./BanPanel";
import { MuteButton } from "./MuteButton";
import { RequestPanel } from "./RequestPanel";
type Props = { params: Promise<{ nev: string }> };
@@ -70,6 +71,7 @@ export default async function MemberPage({ params }: Props) {
Profil szerkesztése
</Link>
)}
{viewer.member && !member.own && <MuteButton nickname={a.nickname} muted={member.muted} />}
{viewer.moderator && !member.own && !a.moderator && (
<BanPanel
nickname={a.nickname}
+1 -1
View File
@@ -18,7 +18,7 @@ export default async function NewThreadPage({ searchParams }: Props) {
const viewer = nav.ok ? nav.data.viewer : null;
if (!viewer?.logged_in) redirect(`/belepes?vissza=${encodeURIComponent(back)}`);
if (viewer.needs_nickname) redirect(`/forum/beallitasok?vissza=${encodeURIComponent(back)}`);
const topics = res.ok ? res.data.topics.filter((t) => t.readable) : [];
const topics = res.ok ? res.data.topics.filter((t) => t.readable && !t.archived) : [];
const initial = topics.find((t) => t.slug === tema)?.slug ?? topics[0]?.slug ?? "";
return (
<div className="fh">
+18 -1
View File
@@ -54,7 +54,24 @@ const AI_SEARCH = [
];
// Logged-in pages redirect anyway; shared links carry noindex.
const PRIVATE = ["/api/", "/admin", "/profil", "/kepletek", "/osszevetesek", "/szemelyek", "/szamlak"];
const PRIVATE = [
"/api/",
"/admin",
"/profil",
"/kepletek",
"/osszevetesek",
"/szemelyek",
"/szamlak",
// The forum's own pages (the topics and threads are open).
"/forum/beallitasok",
"/forum/uzenetek",
"/forum/valaszok",
"/forum/kovetett",
"/forum/moderalas",
"/forum/uj",
"/forum/kereses",
"/forum/leiratkozas",
];
export default async function robots(): Promise<MetadataRoute.Robots> {
return {
+16 -1
View File
@@ -2,6 +2,7 @@ import type { MetadataRoute } from "next";
import { ZODIAC } from "@/content/zodiac";
import { loadCelebrities } from "@/lib/celebrities";
import { forumEnabled, forumSitemap } from "@/lib/forumServer";
import { currentYear } from "@/lib/sky";
import { siteUrl } from "@/lib/share";
@@ -10,7 +11,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const base = await siteUrl();
const privacy = { languages: { hu: `${base}/adatvedelem`, en: `${base}/privacy` } };
// The sitemap still works when the backend does not answer.
const people = await loadCelebrities().catch(() => []);
const [people, forum] = await Promise.all([loadCelebrities().catch(() => []), forumSitemap()]);
const next = currentYear() + 1;
return [
{ url: `${base}/`, changeFrequency: "weekly", priority: 1 },
@@ -30,6 +31,20 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
changeFrequency: "monthly" as const,
priority: 0.6,
})),
// The forum's public topics and threads (the members-only ones are not listed).
...(forumEnabled() ? [{ url: `${base}/forum`, changeFrequency: "hourly" as const, priority: 0.8 }] : []),
...forum.topics.map((t) => ({
url: `${base}/forum/${t.slug}`,
lastModified: t.updated ?? undefined,
changeFrequency: "daily" as const,
priority: 0.6,
})),
...forum.threads.map((t) => ({
url: `${base}/forum/szal/${t.id}-${t.slug}`,
lastModified: t.updated,
changeFrequency: "weekly" as const,
priority: 0.5,
})),
{ url: `${base}/aszf`, changeFrequency: "yearly", priority: 0.2 },
{ url: `${base}/kapcsolat`, changeFrequency: "yearly", priority: 0.2 },
@@ -27,6 +27,8 @@ type Actions = {
remove: (post: ForumPost) => void;
restore: (post: ForumPost) => void;
helped: (post: ForumPost) => void;
/** Mute or unmute the post's author. */
mute: (post: ForumPost) => void;
};
function ReactionRow({
@@ -187,6 +189,7 @@ function PostCard({
const [reporting, setReporting] = useState(false);
const [menu, setMenu] = useState(false);
const [showCollapsed, setShowCollapsed] = useState(false);
const [showMuted, setShowMuted] = useState(false);
const { viewer, thread, access } = page;
const writer = viewer.member !== null && !viewer.member.banned;
const starter = post.author !== null && post.author.nickname === thread.author?.nickname;
@@ -208,6 +211,17 @@ function PostCard({
);
}
// A muted member's post folds up; one click shows it.
if (post.muted && !showMuted) {
return (
<article className={nested ? "fp fp-muted fp-nested" : "fp fp-muted"} id={`h${post.id}`}>
<button type="button" className="fp-collapsed" onClick={() => setShowMuted(true)}>
{author?.nickname ?? "Egy tag"} hozzászólása · elnémítottad · Megjelenítés
</button>
</article>
);
}
const menuItems: { label: string; run: () => void; danger?: boolean }[] = [];
if (!post.deleted) {
if (access?.is_thread_author && !post.is_opening && !post.own && writer) {
@@ -216,6 +230,11 @@ function PostCard({
if (post.own && writer && !thread.locked) menuItems.push({ label: "Szerkesztés", run: () => setEditing(true) });
if (post.own) menuItems.push({ label: "Törlés", run: () => actions.remove(post), danger: true });
if (viewer.logged_in && !post.own) menuItems.push({ label: "Jelentés", run: () => setReporting(true) });
if (viewer.member && !post.own && author && !post.system)
menuItems.push({
label: post.muted ? `${author.nickname} némításának feloldása` : `${author.nickname} némítása`,
run: () => actions.mute(post),
});
if (viewer.moderator && !post.own)
menuItems.push({ label: "Eltávolítás", run: () => actions.remove(post), danger: true });
} else if (viewer.moderator) {
@@ -515,6 +534,21 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
await api(`/forum/posts/${post.id}/restore`, { method: "POST" });
await reload();
}),
mute: (post) => {
const nickname = post.author?.nickname;
if (!nickname) return;
if (
!post.muted &&
!window.confirm(
`Elnémítod ${nickname} tagot? A szálai eltűnnek a listáidból, a hozzászólásai összecsukva látszanak, és nem kapsz értesítést tőle. Ő erről nem tud. A beállításoknál bármikor feloldhatod.`,
)
)
return;
void run(async () => {
await api(`/forum/members/${encodeURIComponent(nickname)}/mute`, { method: post.muted ? "DELETE" : "PUT" });
await reload();
});
},
helped: (post) =>
void run(async () => {
const updated = await api<ForumPost>(`/forum/posts/${post.id}/helped`, {
@@ -738,7 +772,11 @@ export function ThreadView({ initial }: { initial: ThreadPage }) {
) : viewer.member?.banned ? (
<p className="ftv-gate">Most nem írhatsz a fórumba.</p>
) : !access?.can_reply ? (
<p className="ftv-gate">Ez a szál le van zárva, új hozzászólás nem írható.</p>
<p className="ftv-gate">
{thread.topic.archived
? "Ez a téma archivált: olvasható, de új hozzászólás nem írható."
: "Ez a szál le van zárva, új hozzászólás nem írható."}
</p>
) : (
<>
<Composer
+8 -2
View File
@@ -42,6 +42,8 @@ export interface ForumTopic extends TopicRef {
description: string;
visibility: "public" | "members" | "restricted";
listening: boolean;
/** Archived: readable, but takes nothing new. */
archived?: boolean;
readable: boolean;
/** A restricted topic: the viewer's place in it. */
membership?: "none" | "pending" | "approved" | null;
@@ -84,7 +86,7 @@ export interface ForumHome {
export interface TopicPage {
viewer: ForumViewer;
topic: TopicRef & { description: string; visibility: string; listening: boolean };
topic: TopicRef & { description: string; visibility: string; listening: boolean; archived?: boolean };
threads: ThreadCard[];
page: number;
has_more: boolean;
@@ -113,6 +115,8 @@ export interface ForumPost {
system?: boolean;
/** The post this reply answered (it may sit on the same level). */
reply_to?: { id: number; nickname: string | null } | null;
/** The viewer muted the author: shown folded up. */
muted?: boolean;
}
export interface ThreadPage {
@@ -122,7 +126,7 @@ export interface ThreadPage {
slug: string;
title: string;
intent: "listen" | "advice" | null;
topic: TopicRef & { visibility: string; listening: boolean };
topic: TopicRef & { visibility: string; listening: boolean; archived?: boolean };
author: ForumAuthor | null;
created_at: string;
locked: boolean;
@@ -188,6 +192,8 @@ export interface MemberProfile {
thread_count: number;
last_seen: "online" | "day" | "week" | "earlier" | null;
own: boolean;
/** The viewer muted them. */
muted: boolean;
banned_until: string | null;
ban_reason: string | null;
};
+15
View File
@@ -27,3 +27,18 @@ export async function forumGet<T>(path: string): Promise<ForumResult<T>> {
if (!res.ok) throw new BackendError(res.status, `${path}: HTTP ${res.status}`);
return { ok: true, data: (await res.json()) as T };
}
/** The public forum pages for the sitemap (nothing when the forum is off or does not answer). */
export async function forumSitemap(): Promise<{
topics: { slug: string; updated: string | null }[];
threads: { id: number; slug: string; updated: string }[];
}> {
const empty = { topics: [], threads: [] };
if (!forumEnabled()) return empty;
try {
const res = await fetch(`${FORUM_URL}/v1/forum/sitemap`, { next: { revalidate: 3600 } });
return res.ok ? await res.json() : empty;
} catch {
return empty;
}
}