funkwhale/docs/developer/ap-overview.md

7.3 KiB

Funkwhale ActivityPub overview

Actors

Funkwhale uses ActivityPub actors to hold and manage access to content. There are five main types of actor:

Service actor

The Service actor is a special actor that represents a Funkwhale pod. ActivityPub actors can follow this actor to receive updates to public content stored on the pod.

User

A User is an actor that represents either a person with a Funkwhale account or a virtual user that controls access to a Channel. Regular Users can own Funkwhale Collection actors to add content to their ActivityPub Collection.

Regular Users may follow other Users to receive updates about the User's Favorites (likes collection) and Listening activity.

Multiple regular Users can own a virtual User to control access to a Channel. This is useful in the example of bands or groups who might share access to a joint account. A User may authenticate as the virtual user to add content to a Channel's ActivityPub Collection.

Collection

A Collection is an actor that represents a collection of content owned by a User. ActivityPub actors can follow this actor to be notified of changes to the collection's content.

Channel

A Channel is an actor that represents a public stream of content owned by a virtual User. Funkwhale Users with access to the virtual User may manage content in the Channel's collection. ActivityPub actors can follow this actor to be notified of changes to the collection's content.

Each actor must have a globally unique username that identifies them across federation. The preferredUsername field should be used to render the actor's name in all representations. Actor owners can change the preferredUsername of the actor at any time to update how it is represented.

erDiagram
    Pod ||--|| ServiceActor : contains
    Pod ||--|{ Users: contains
    Users ||--|{ Collections : owns
    Users }|--o{ VirtualUsers : accesses
    VirtualUsers ||--|{ Channels : owns
    Users }|--o{ Collections : follows
    Users }|--o{ Channels : follows
    Channels }|--|| ServiceActor : "public content"
    Collections }|--|| ServiceActor : "public content"
    ServiceActor ||--|| Outbox : publish

Service actor outbox

The Service actor publishes public Funkwhale content to its outbox. When new content is added to a public Collection or to a Channel, this update is added to the Service actor's outbox. Actors in the follower collection receive updates in their inbox and display the new content.

Pods may follow one another's public content by having their Service actor follow the target pod's Service actor. If the target Service actor accepts the follow request, the requesting Service actor is added to the target Service actor's follower collection.

sequenceDiagram
    Pod A->>Pod B: Follow
    Pod B-->>Pod A: Accept
    loop New items are added to the outbox
        Pod B->>Pod A: New items
    end

Service actors publish the following to their outbox:

  • Addition of new public content (represented as created actvities against content objects)
  • Deletion of public content (represented as delete activities against content objects)
  • Changes to public content details (represented as update activities against content objects)
sequenceDiagram
    User->>Service actor: Add new public content
    Service actor->>Outbox: Create content object
    Outbox->>Follower collection: Create content object
    User->>Service actor: Delete public content
    Service actor->>Outbox: Delete content object
    Outbox->>Follower collection: Delete content object
    User->>Service actor: Update public content
    Service actor->>Outbox: Update content object
    Outbox->>Follower collection: Update content object

Regular user outbox

Regular actors publish the following to their outbox:

Favorite action

sequenceDiagram
    par
        User->>Funkwhale API: Favorite content
        User->>Outbox: Like content object
    end
    Outbox->>Follower collection: Like content object

Listen action

sequenceDiagram
    par
        User->>Funkwhale API: Listen
        User->>Outbox: Create listen object
    end
    Outbox->>Follower collection: Create listen object

Collection outbox

Collection actors publish the following to their outbox:

sequenceDiagram
    User->>Collection: Add new content
    Collection->>Outbox: Create content object
    Outbox->>Follower collection: Create content object
    User->>Collection: Delete content
    Collection->>Outbox: Delete content object
    Outbox->>Follower collection: Delete content object
    User->>Collection: Update content
    Collection->>Outbox: Update content object
    Outbox->>Follower collection: Update content object

Channel outbox

Channel actors publish the following to their outbox:

sequenceDiagram
    User->>Channel: Add new content
    Channel->>Outbox: Create content object
    Outbox->>Follower collection: Create content object
    User->>Channel: Delete content
    Channel->>Outbox: Delete content object
    Outbox->>Follower collection: Delete content object
    User->>Channel: Update content
    Channel->>Outbox: Update content object
    Outbox->>Follower collection: Update content object