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
Joesubscribes toAlice,Joeis the subscriber. - Target: The entity subscribed to. If
Joesubscribes toAlice,Aliceis 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"- Lifetime
- Transient Entity
Fields
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
typestring Requiredcreated_atRFC3339 RequiredextensionsExtensions
{
"type": "Subscribe",
"created_at": "2021-01-01T00:00:00Z",
"subscriber": "example.org:033wv9k6n0007",
"target": "example.com:033qtdbdkj006",
"target_type": "User"
}Check a Subscribe
Checks a Subscribe against the fields above. Nothing leaves your browser.
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:
- Create a
Subscribeentity withJoeas the subscriber andAliceas the target. - Send the
Subscribeentity toalice.example’s inbox. - Treat the subscription as “processing” until a
SubscribeAcceptorSubscribeRejectarrives, or untilJoesends 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:
- Create a SubscribeAccept entity with
Joeas the subscriber andAliceas the target. - Send the
SubscribeAcceptentity tojoe.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:
- Create a SubscribeReject entity with
Joeas the subscriber andAliceas the target. - Send the
SubscribeRejectentity tojoe.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:
- Request:
SubscribeJoeasks to subscribe toAlice. - Marks the subscription as “processing”.
- Request:
SubscribeAcceptAliceaccepts. - Marks the subscription as “accepted”.
- Marks the subscription as “accepted”.
Or rejected:
- Request:
SubscribeJoeasks to subscribe toAlice. - Marks the subscription as “processing”.
- Request:
SubscribeRejectAlicerejects. - Optionally, logs the rejection.
- Removes the subscription.
Once accepted, the subscription ends when Joe unsubscribes:
- Request:
UnsubscribeJoeunsubscribes fromAlice. - Removes the subscription.
- Removes the subscription.
Or when Alice removes Joe as a subscriber:
- Request:
SubscribeRejectAliceremovesJoeas a subscriber. - Removes the subscription.
- Removes the subscription.