hackers.pub Hall

The Diplomacy Office (federation)

ja· en· ko
If you're new hereThe room where hackers.pub exchanges letters with outside servers. The real work is left to fedify.

What hollo does, you can do in Deno too. Keep the diplomatic floor plan as a shared blueprint (the builder), and several wings can reuse the same wiring—a model for where to put federation in an app that grows large.

inbox/mod.ts reads as a route map of verbs. Accept, Follow, Undo… an ambiguous verb is sorted by looking inside. The kinds of letters that arrive are all surveyable on a single sheet.

Highlights

  • The shared inbox is /ap/inbox, the individual one /ap/actors/{identifier}/inbox. The identifier is an account's UUID, or the hostname of the instance itself
  • The instance actor is an Application named "Hackers' Pub". A deleted resident becomes not null but a KeyedTombstone—at the end of the link, the shape of an absence remains
  • The handlers are split into named functions—onPostCreated, onFollowed, onQuoteRequested—each with a companion test

A passage from the sutra

builder
  .setInboxListeners("/ap/actors/{identifier}/inbox", "/ap/inbox")
  .setSharedKeyDispatcher((ctx) => ({
    identifier: new URL(ctx.canonicalOrigin).hostname,
  }))
  .onUnverifiedActivity(onUnverifiedActivity)
  .on(Accept, async (fedCtx, accept) => {
    if (await onQuoteRequestAccepted(fedCtx, accept)) return;
    if (await onRelayFollowAccepted(fedCtx, accept)) return;
    await onFollowAccepted(fedCtx, accept);
  })
federation/inbox/mod.ts L53-L63— When an Accept arrives, it asks after three possibilities in turn

Floor plan

federation/builder.ts
The empty blueprint (createFederationBuilder)
federation/inbox/mod.ts
The route map of verbs. Sixteen kinds of .on()
federation/actor.ts
The three choices: instance actor, resident actor, or tombstone
federation/mod.ts
Assembles the wings by side-effect import and re-exports

Neighboring rooms

Outside links