fix(forum): complete member profiles — counts, avatars, strip AI metadata

This commit is contained in:
2026-06-26 23:46:59 +00:00
parent 4acc068732
commit eb05918960
7 changed files with 133 additions and 81 deletions

View File

@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { createClient } from '@/lib/supabase/server';
import { attachAuthorUsernames, buildAuthorUsernameMap } from '@/lib/forum/authorUsernames';
export async function GET(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
@@ -30,7 +31,13 @@ export async function GET(req: NextRequest, { params }: { params: Promise<{ id:
if (repliesError) throw repliesError;
return NextResponse.json({ thread, replies: replies || [] });
const usernameMap = await buildAuthorUsernameMap(supabase);
const [threadWithUsername] = attachAuthorUsernames([thread], usernameMap);
return NextResponse.json({
thread: threadWithUsername,
replies: attachAuthorUsernames(replies, usernameMap),
});
} catch (err: any) {
return NextResponse.json({ error: err.message }, { status: 500 });
}

View File

@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { createClient } from '@/lib/supabase/server';
import { ensureForumProfile } from '@/lib/forum/profile';
import { attachAuthorUsernames, buildAuthorUsernameMap } from '@/lib/forum/authorUsernames';
export async function GET(req: NextRequest) {
try {
@@ -50,7 +51,13 @@ export async function GET(req: NextRequest) {
const { data, error, count } = await query;
if (error) throw error;
return NextResponse.json({ threads: data, total: count, page, limit });
const usernameMap = await buildAuthorUsernameMap(supabase);
return NextResponse.json({
threads: attachAuthorUsernames(data, usernameMap),
total: count,
page,
limit,
});
} catch (err: any) {
return NextResponse.json({ error: err.message }, { status: 500 });
}