mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 08:53:48 +01:00
[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
@ -19,6 +19,9 @@ import type { IObject } from "./type.js";
|
|||||||
import { getApId } from "./type.js";
|
import { getApId } from "./type.js";
|
||||||
import { resolvePerson, updatePerson } from "./models/person.js";
|
import { resolvePerson, updatePerson } from "./models/person.js";
|
||||||
import {redisClient, subscriber} from "@/db/redis.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 publicKeyCache = new Cache<UserPublickey | null>("publicKey", 60 * 30);
|
||||||
const publicKeyByUserIdCache = new Cache<UserPublickey | null>(
|
const publicKeyByUserIdCache = new Cache<UserPublickey | null>(
|
||||||
@ -188,7 +191,21 @@ export default class DbResolver {
|
|||||||
user: CacheableRemoteUser;
|
user: CacheableRemoteUser;
|
||||||
key: UserPublickey | null;
|
key: UserPublickey | null;
|
||||||
} | 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;
|
if (user == null) return null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user