ActivityPub/Primer/Follow activity
Client to server
The Follow activity is how follow connections are initiated on the ActivityPub network. Here are some things to check when validating a new Follow activity received from the client:
- Check that the
objectof the activity exists. - Check that the
objectof the activity is not already in the actor'sfollowingcollection. - Check that the
objectof the activity is an actor that can be followed. Actors have at least aninboxand anoutboxproperty. - Check that an outstanding
Followrequest has not already been made. It may be useful to store outstanding Follow requests in an easy-to-find way in your storage.
If these checks work, there are two paths to follow:
- If it is a local actor (on the same server), and the actor does not require manually confirming follows, then you can simply implement the follow. See the ActivityPub/Primer/Accept activity for how to do this.
- Otherwise, the server should send the Follow activity to the
objectactor for approval. No additional modifications to the social graph should be made until anAcceptorRejectactivity is received.
Server to server
The Follow activity is how follow connections are initiated on the ActivityPub network. Here are some things to check when validating a new Follow activity received from another server:
- Check that the
objectof the activity exists. - Check that the
objectof the activity is an object on the local server. Otherwise, the Follow activity can be safely treated like any other activity with no side effects. - Check that the
objectof the activity is an actor that can be followed. Actors have at least aninboxand anoutboxproperty. - Check that the
actorof the activity is not already in theobject'sfollowerscollection. - Check that an outstanding
Followrequest has not already been made. It may be useful to store outstanding Follow requests in an easy-to-find way in your storage.
If these checks work, there are two paths to follow:
- If the recipient does not require manually confirming follows, then you can simply create the connection and send an
Acceptactivity in response. - If the recipient does require manually confirming follows, the server should allow the actor to review the follow and either accept or reject. A typical implementation shows new follow requests in a separate section of the UI. Another option is including the
Followactivity in the actor's inbox for review.
To create the connection, there are two steps:
- Add the
actorof the activity to theobject'sfollowerscollection. - Add the
objectof the activity to theactor'sfollowingcollection.
Note that if the actor or the object are on a different server, these collections might not be canonical for the actor or object, but just a cache of the remote data. It's also reasonable not to cache these remote collections and to always retrieve them from the remote server.
Multiple Follow activities
An actor sending more than one Follow activity for the same actor is not discussed in the ActivityPub spec.
However, most implementations treat the followers and following collections of the actor as unique by actor id.
Given this situation, some recommendations for best practices to maximize interoperation:
Originating servers should avoid sending multiple Follow activities from the same actor for the same object. Receiving servers that receive multiple Follow activities from the same actor for the same object, and treat following and followers as unique, should quietly ignore all activities except the first.