mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
fix(federation): 🐛 Fix fetching of ActivityPub users not working anymore
This commit is contained in:
parent
0e054e7cba
commit
42ff591e48
12 changed files with 2182 additions and 8 deletions
|
|
@ -139,7 +139,12 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
proxy: config.http.proxy.address,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
if (
|
||||
!(
|
||||
response.ok &&
|
||||
response.headers.get("content-type")?.includes("json")
|
||||
)
|
||||
) {
|
||||
// If the server doesn't have a Lysand well-known endpoint, it's not a Lysand instance
|
||||
// Try to resolve ActivityPub metadata instead
|
||||
const data = await Instance.fetchActivityPubMetadata(url);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import type {
|
|||
Mention as ApiMention,
|
||||
} from "@lysand-org/client/types";
|
||||
import { EntityValidator } from "@lysand-org/federation";
|
||||
import type { FederationRequester } from "@lysand-org/federation/requester";
|
||||
import type { Entity, User as LysandUser } from "@lysand-org/federation/types";
|
||||
import {
|
||||
type InferInsertModel,
|
||||
|
|
@ -198,6 +199,20 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
|||
);
|
||||
}
|
||||
|
||||
static async webFinger(
|
||||
manager: FederationRequester,
|
||||
username: string,
|
||||
): Promise<string> {
|
||||
return (
|
||||
(await manager.webFinger(username).catch(() => null)) ??
|
||||
(await manager.webFinger(
|
||||
username,
|
||||
manager.url.hostname,
|
||||
"application/activity+json",
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
static async getCount() {
|
||||
return (
|
||||
await db
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue