mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(federation): 🐛 Fix some errors not being ignored properly
This commit is contained in:
parent
db2d582295
commit
1216e278e8
|
|
@ -106,13 +106,13 @@
|
|||
"@json2csv/plainjs": "^7.0.6",
|
||||
"@logtape/logtape": "npm:@jsr/logtape__logtape@0.4.2",
|
||||
"@lysand-org/client": "^0.2.5",
|
||||
"@lysand-org/federation": "^2.1.9",
|
||||
"@lysand-org/federation": "^2.1.10",
|
||||
"@oclif/core": "^4.0.14",
|
||||
"@sentry/bun": "^8.20.0",
|
||||
"@tufjs/canonical-json": "^2.0.0",
|
||||
"altcha-lib": "^0.5.1",
|
||||
"blurhash": "^2.0.5",
|
||||
"bullmq": "^5.10.3",
|
||||
"bullmq": "^5.10.4",
|
||||
"chalk": "^5.3.0",
|
||||
"cli-progress": "^3.12.0",
|
||||
"cli-table": "^0.3.11",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { getLogger } from "@logtape/logtape";
|
|||
import {
|
||||
EntityValidator,
|
||||
FederationRequester,
|
||||
type ResponseError,
|
||||
type ValidationError,
|
||||
} from "@lysand-org/federation";
|
||||
import type { ServerMetadata } from "@lysand-org/federation/types";
|
||||
|
|
@ -145,7 +146,9 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
// @ts-expect-error Bun extension
|
||||
proxy: config.http.proxy.address,
|
||||
},
|
||||
);
|
||||
).catch((e) => ({
|
||||
...(e as ResponseError).response,
|
||||
}));
|
||||
|
||||
if (!(ok && raw.headers.get("content-type")?.includes("json"))) {
|
||||
// If the server doesn't have a Lysand well-known endpoint, it's not a Lysand instance
|
||||
|
|
@ -202,7 +205,13 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
}>(wellKnownUrl, {
|
||||
// @ts-expect-error Bun extension
|
||||
proxy: config.http.proxy.address,
|
||||
});
|
||||
}).catch((e) => ({
|
||||
...(
|
||||
e as ResponseError<{
|
||||
links: { rel: string; href: string }[];
|
||||
}>
|
||||
).response,
|
||||
}));
|
||||
|
||||
if (!ok) {
|
||||
logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold(
|
||||
|
|
@ -246,7 +255,19 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
}>(metadataUrl.href, {
|
||||
// @ts-expect-error Bun extension
|
||||
proxy: config.http.proxy.address,
|
||||
});
|
||||
}).catch((e) => ({
|
||||
...(
|
||||
e as ResponseError<{
|
||||
metadata: {
|
||||
nodeName?: string;
|
||||
title?: string;
|
||||
nodeDescription?: string;
|
||||
description?: string;
|
||||
};
|
||||
software: { version: string };
|
||||
}>
|
||||
).response,
|
||||
}));
|
||||
|
||||
if (!ok2) {
|
||||
logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold(
|
||||
|
|
|
|||
|
|
@ -340,19 +340,13 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
|||
uri: string,
|
||||
instance: Instance,
|
||||
): Promise<User> {
|
||||
const {
|
||||
raw: response,
|
||||
data: json,
|
||||
ok,
|
||||
} = await FederationRequester.get<Partial<LysandUser>>(uri, {
|
||||
const { data: json } = await FederationRequester.get<
|
||||
Partial<LysandUser>
|
||||
>(uri, {
|
||||
// @ts-expect-error Bun extension
|
||||
proxy: config.http.proxy.address,
|
||||
});
|
||||
|
||||
if (!ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const validator = new EntityValidator();
|
||||
const data = await validator.User(json);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue