@alex@dave i asked chatgpt for help to see if it'll actually be any more helpful than a google search it was the most useless dogshit ive seen Thank God even AI can't understand activitypub
@meso@alex Pasted your reply and asked for an explanation a seasoned programmer would understand:
Certainly! As a seasoned programmer, you’re likely familiar with RESTful APIs, HTTP requests, and JSON serialization. ActivityPub is a protocol that uses these concepts to enable decentralized social networking. Let’s dive into the details of how federation works in ActivityPub, including the roles of the inbox and outbox, and how servers communicate with each other.
ActivityPub Federation:
Federation is the process by which servers in the ActivityPub network (known as the Fediverse) communicate and share data. Each server in the network is responsible for hosting user accounts (actors) and their content (objects). Federation allows actors on one server to interact with actors on other servers. For example, a user on server A can follow, like, or reply to a post created by a user on server B. Server Endpoints:
Each server implementing ActivityPub exposes two key endpoints for each actor: the inbox and the outbox. The inbox is an endpoint that receives incoming activities from other actors. It’s essentially an HTTP endpoint that accepts POST requests containing ActivityStreams objects. The outbox is an endpoint that holds activities created by the actor. It’s a collection of activities that the actor has published. Other servers can retrieve activities from an actor’s outbox to stay updated. Inbox and Delivery:
When an actor performs an activity (e.g., creating a post or following another actor), the activity is published to their outbox and delivered to relevant recipients. Recipients can be specified using properties like “to,” “cc,” and “bto.” The server is responsible for delivering the activity to the inboxes of recipients. This is done by making an HTTP POST request to the inbox endpoint of each recipient with the JSON-serialized activity as the payload. The recipient’s server processes the incoming activity, performs necessary actions (e.g., updating the follower list), and may generate new activities in response (e.g., an “Accept” activity for a “Follow” request). Outbox and Retrieval:
Other servers can retrieve activities from an actor’s outbox to stay updated with their actions. The outbox is typically accessible via an HTTP GET request, and it returns a JSON-serialized collection of activities. The outbox may support different types of views, such as an “OrderedCollection” view that provides a paginated list of activities. Example of Activity Delivery:
Actor A on server A creates a “Follow” activity to follow actor B on server B. The activity is added to actor A’s outbox. Server A delivers the “Follow” activity to actor B’s inbox on server B by making an HTTP POST request to the inbox endpoint with the activity payload. Server B processes the incoming activity, updates actor B’s list of followers, and generates an “Accept” activity in response. Server B delivers the “Accept” activity to actor A’s inbox on server A, confirming the follow request. Discovering Actors and Endpoints:
Actors are usually identified by a URI (e.g., “https://example.com/actor/alice”). To interact with an actor, a server needs to discover the actor’s endpoints (inbox, outbox, etc.). This is done by fetching the actor’s URI, which returns an ActivityStreams “Person” (or other actor type) object containing the relevant endpoints and metadata. Overall, ActivityPub federation relies on RESTful principles, HTTP requests, and JSON-LD serialization to enable communication between servers. The inbox and outbox play central roles in receiving and publishing activities, respectively. The protocol is flexible and can be extended to support various social networking use cases.
@meso@alex ActivityPub is a decentralized social networking protocol that allows users to create, update, and delete content on one server, while that content can be delivered to and interacted with by users on other servers. It is part of the larger “Fediverse” of federated social networks. The protocol is based on the ActivityStreams 2.0 data format and is designed to be used with JSON-LD (JSON Linked Data). ActivityPub became a W3C Recommendation in January 2018.
Key Concepts:
Actors: In ActivityPub, users and groups are represented as “actors.” Each actor has a unique identifier (a URI), an inbox for receiving activities, and an outbox for sending activities.
Activities: Actions performed by actors are called “activities.” Activities are the “data” referred to in the question, and they are represented using the ActivityStreams 2.0 vocabulary. Common activities include “Create,” “Update,” “Delete,” “Follow,” “Like,” and “Announce” (share).
Objects: The content or items that activities act upon are called “objects.” Examples of objects include notes, articles, images, videos, and profiles.
How Servers Find Each Other:
Servers find each other through a process known as “federation.” When an actor on one server (Server A) wants to interact with an actor on another server (Server B), Server A sends an activity to the inbox of the actor on Server B. This establishes a federation relationship between the two servers. Actors can also “follow” each other, creating a subscription relationship. When an actor follows another actor, their server will receive updates from the followed actor’s outbox.
How Data Is Fetched and Synced Across Servers:
When an actor performs an activity (e.g., creating a post), the activity is published to their outbox. The server then delivers the activity to the inboxes of relevant actors (e.g., followers) on the same server and on other federated servers. Servers fetch and sync data by exchanging activities between inboxes and outboxes. Activities are sent as HTTP requests with JSON-LD payloads. The protocol also supports the fetching of individual objects and collections through their URIs. Data Format:
The “data” in ActivityPub is called “activities,” and they are represented using the ActivityStreams 2.0 vocabulary. Activities are serialized as JSON-LD documents. JSON-LD is a JSON-based format used to represent linked data. Each activity has a “type” (e.g., “Create,” “Follow”) and typically includes an “actor” (who performed the activity), an “object” (what the activity is about), and other optional properties. Example of an Activity in JSON-LD Format:
In this example, an actor with the URI “https://example.com/actor/123” creates a note with the content “Hello, ActivityPub world!” The activity is of type “Create” and is addressed to the actor’s followers.
Overall, ActivityPub provides a standardized way for servers to communicate and share social data in a decentralized manner, enabling a diverse and interoperable ecosystem of social applications.
@dave@alex this explains the underlying terminology and concepts of ActivityPub objects and stuff not the actual federation, it just says inbox and stuff, not really how inbox/outbox are supposed to work
@dave@alex explain in technical terms activitypub federation or something like that and it explained it like Uhmmm so youve got a server adn then it talks to the other server and that's NOT technical
@dave@meso I asked it to design me a bridge between Nostr and the Fediverse a month ago, and it gave me a boilerplate that was basically correct. It didn’t really impact the project but it reaffirmed what I already knew.
@meso@alex I’ve got GPT-4 (w/ plugin) access, and it’s good at basic coding and scripting in almost any language. Gimme a follow-up prompt with some more specific requests, and it can probably help. For the record, the prompts used were:
Explain the ActivityPub protocol, make sure your response includes an explanation of how servers find each other, how “data” is fetched and synced across servers, what this “data” is called by the AP spec designers, and what the format of this “data” is.
and
this explains the underlying terminology and concepts of ActivityPub objects and stuff not the actual federation, it just says inbox and stuff, not really how inbox/outbox are supposed to work. Can you try explaining these concepts to me like I’m a seasoned programmer that is just trying to learn how to work with this spec?
@dave@meso The biggest thing that helped me build the bridge was not AI, but this, which I listened to THE ENTIRE TIME, NONSTOP, no other music whatsoever, even when I wasn’t working: https://youtu.be/uLD1OvWM1JE?list=RDuLD1OvWM1JE
@eris@dave@meso The main issue with JSON is serialization/deserialization performance. An alternative is flatbuffers which is more machine-friendly than human-friendly (JSON was designed as a middle ground). If you want to feel like you’re falling down an LSD-induced computer rabbit hole, read this: https://github.com/hoytech/strfry