Skip to content

Commit 5c44257

Browse files
committed
Preload Lemmy's JSON-LD context
Bundle Lemmy's JSON-LD context in vocab-runtime and register it as a preloaded context for the default document loader. This lets Fedify parse Lemmy-originated activities without application-specific document loader workarounds for the context URL's non-JSON-LD response headers. Update the changelog for the next vocab-runtime release. Fixes #714 Assisted-by: Codex:gpt-5.4
1 parent c0dd72c commit 5c44257

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ Version 2.0.14
88

99
To be released.
1010

11+
### @fedify/vocab-runtime
12+
13+
- Added <https://join-lemmy.org/context.json> to preloaded JSON-LD contexts.
14+
Lemmy serves this context as `application/json` without a JSON-LD context
15+
`Link` header, which caused the default document loader to reject
16+
Lemmy-originated activities before application handlers could run. [[#714]]
17+
18+
[#714]: https://github.com/fedify-dev/fedify/issues/714
19+
1120

1221
Version 2.0.13
1322
--------------

packages/vocab-runtime/src/contexts.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// https://github.com/fedify-dev/fedify/issues/74
33
// cSpell: disable
44

5+
import joinLemmyContext from "./contexts/join-lemmy.json" with { type: "json" };
6+
57
const preloadedContexts: Record<string, unknown> = {
68
"https://www.w3.org/ns/activitystreams": {
79
"@context": {
@@ -4315,6 +4317,15 @@ const preloadedContexts: Record<string, unknown> = {
43154317
},
43164318
},
43174319

4320+
// Lemmy's context document is served as application/json without the JSON-LD
4321+
// context Link header. The default document loader treats that as a regular
4322+
// JSON response instead of a JSON-LD context, so every Lemmy activity that
4323+
// references this URL fails before application handlers run. We ship a
4324+
// built-in copy here so Fedify can parse Lemmy-originated activities without
4325+
// application-level document loader workarounds.
4326+
// See: https://github.com/fedify-dev/fedify/issues/714
4327+
"https://join-lemmy.org/context.json": joinLemmyContext,
4328+
43184329
// Mastodon's "toot:" namespace. The URL http://joinmastodon.org/ns has
43194330
// *never* served a real JSON-LD context document—Mastodon has always inlined
43204331
// these term definitions directly in every outgoing @context array. However,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"@context": [
3+
"https://w3id.org/security/v1",
4+
{
5+
"as": "https://www.w3.org/ns/activitystreams#",
6+
"lemmy": "https://join-lemmy.org/ns#",
7+
"litepub": "http://litepub.social/ns#",
8+
"pt": "https://joinpeertube.org/ns#",
9+
"sc": "http://schema.org/",
10+
"mastodon": "http://joinmastodon.org/ns#",
11+
"ChatMessage": "litepub:ChatMessage",
12+
"commentsEnabled": "pt:commentsEnabled",
13+
"sensitive": "as:sensitive",
14+
"matrixUserId": "lemmy:matrixUserId",
15+
"postingRestrictedToMods": "lemmy:postingRestrictedToMods",
16+
"removeData": "lemmy:removeData",
17+
"stickied": "lemmy:stickied",
18+
"moderators": {
19+
"@type": "@id",
20+
"@id": "lemmy:moderators"
21+
},
22+
"expires": "as:endTime",
23+
"distinguished": "lemmy:distinguished",
24+
"language": "sc:inLanguage",
25+
"identifier": "sc:identifier",
26+
"Hashtag": "as:Hashtag",
27+
"featured": {
28+
"@type": "@id",
29+
"@id": "mastodon:featured"
30+
}
31+
}
32+
]
33+
}

0 commit comments

Comments
 (0)