diff --git a/web-next/app/[locale]/forum/topic/[topicId]/page.tsx b/web-next/app/[locale]/forum/topic/[topicId]/page.tsx index 827c18b..6c316be 100644 --- a/web-next/app/[locale]/forum/topic/[topicId]/page.tsx +++ b/web-next/app/[locale]/forum/topic/[topicId]/page.tsx @@ -101,7 +101,12 @@ export default async function TopicPage({ {author?.name ?? `#${post.poster}`}
- +

diff --git a/web-next/lib/forum.ts b/web-next/lib/forum.ts index e8d1913..c752936 100644 --- a/web-next/lib/forum.ts +++ b/web-next/lib/forum.ts @@ -85,6 +85,16 @@ export interface PosterInfo { isStaff: boolean joindate: string | null postCount: number + avatar: string +} + +// Avatar por clase (FusionCMS) del personaje de más nivel de la cuenta. Solo clases +// jugables en WotLK 3.4.3 (1..9 y 11). Sin personaje → guerrero por defecto. +const AVATAR_DIR = '/forum/avatars' +const AVATAR_CLASSES = new Set([1, 2, 3, 4, 5, 6, 7, 8, 9, 11]) +function avatarForClass(classId: number | undefined): string { + const c = classId && AVATAR_CLASSES.has(classId) ? classId : 1 + return `${AVATAR_DIR}/class-${c}.gif` } /** Nivel GM mínimo para considerarse «staff» en el foro (badge y color). */ @@ -362,6 +372,23 @@ export async function resolvePosters(ids: number[]): Promise '?').join(',') + + // Clase del personaje de más nivel de cada cuenta (para el avatar). Se tolera que + // acore_characters no exista o esté vacía: el avatar cae a guerrero por defecto. + const classByAccount = new Map() + try { + const [chars] = await db(DB.characters).query( + `SELECT account, class FROM characters WHERE account IN (${placeholders}) ORDER BY level DESC, guid ASC`, + unique, + ) + for (const c of chars) { + const acc = Number(c.account) + if (!classByAccount.has(acc)) classByAccount.set(acc, Number(c.class)) + } + } catch { + /* sin personajes: avatar por defecto */ + } + try { const [accs] = await db(DB.auth).query( `SELECT id, username, joindate FROM account WHERE id IN (${placeholders})`, @@ -383,6 +410,7 @@ export async function resolvePosters(ids: number[]): Promise= STAFF_GMLEVEL, joindate: a.joindate ? new Date(a.joindate).toISOString() : null, postCount: 0, + avatar: avatarForClass(classByAccount.get(Number(a.id))), }) } } catch { @@ -391,7 +419,15 @@ export async function resolvePosters(ids: number[]): Promise