ActivityPub/Primer/Accept activity

From W3C Wiki

The Accept activity is how an actor expresses their approval for another activity, typically. In ActivityPub, it is especially important for accepting Follow activities.

Client to server

When a server receives an Accept activity, it should check:

  • That the object of the activity exists.

If the object is an activity of type Follow, the server should also check:

  • That the object of the Follow activity is not already in the actor's followers collection.
  • That the Follow activity has not been undone by an Undo activity. See ActivityPub/Primer/Undo activity for more information.

If these checks pass, then the server should:

  • Add the actor of the Follow activity to the actor of the Accept activity's followers.
  • If it's a local user, add the actor of the Accept activity to the actor of the Accept activity's following. If not, it may make sense to retain this information if the server is keeping a cache of the following collections of remote users.
  • Send the Accept activity to the actor of the Follow activity.

Server to server

When a server receives an Accept activity from a remote user, it should check:

  • That the object of the activity exists.

If the object is an activity of type Follow, the server should also check:

  • That the actor of the Accept activity is not already in the recipient's following collection.
  • That the Follow activity has not been undone by an Undo activity. See ActivityPub/Primer/Undo activity for more information.

If these checks pass, then the server should:

  • Add the actor of the Accept activity to the actor of the Follow activity's following.
  • If the server is keeping caches of remote followers collects, add the actor of the Follow activity to the actor of the Accept activity's following.

It may be useful to store this Reject activity as the result of the Follow activity, to show that the follow is no longer outstanding.

Reference