Foro: barra de acciones por publicación (me gusta, enlace, denuncia, marcador)

- Me gusta con contador y toggle (al volver a pulsar se retira).
- Copiar enlace (permalink al post con ancla #post-ID).
- Denunciar: modal con motivos (troleo, amenaza, spam, etc.) + detalle.
- Guardar en marcadores + popover de recordatorio (2h/mañana/3 días/más)
  y modal "Editar marcador" con nota y recordatorio (nota + remind_at en BD).
- Tablas acore_web: forum_post_like, forum_post_bookmark (+note,+remind_at), forum_post_report.
- APIs /api/forum/{like,bookmark,report,bookmark-reminder}, gated por sesión.
- Estilo oscuro+dorado de la web.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 08:30:57 +00:00
parent aaf106ef55
commit a73fe4d8d5
10 changed files with 776 additions and 3 deletions
@@ -10,6 +10,7 @@ import {
getAccountCharactersForForum,
getForumCharacterPick,
} from '@/lib/forum'
import { getPostsSocial, REPORT_REASONS } from '@/lib/forum-social'
import { formatForumDate } from '@/lib/forum-format'
import { localizeWowheadLinks } from '@/lib/forum-wowhead'
import { getSession } from '@/lib/session'
@@ -20,6 +21,7 @@ import { ForumBreadcrumb } from '@/components/ForumBreadcrumb'
import { Pagination } from '@/components/Pagination'
import { ReplyForm } from '@/components/ReplyForm'
import { ForumCharacterPicker } from '@/components/ForumCharacterPicker'
import { PostActions } from '@/components/PostActions'
import { EditPostForm } from '@/components/EditPostForm'
import { ForumModActions } from '@/components/ForumModActions'
import { WowheadRefresh } from '@/components/WowheadRefresh'
@@ -61,6 +63,32 @@ export default async function TopicPage({
await Promise.all(uniquePosters.map(async (pid) => [pid, await getUserPostCount(pid)] as const)),
)
const social = await getPostsSocial(posts.map((p) => p.id), session.accountId ?? 0)
const REASON_DESC: Record<string, string> = {
troll: t('rTrollDesc'), threat: t('rThreatDesc'), username: t('rUsernameDesc'),
offtopic: t('rOfftopicDesc'), inappropriate: t('rInappropriateDesc'), spam: t('rSpamDesc'),
violence: t('rViolenceDesc'), child: t('rChildDesc'), illegal: t('rIllegalDesc'),
}
const REASON_LABEL: Record<string, string> = {
troll: t('rTroll'), threat: t('rThreat'), username: t('rUsername'), offtopic: t('rOfftopic'),
inappropriate: t('rInappropriate'), spam: t('rSpam'), violence: t('rViolence'),
child: t('rChild'), illegal: t('rIllegal'),
}
const reportReasons = REPORT_REASONS.map((k) => ({ key: k, label: REASON_LABEL[k] || k, desc: REASON_DESC[k] || '' }))
const paLabels = {
like: t('like'), copyLink: t('copyLink'), copied: t('copied'), report: t('report'),
bookmark: t('bookmark'), bookmarked: t('bookmarked'), loginRequired: t('loginToPost'),
reportTitle: t('reportTitle'), reportIntro: t('reportIntro'), reportDetail: t('reportDetail'),
reportSubmit: t('reportSubmit'), reportSent: t('reportSent'),
reminderTitle: t('reminderTitle'), savedBookmark: t('savedBookmark'),
remind2h: t('remind2h'), remindTomorrow: t('remindTomorrow'), remind3days: t('remind3days'), remindMore: t('remindMore'),
editTitle: t('editBookmark'), notePlaceholder: t('notePlaceholder'), save: t('save'), cancel: t('cancel'),
remove: t('removeBookmark'), reminderLabel: t('reminderLabel'), rNone: t('rNone'),
rTomorrow: t('rmTomorrow'), rNextWeek: t('rmNextWeek'), rNextMonth: t('rmNextMonth'), rCustom: t('rmCustom'),
}
const paCanAct = Boolean(session.accountId)
const paLoginHref = `/${locale}/my-account`
const [forumChars, forumPick] = session.accountId
? await Promise.all([getAccountCharactersForForum(session.accountId), getForumCharacterPick(session.accountId)])
: [[], null]
@@ -110,7 +138,7 @@ export default async function TopicPage({
const author = posters.get(post.poster)
const isStaff = author?.isStaff ?? false
return (
<div key={post.id} className={`topic_post${isStaff ? ' isStaff' : ''}${post.deleted ? ' post_deleted' : ''}`}>
<div key={post.id} id={`post-${post.id}`} className={`topic_post${isStaff ? ' isStaff' : ''}${post.deleted ? ' post_deleted' : ''}`}>
<div className="left_side">
<div className="username_container">
<span className="username">
@@ -176,6 +204,22 @@ export default async function TopicPage({
<div className="right_side">
<div className="post_container" dangerouslySetInnerHTML={{ __html: post.text }} />
<ul className="post_controls">
<li className="pa-li">
<PostActions
postId={post.id}
permalink={`/${locale}/forum/topic/${id}#post-${post.id}`}
canAct={paCanAct}
loginHref={paLoginHref}
initialLikes={social.get(post.id)?.likes ?? 0}
initialLiked={social.get(post.id)?.liked ?? false}
initialBookmarked={social.get(post.id)?.bookmarked ?? false}
initialNote={social.get(post.id)?.note ?? ''}
initialRemindAt={social.get(post.id)?.remindAt ?? null}
locale={locale}
reasons={reportReasons}
labels={paLabels}
/>
</li>
<li className="post_date">{formatForumDate(post.time, locale)}</li>
{canEditPost(session, isMod, post.poster) && (
<li>