mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(federation): 🐛 Fix fetching of ActivityPub users not working anymore
This commit is contained in:
parent
0e054e7cba
commit
42ff591e48
|
|
@ -323,7 +323,7 @@ export const parseTextMentions = async (
|
||||||
signatureConstructor,
|
signatureConstructor,
|
||||||
);
|
);
|
||||||
|
|
||||||
const uri = await manager.webFinger(person?.[1] ?? "");
|
const uri = await User.webFinger(manager, person?.[1] ?? "");
|
||||||
|
|
||||||
const user = await User.resolve(uri);
|
const user = await User.resolve(uri);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ export default class FederationUserFetch extends BaseCommand<
|
||||||
signatureConstructor,
|
signatureConstructor,
|
||||||
);
|
);
|
||||||
|
|
||||||
const uri = await manager.webFinger(username);
|
const uri = await User.webFinger(manager, username);
|
||||||
|
|
||||||
const newUser = await User.resolve(uri);
|
const newUser = await User.resolve(uri);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ export default class FederationUserFinger extends BaseCommand<
|
||||||
signatureConstructor,
|
signatureConstructor,
|
||||||
);
|
);
|
||||||
|
|
||||||
const uri = await manager.webFinger(username);
|
const uri = await User.webFinger(manager, username);
|
||||||
|
|
||||||
spinner.succeed("Fetched user URI");
|
spinner.succeed("Fetched user URI");
|
||||||
|
|
||||||
|
|
|
||||||
2
drizzle/migrations/0030_curvy_vulture.sql
Normal file
2
drizzle/migrations/0030_curvy_vulture.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
DROP INDEX IF EXISTS "Users_username_index";--> statement-breakpoint
|
||||||
|
CREATE INDEX IF NOT EXISTS "Users_username_index" ON "Users" USING btree ("username");
|
||||||
2145
drizzle/migrations/meta/0030_snapshot.json
Normal file
2145
drizzle/migrations/meta/0030_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -211,6 +211,13 @@
|
||||||
"when": 1721155789219,
|
"when": 1721155789219,
|
||||||
"tag": "0029_shiny_korvac",
|
"tag": "0029_shiny_korvac",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 30,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1721223331975,
|
||||||
|
"tag": "0030_curvy_vulture",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,7 @@ export const Users = pgTable(
|
||||||
(table) => {
|
(table) => {
|
||||||
return {
|
return {
|
||||||
uriKey: uniqueIndex().on(table.uri),
|
uriKey: uniqueIndex().on(table.uri),
|
||||||
usernameKey: uniqueIndex().on(table.username),
|
usernameKey: index().on(table.username),
|
||||||
emailKey: uniqueIndex().on(table.email),
|
emailKey: uniqueIndex().on(table.email),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,12 @@ export class Instance extends BaseInterface<typeof Instances> {
|
||||||
proxy: config.http.proxy.address,
|
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
|
// If the server doesn't have a Lysand well-known endpoint, it's not a Lysand instance
|
||||||
// Try to resolve ActivityPub metadata instead
|
// Try to resolve ActivityPub metadata instead
|
||||||
const data = await Instance.fetchActivityPubMetadata(url);
|
const data = await Instance.fetchActivityPubMetadata(url);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import type {
|
||||||
Mention as ApiMention,
|
Mention as ApiMention,
|
||||||
} from "@lysand-org/client/types";
|
} from "@lysand-org/client/types";
|
||||||
import { EntityValidator } from "@lysand-org/federation";
|
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 { Entity, User as LysandUser } from "@lysand-org/federation/types";
|
||||||
import {
|
import {
|
||||||
type InferInsertModel,
|
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() {
|
static async getCount() {
|
||||||
return (
|
return (
|
||||||
await db
|
await db
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ export default (app: Hono) =>
|
||||||
signatureConstructor,
|
signatureConstructor,
|
||||||
);
|
);
|
||||||
|
|
||||||
const uri = await manager.webFinger(username);
|
const uri = await User.webFinger(manager, username);
|
||||||
|
|
||||||
const foundAccount = await User.resolve(uri);
|
const foundAccount = await User.resolve(uri);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ export default (app: Hono) =>
|
||||||
signatureConstructor,
|
signatureConstructor,
|
||||||
);
|
);
|
||||||
|
|
||||||
const uri = await manager.webFinger(username);
|
const uri = await User.webFinger(manager, username);
|
||||||
|
|
||||||
const resolvedUser = await User.resolve(uri);
|
const resolvedUser = await User.resolve(uri);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ export default (app: Hono) =>
|
||||||
signatureConstructor,
|
signatureConstructor,
|
||||||
);
|
);
|
||||||
|
|
||||||
const uri = await manager.webFinger(username);
|
const uri = await User.webFinger(manager, username);
|
||||||
|
|
||||||
const newUser = await User.resolve(uri);
|
const newUser = await User.resolve(uri);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue