From b04619e00761ec3b861e615b4f9344d6f734a832 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 11 Sep 2023 22:58:02 +0200 Subject: [PATCH] Skip mention user lookup for local users --- packages/backend/src/remote/resolve-user.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index 22d7cb462..0411aae93 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -193,16 +193,17 @@ export async function getSubjectHostFromUriAndUsernameCached(uri: string, userna const hostname = new URL(uri).hostname; username = username.substring(1); // remove leading @ from username + if (hostname === config.hostname) { + // user is local, return local account domain + return config.domain; + } + const user = await Users.findOneBy({ usernameLower: username.toLowerCase(), host: hostname }); - if (user) { - return user.host; - } - - return await uriHostCache.fetch(uri, async () => await getSubjectHostFromUri(uri) ?? hostname); + return user ? user.host : await uriHostCache.fetch(uri, async () => await getSubjectHostFromUri(uri) ?? hostname); } export async function getSubjectHostFromAcct(acct: string): Promise {