mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(federation): 🐛 Fix incorrect destructuring causing federation issues
This commit is contained in:
parent
1d17831454
commit
054b8bc5cb
3
drizzle/migrations/0049_graceful_iron_man.sql
Normal file
3
drizzle/migrations/0049_graceful_iron_man.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE "Notes" ALTER COLUMN "sensitive" SET DEFAULT false;--> statement-breakpoint
|
||||
ALTER TABLE "Users" ALTER COLUMN "display_name" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "Users" ALTER COLUMN "source" DROP NOT NULL;
|
||||
2342
drizzle/migrations/meta/0049_snapshot.json
Normal file
2342
drizzle/migrations/meta/0049_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -344,6 +344,13 @@
|
|||
"when": 1743365238468,
|
||||
"tag": "0048_chilly_vector",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 49,
|
||||
"version": "7",
|
||||
"when": 1744979203068,
|
||||
"tag": "0049_graceful_iron_man",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,15 +39,15 @@ export class FederationRequester {
|
|||
|
||||
const finalReq = await sign(this.privateKey, this.authorUrl, req);
|
||||
|
||||
const { ok, json, text, headers, status } = await fetch(finalReq);
|
||||
const res = await fetch(finalReq);
|
||||
|
||||
if (!ok) {
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
`Failed to fetch entity from ${url.toString()}: got HTTP code ${status} with body "${await text()}"`,
|
||||
`Failed to fetch entity from ${url.toString()}: got HTTP code ${res.status} with body "${await res.text()}"`,
|
||||
);
|
||||
}
|
||||
|
||||
const contentType = headers.get("Content-Type");
|
||||
const contentType = res.headers.get("Content-Type");
|
||||
|
||||
if (!contentType?.includes("application/json")) {
|
||||
throw new Error(
|
||||
|
|
@ -55,7 +55,7 @@ export class FederationRequester {
|
|||
);
|
||||
}
|
||||
|
||||
const jsonData = await json();
|
||||
const jsonData = await res.json();
|
||||
const type = jsonData.type;
|
||||
|
||||
if (type && type !== expectedType.name) {
|
||||
|
|
@ -168,7 +168,7 @@ export class FederationRequester {
|
|||
contentType = "application/json",
|
||||
serverUrl = `https://${hostname}`,
|
||||
): Promise<URL | null> {
|
||||
const { ok, json, text } = await fetch(
|
||||
const res = await fetch(
|
||||
new URL(
|
||||
`/.well-known/webfinger?${new URLSearchParams({
|
||||
resource: `acct:${username}@${hostname}`,
|
||||
|
|
@ -184,14 +184,14 @@ export class FederationRequester {
|
|||
},
|
||||
);
|
||||
|
||||
if (!ok) {
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
`Failed to fetch webfinger from ${serverUrl}: got HTTP code ${ok} with body "${await text()}"`,
|
||||
`Failed to fetch webfinger from ${serverUrl}: got HTTP code ${res.ok} with body "${await res.text()}"`,
|
||||
);
|
||||
}
|
||||
|
||||
// Validate the response
|
||||
const data = await WebFingerSchema.parseAsync(await json());
|
||||
const data = await WebFingerSchema.parseAsync(await res.json());
|
||||
|
||||
// Get the first link with a rel of "self"
|
||||
const selfLink = data.links?.find(
|
||||
|
|
|
|||
Loading…
Reference in a new issue