Skip to content

Commit 06d31be

Browse files
authored
Merge pull request #681 from dahlia/former-type
Preserve deleted entity types in tombstones
2 parents d89091e + 5f5c1e4 commit 06d31be

17 files changed

Lines changed: 4591 additions & 1050 deletions

File tree

CHANGES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ To be released.
3434

3535
### @fedify/vocab
3636

37+
- Added `Tombstone.formerType` plus generated entity type helpers for deleted
38+
vocabulary objects. Applications can now construct tombstones with Fedify
39+
entity classes such as `Person`, and `@fedify/vocab` now exports
40+
`$EntityType`, `isEntityType()`, and `getEntityTypeById()` for working with
41+
those references. Unknown remote `formerType` values are ignored with a
42+
warning instead of making the whole tombstone fail to parse.
43+
[[#645], [#681]]
44+
3745
- Added [FEP-044f] vocabulary support for Mastodon-style quote posts.
3846
[[#452], [#679]]
3947

@@ -56,7 +64,18 @@ To be released.
5664
[FEP-0837]: https://w3id.org/fep/0837
5765
[#452]: https://github.com/fedify-dev/fedify/issues/452
5866
[#578]: https://github.com/fedify-dev/fedify/issues/578
67+
[#645]: https://github.com/fedify-dev/fedify/issues/645
5968
[#679]: https://github.com/fedify-dev/fedify/pull/679
69+
[#681]: https://github.com/fedify-dev/fedify/pull/681
70+
71+
### @fedify/vocab-tools
72+
73+
- Added the `fedify:vocabEntityType` pseudo-scalar to the vocabulary
74+
generator. Vocabulary properties can now accept generated Fedify entity
75+
constructors instead of arbitrary IRIs when the schema wants a reference to
76+
a known vocabulary type. Generated code now also emits the supporting
77+
`$EntityType`, `isEntityType()`, and `getEntityTypeById()` helpers for
78+
working with those references. [[#645], [#681]]
6079

6180
### @fedify/cli
6281

docs/manual/actor.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,25 @@ instead of `null`:
6060
~~~~ typescript twoslash
6161
// @noErrors: 2345
6262
import { type Federation } from "@fedify/fedify";
63-
import { Tombstone } from "@fedify/vocab";
63+
import { Person, Tombstone } from "@fedify/vocab";
6464
const federation = null as unknown as Federation<void>;
6565
const deletedAt = Temporal.Instant.from("2024-01-15T00:00:00Z");
6666
// ---cut-before---
6767
federation.setActorDispatcher("/users/{identifier}", async (ctx, identifier) => {
6868
if (identifier !== "alice") return null;
6969
return new Tombstone({
7070
id: ctx.getActorUri(identifier),
71+
formerType: Person,
7172
deleted: deletedAt,
7273
});
7374
});
7475
~~~~
7576

7677
When an actor dispatcher returns a `Tombstone`, Fedify responds from the actor
7778
endpoint with `410 Gone` and the serialized tombstone body. WebFinger for the
78-
same account also responds with `410 Gone`.
79+
same account also responds with `410 Gone`. If you know the deleted actor's
80+
former Fedify entity class, set `formerType` so the tombstone preserves the
81+
original ActivityStreams type.
7982

8083
Use `null` only when the identifier is not handled at all and the request
8184
should fall through to the next middleware or `onNotFound` handler.

docs/manual/context.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ const actor = await ctx.getActor(identifier, {
230230
tombstone: "passthrough",
231231
});
232232
if (actor instanceof Tombstone) {
233-
console.log(`${identifier} was deleted at ${actor.deleted}`);
233+
console.log(
234+
`${identifier} was deleted at ${actor.deleted} ` +
235+
`(former type: ${actor.formerType?.name ?? "unknown"})`,
236+
);
234237
}
235238
~~~~
236239

packages/fedify/src/federation/handler.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ test("handleActor()", async () => {
8989
if (identifier !== "gone") return null;
9090
return new Tombstone({
9191
id: ctx.getActorUri(identifier),
92+
formerType: Person,
9293
deleted: deletedAt,
9394
});
9495
};
@@ -346,6 +347,7 @@ test("handleActor()", async () => {
346347
],
347348
id: "https://example.com/users/gone",
348349
type: "Tombstone",
350+
formerType: "as:Person",
349351
deleted: "2024-01-15T00:00:00Z",
350352
});
351353
assertEquals(onNotFoundCalled, null);

0 commit comments

Comments
 (0)