From 8eee3b19c633a7716e9bfc937b4d43941fdae5b3 Mon Sep 17 00:00:00 2001 From: Christomatt Date: Mon, 26 Jan 2026 12:10:46 +0100 Subject: [PATCH] feat(users): Add remote placeholder refresh logic to user profile endpoint - Add detection for remote placeholder users (handles containing @) - Implement fresh data fetching from remote when placeholder is detected - Refactor conditional logic to treat stale placeholders as missing users - Only return 404 error if user is genuinely not found, not for refresh attempts - Improves data freshness for federated user profiles by re-fetching from source --- src/app/api/users/[handle]/route.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/api/users/[handle]/route.ts b/src/app/api/users/[handle]/route.ts index a9dd311..731a3ff 100644 --- a/src/app/api/users/[handle]/route.ts +++ b/src/app/api/users/[handle]/route.ts @@ -88,7 +88,10 @@ export async function GET(request: Request, context: RouteContext) { where: eq(users.handle, cleanHandle), }); - if (!user) { + // If user exists but is a remote placeholder (handle contains @), fetch fresh data from remote + const isRemotePlaceholder = user && cleanHandle.includes('@'); + + if (!user || isRemotePlaceholder) { if (remoteHandle && remoteDomain) { // Try Swarm API first (for Synapsis nodes) const swarmData = await fetchSwarmProfile(remoteHandle, remoteDomain); @@ -157,7 +160,10 @@ export async function GET(request: Request, context: RouteContext) { }); } } - return NextResponse.json({ error: 'User not found' }, { status: 404 }); + // Only return 404 if this wasn't a remote placeholder we were trying to refresh + if (!isRemotePlaceholder) { + return NextResponse.json({ error: 'User not found' }, { status: 404 }); + } } if (user.isSuspended) { return NextResponse.json({ error: 'User not found' }, { status: 404 });