[backend] Fix initial federation initiated by GoToSocial in secure mode
This bypasses GoToSocial issue #1186 (ref: https://github.com/superseriousbusiness/gotosocial/issues/1186)
This commit is contained in:
parent
89ab890331
commit
496454cf1f
1 changed files with 18 additions and 1 deletions
|
@ -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<UserPublickey | null>("publicKey", 60 * 30);
|
||||
const publicKeyByUserIdCache = new Cache<UserPublickey | null>(
|
||||
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue