Skip to content

Subscribe

In ActivityPub, this is Follow, and SubscribeAccept, SubscribeReject and Unsubscribe are Accept, Reject and Undo. See Other Protocols.

A User can subscribe to another entity to receive what it shares with its subscribers. The Subscribe entity starts a subscription.

  • Subscriber: The user who subscribes. If Joe subscribes to Alice, Joe is the subscriber.
  • Target: The entity subscribed to. If Joe subscribes to Alice, Alice is the target.

Only entity types whose page says they accept subscriptions can be a target. In the core, that is the User. An extension can make its own types accept subscriptions, as Groups does, and states on its page what their subscribers receive.

Definition

Subscribe has no author. It MUST be sent by the subscriber’s instance.

Checking the Sender

None of the four subscription entities has an author. When a receiver checks Authors and Signers, it MUST treat subscriber as the author of a Subscribe or an Unsubscribe, and target as the author of a SubscribeAccept or a SubscribeReject.

target_type MUST be the type of the entity that target points to. A receiver that holds that entity MUST reject a subscription entity whose target_type does not match it.

Type
"Subscribe"

Fields

Reference to the User who subscribes.

target Reference Required

Reference to the entity subscribed to.

target_type string Required

Type of the entity that target points to, such as User. MUST be a type that accepts subscriptions.

Inherited from Entity: type, created_at, extensions
{
    "type": "Subscribe",
    "created_at": "2021-01-01T00:00:00Z",
    "subscriber": "example.org:033wv9k6n0007",
    "target": "example.com:033qtdbdkj006",
    "target_type": "User"
}

Behavior

Joe, a user on joe.example, wants to subscribe to Alice, a user on alice.example.

Sending a Subscription Request

To start a subscription, joe.example MUST do the following:

  1. Create a Subscribe entity with Joe as the subscriber and Alice as the target.
  2. Send the Subscribe entity to alice.example’s inbox.
  3. Treat the subscription as “processing” until a SubscribeAccept or SubscribeReject arrives, or until Joe sends an Unsubscribe.

A Subscribe whose target_type does not accept subscriptions MUST be rejected.

Accepting the Subscription Request

alice.example MUST answer every Subscribe with a SubscribeAccept or a SubscribeReject, even if manually_approves_subscribers is false. If Joe is already subscribed to Alice and sends another Subscribe, alice.example MUST send a SubscribeAccept again, in case the first was lost.

The answer can wait for Alice to decide. There is no time limit on a pending Subscribe.

To accept the subscription request, alice.example MUST do the following:

  1. Create a SubscribeAccept entity with Joe as the subscriber and Alice as the target.
  2. Send the SubscribeAccept entity to joe.example’s inbox.

It then treats Joe as a subscriber of Alice.

Rejecting the Subscription Request

To reject the subscription request, alice.example MUST do the following:

  1. Create a SubscribeReject entity with Joe as the subscriber and Alice as the target.
  2. Send the SubscribeReject entity to joe.example’s inbox.

Cancelling the Subscription Request

To cancel a subscription request that has not been answered, joe.example sends an Unsubscribe.

Final Steps

joe.example MUST mark the subscription as “accepted” when it receives a SubscribeAccept, and remove it when it receives a SubscribeReject.

Delivering Entities

Which entities reach a subscriber is defined in Delivery, and by the page of each type that accepts subscriptions.

Ending the Subscription

Joe ends the subscription by sending an Unsubscribe. Alice ends it by sending a SubscribeReject, which removes Joe as a subscriber. An Unsubscribe is not used to remove a subscriber.

Flows

Every message here is sent to the inbox of the other user’s instance. A subscription request is either accepted:

  1. Request: Subscribe
    Joe asks to subscribe to Alice.
  2. Marks the subscription as “processing”.
  3. Request: SubscribeAccept
    Alice accepts.
  4. Marks the subscription as “accepted”.
  5. Marks the subscription as “accepted”.

Or rejected:

  1. Request: Subscribe
    Joe asks to subscribe to Alice.
  2. Marks the subscription as “processing”.
  3. Request: SubscribeReject
    Alice rejects.
  4. Optionally, logs the rejection.
  5. Removes the subscription.

Once accepted, the subscription ends when Joe unsubscribes:

  1. Request: Unsubscribe
    Joe unsubscribes from Alice.
  2. Removes the subscription.
  3. Removes the subscription.

Or when Alice removes Joe as a subscriber:

  1. Request: SubscribeReject
    Alice removes Joe as a subscriber.
  2. Removes the subscription.
  3. Removes the subscription.