diff --git a/packages/backend/src/remote/activitypub/db-resolver.ts b/packages/backend/src/remote/activitypub/db-resolver.ts index d8aa3b706..02b0c2cd5 100644 --- a/packages/backend/src/remote/activitypub/db-resolver.ts +++ b/packages/backend/src/remote/activitypub/db-resolver.ts @@ -19,6 +19,9 @@ import type { IObject } from "./type.js"; import { getApId } from "./type.js"; import { resolvePerson, updatePerson } from "./models/person.js"; import {redisClient, subscriber} from "@/db/redis.js"; +import { remoteLogger } from "@/remote/logger.js"; + +const logger = remoteLogger.createSubLogger("db-resolver"); const publicKeyCache = new Cache("publicKey", 60 * 30); const publicKeyByUserIdCache = new Cache( @@ -188,7 +191,21 @@ export default class DbResolver { user: CacheableRemoteUser; key: UserPublickey | null; } | null> { - const user = (await resolvePerson(uri)) as CacheableRemoteUser; + let user: CacheableRemoteUser; + + try { + user = (await resolvePerson(uri)) as CacheableRemoteUser; + } + catch (e: any) { + // Bypass GoToSocial issue #1186 (ref: https://github.com/superseriousbusiness/gotosocial/issues/1186) + if (e.message === 'invalid Actor: wrong inbox' && uri.match(/https?:\/\/[a-zA-Z0-9-.]+\/users\/[a-zA-Z0-9_]+\/main-key$/)) { + logger.warn(`Failed to resolve ${uri}, re-attempting without trailing /main-key`); + user = (await resolvePerson(uri.substring(0, uri.length - 9))) as CacheableRemoteUser; + } + else { + throw e; + } + } if (user == null) return null;