refactor(federation): ♻️ Correctly handle bridge requests and instance signatures in user inboxes

This commit is contained in:
Jesse Wierzbinski 2024-11-23 23:02:18 +01:00
parent afc5a74a40
commit ace6921447
No known key found for this signature in database
8 changed files with 2310 additions and 36 deletions

View file

@ -319,6 +319,18 @@ export class Instance extends BaseInterface<typeof Instances> {
}
}
public static resolveFromHost(host: string): Promise<Instance> {
if (host.startsWith("http")) {
const url = new URL(host).host;
return Instance.resolve(url);
}
const url = new URL(`https://${host}`);
return Instance.resolve(url.origin);
}
public static async resolve(url: string): Promise<Instance> {
const logger = getLogger("federation");
const host = new URL(url).host;
@ -346,6 +358,7 @@ export class Instance extends BaseInterface<typeof Instances> {
version: metadata.software.version,
logo: metadata.logo,
protocol,
publicKey: metadata.public_key,
});
}