fix(federation): 🐛 Put the ActivityPub link first in WebFinger to work around Misskey bug

This commit is contained in:
Jesse Wierzbinski 2024-07-17 15:08:21 +02:00
parent 896d22616d
commit 0e054e7cba
No known key found for this signature in database
3 changed files with 9 additions and 6 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -104,7 +104,7 @@
"@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.4", "@lysand-org/client": "^0.2.4",
"@lysand-org/federation": "^2.1.2", "@lysand-org/federation": "^2.1.3",
"@oclif/core": "^4.0.12", "@oclif/core": "^4.0.12",
"@tufjs/canonical-json": "^2.0.0", "@tufjs/canonical-json": "^2.0.0",
"altcha-lib": "^0.4.0", "altcha-lib": "^0.4.0",

View file

@ -96,6 +96,7 @@ export default (app: Hono) =>
activityPubUrl = await manager.webFinger( activityPubUrl = await manager.webFinger(
user.data.username, user.data.username,
new URL(config.http.base_url).host, new URL(config.http.base_url).host,
"application/activity+json",
); );
} catch (e) { } catch (e) {
const error = e as ResponseError; const error = e as ResponseError;
@ -111,6 +112,13 @@ export default (app: Hono) =>
}@${host}`, }@${host}`,
links: [ links: [
// Keep the ActivityPub link first, because Misskey only searches
// for the first link with rel="self" and doesn't check the type.
activityPubUrl && {
rel: "self",
type: "application/activity+json",
href: activityPubUrl,
},
{ {
rel: "self", rel: "self",
type: "application/json", type: "application/json",
@ -119,11 +127,6 @@ export default (app: Hono) =>
config.http.base_url, config.http.base_url,
).toString(), ).toString(),
}, },
activityPubUrl && {
rel: "self",
type: "application/activity+json",
href: activityPubUrl,
},
{ {
rel: "avatar", rel: "avatar",
type: lookup(user.getAvatarUrl(config)), type: lookup(user.getAvatarUrl(config)),