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",
|
"@json2csv/plainjs": "^7.0.6",
|
||||||
"@logtape/logtape": "npm:@jsr/logtape__logtape@0.4.2",
|
"@logtape/logtape": "npm:@jsr/logtape__logtape@0.4.2",
|
||||||
"@lysand-org/client": "^0.2.5",
|
"@lysand-org/client": "^0.2.5",
|
||||||
"@lysand-org/federation": "^2.1.9",
|
"@lysand-org/federation": "^2.1.10",
|
||||||
"@oclif/core": "^4.0.14",
|
"@oclif/core": "^4.0.14",
|
||||||
"@sentry/bun": "^8.20.0",
|
"@sentry/bun": "^8.20.0",
|
||||||
"@tufjs/canonical-json": "^2.0.0",
|
"@tufjs/canonical-json": "^2.0.0",
|
||||||
"altcha-lib": "^0.5.1",
|
"altcha-lib": "^0.5.1",
|
||||||
"blurhash": "^2.0.5",
|
"blurhash": "^2.0.5",
|
||||||
"bullmq": "^5.10.3",
|
"bullmq": "^5.10.4",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
"cli-table": "^0.3.11",
|
"cli-table": "^0.3.11",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { getLogger } from "@logtape/logtape";
|
||||||
import {
|
import {
|
||||||
EntityValidator,
|
EntityValidator,
|
||||||
FederationRequester,
|
FederationRequester,
|
||||||
|
type ResponseError,
|
||||||
type ValidationError,
|
type ValidationError,
|
||||||
} from "@lysand-org/federation";
|
} from "@lysand-org/federation";
|
||||||
import type { ServerMetadata } from "@lysand-org/federation/types";
|
import type { ServerMetadata } from "@lysand-org/federation/types";
|
||||||
|
|
@ -145,7 +146,9 @@ export class Instance extends BaseInterface<typeof Instances> {
|
||||||
// @ts-expect-error Bun extension
|
// @ts-expect-error Bun extension
|
||||||
proxy: config.http.proxy.address,
|
proxy: config.http.proxy.address,
|
||||||
},
|
},
|
||||||
);
|
).catch((e) => ({
|
||||||
|
...(e as ResponseError).response,
|
||||||
|
}));
|
||||||
|
|
||||||
if (!(ok && raw.headers.get("content-type")?.includes("json"))) {
|
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
|
// 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, {
|
}>(wellKnownUrl, {
|
||||||
// @ts-expect-error Bun extension
|
// @ts-expect-error Bun extension
|
||||||
proxy: config.http.proxy.address,
|
proxy: config.http.proxy.address,
|
||||||
});
|
}).catch((e) => ({
|
||||||
|
...(
|
||||||
|
e as ResponseError<{
|
||||||
|
links: { rel: string; href: string }[];
|
||||||
|
}>
|
||||||
|
).response,
|
||||||
|
}));
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold(
|
logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold(
|
||||||
|
|
@ -246,7 +255,19 @@ export class Instance extends BaseInterface<typeof Instances> {
|
||||||
}>(metadataUrl.href, {
|
}>(metadataUrl.href, {
|
||||||
// @ts-expect-error Bun extension
|
// @ts-expect-error Bun extension
|
||||||
proxy: config.http.proxy.address,
|
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) {
|
if (!ok2) {
|
||||||
logger.error`Failed to fetch ActivityPub metadata for instance ${chalk.bold(
|
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,
|
uri: string,
|
||||||
instance: Instance,
|
instance: Instance,
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
const {
|
const { data: json } = await FederationRequester.get<
|
||||||
raw: response,
|
Partial<LysandUser>
|
||||||
data: json,
|
>(uri, {
|
||||||
ok,
|
|
||||||
} = await FederationRequester.get<Partial<LysandUser>>(uri, {
|
|
||||||
// @ts-expect-error Bun extension
|
// @ts-expect-error Bun extension
|
||||||
proxy: config.http.proxy.address,
|
proxy: config.http.proxy.address,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!ok) {
|
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const validator = new EntityValidator();
|
const validator = new EntityValidator();
|
||||||
const data = await validator.User(json);
|
const data = await validator.User(json);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue