Skip to content

ActivityPub Processing

If you use cattle_grid as a middleware, it takes care of communicating to the Fediverse for you. This means instead of having to handle receiving and sending HTTP post requests, you will be dealing with RabbitMQ routing. The relevant routing keys will be

incoming.ACTIVITY_TYPE
outgoing.ACTIVITY_TYPE

where the message content is given by the ActivityMessage type.

cattle_grid.model

ActivityMessage

Bases: BaseModel

Message that contains an Activity. Activity is used as the name for the ‘data object’ being exchanged, as is common in the Fediverse

Source code in cattle_grid/model/__init__.py
class ActivityMessage(BaseModel):
    """
    Message that contains an Activity. Activity is used as the name for the 'data object' being exchanged, as is common in the Fediverse
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    actor: str
    """
    actor_id of the actor that received the message
    """
    data: Dict[str, Any]
    """
    Activity.
    """
    activity_type: str
    """
    Type of the Activity
    """

activity_type: str instance-attribute

Type of the Activity

actor: str instance-attribute

actor_id of the actor that received the message

data: Dict[str, Any] instance-attribute

Activity.

FetchMessage

Bases: BaseModel

Used to request an ActivityPub object to be retrieved

Source code in cattle_grid/model/__init__.py
class FetchMessage(BaseModel):
    """
    Used to request an ActivityPub object to be retrieved
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    actor: str
    """
    actor_id of the actor that received the message
    """
    uri: str
    """
    URI of the object being retrieved
    """

actor: str instance-attribute

actor_id of the actor that received the message

uri: str instance-attribute

URI of the object being retrieved

JSON Schema

This section provides the json-schema documents used on this page.

ActivityMessage

activity_message.schema.json
{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "definitions": {
    "ActivityMessage": {
      "type": "object",
      "additionalProperties": false,
      "title": "Activity Message",
      "description": "Message that contains an Activity. Activity is used as the name for the 'data object' being exchanged, as is common in the Fediverse",
      "properties": {
        "actor": {
          "type": "string",
          "description": "actor_id of the actor that received the message"
        },
        "data": {
          "type": "object",
          "description": "Activity."
        },
        "activity_type": {
          "type": "string",
          "description": "Type of the Activity"
        }
      },
      "required": ["data", "actor", "activity_type"]
    },
    "FetchMessage": {
      "type": "object",
      "additionalProperties": false,
      "title": "Fetch Message",
      "description": "Used to request an ActivityPub object to be retrieved",
      "properties": {
        "actor": {
          "type": "string",
          "description": "actor_id of the actor that received the message"
        },
        "uri": {
          "type": "string",
          "description": "URI of the object being retrieved"
        }
      },
      "required": ["uri", "actor"]
    }
  }
}