Inbox and Outbox
In the ActivityPub Server-to-Server (S2S) protocol, the exchange of messages is managed through two primary endpoints: Inbox and Outbox.
Message Distribution (Outbox)
Section titled “Message Distribution (Outbox)”In a pure S2S context, the Outbox serves as the formal origin or the “sent folder” for an actor’s activities. When a server generates a new activity (such as a Create or Announce), it is conceptually added to the actor’s Outbox to represent the actor’s history of outgoing actions.
The Delivery Process
Section titled “The Delivery Process”Once an activity is generated, the server initiates the delivery process to notify relevant peers:
- Identifying Targets: The server examines the
to,cc, andaudiencefields, as well as the actor’sfollowerslist, to determine theinboxURLs of the remote recipients. - Dispatching: The server then performs an HTTP POST of the activity to each identified remote
inbox.
Receiving Messages (Inbox)
Section titled “Receiving Messages (Inbox)”the Inbox is the designated endpoint for receiving activities sent by external servers.
- Activity Reception: An external server POSTs an
Activityto the actor’sinboxURL. - Verification and Processing: The receiving server verifies the request’s authenticity (e.g., via HTTP Signatures). If valid, the activity is processed—such as being stored in the database or triggering a notification for the local user.
Shared Inbox
Section titled “Shared Inbox”When an actor has a large following (thousands or millions of followers), POSTing to every individual follower’s inbox creates immense overhead. The Shared Inbox optimizes this high-volume delivery.
- Mechanism: If multiple followers reside on the same remote instance, the sending server POSTs the activity only once to a
sharedInboxendpoint defined by that instance. - Internal Distribution: The receiving server accepts the single POST and internally distributes the activity to all relevant local users.
This mechanism significantly reduces network traffic and minimizes CPU/memory usage for both the sending and receiving servers.