From c0d7ecf5c30aa882fb3b6e0658129343c66d85b8 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 14 Oct 2023 17:16:21 +0200 Subject: [PATCH] [backend] Actually resolve with objectHost --- packages/backend/src/remote/resolve-user.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index 576b89c91..442bd5b7b 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -179,15 +179,17 @@ export async function resolveUser( export async function resolveMentionWithFallback(username: string, host: string | null, objectHost: string | null, cache: IMentionedRemoteUsers): Promise { let fallback = `${config.url}/@${username}`; - if (host !== null) fallback += `@${host}`; - else if (objectHost !== null) fallback += `@${objectHost}`; + if (host !== null && host !== config.domain) + fallback += `@${host}`; + else if (objectHost !== null && objectHost !== config.domain && host !== config.domain) + fallback += `@${objectHost}`; const cached = cache.find(r => r.username.toLowerCase() === username.toLowerCase() && r.host === host); if (cached) return cached.url ?? cached.uri; - if (host === null || host === config.domain) return fallback; + if ((host === null && objectHost === null) || host === config.domain) return fallback; try { - const user = await resolveUser(username, host, false); + const user = await resolveUser(username, host ?? objectHost, false); const profile = await UserProfiles.findOneBy({ userId: user.id }); return profile?.url ?? user.uri ?? fallback; }