ActivityPub

From IndieWeb
Jump to: navigation, search


ActivityPub is a decentralized social networking protocol (W3C Recommendation) briefly known as ActivityPump, based on pump.io and ActivityStreams. Conceptually they were all preceded by OStatus.

w3c-spec-REC.svg

IndieWeb Examples

  •  Matthias Pfefferle has built the ActivityPub plugin for WordPress which allows his WordPress sites to (at least partially) support the ActivityPub protocol so sites like Mastodon and other parts of the Fediverse view his sites as a federated member.
  • Aaron Parecki - I have native ActivityPub support in my website so that it can be followed from people using compatible software. I turned that knowledge into a separate service that can be used to add ActivityPub to any website, the code is available as Nautilus on GitHub.
  • Greg McVerry uses Mastodon Plugin for Known which enables syndication, and native ActivityPub support in Micro.blog:
    • Added the Mastodon Plugin for Known to syndicate posts but also used Bridgy to create an instance of his blog at @quickthoughts.jgregorymcverry.com@quickthoughts.jgregorymcverry.com.
    • Uses the native ActivityPub support in Micro.blog which can be viewed @jgmac1106@stream.jgregorymcverry.com he can then send posts from his blog to his ActivityPub instance through Micro.blog

Bridging

Main article: bridge#ActivityPub

ActivityPub Notifications to Webmention

Since Mastodon and other ActivityPub implementations often include Microformats on their permalinks, a shortcut for receiving comments from ActivityPub servers is to treat them as webmentions instead of doing the full Inbox processing normally required by ActivityPub.

When your ActivityPub inbox receives a notification:

  • If type is Create
    • and if object.InReplyTo is present and is a URL on your domain
      • then save object.id as "source"
      • save object.InReplyTo as "target"
      • send a webmention to your webmention endpoint with the source and target

Then your site's existing webmention handling will fetch and verify the ActivityPub source URL, and if there are Microformats on the page, will even look like a reply.

Example:

Sending an ActivityPub notification from an IndieWeb website

As more people and services in the IndieWeb build in support for ActivityPub, it's important to remember that competing communication options could happen. Here is a general top-level breakdown of sending an ActivityPub notification for a reply or like.

The u-in-reply-to or u-like-of url will be referred to as the "targetUrl" below, and your post is referred to as the sourceUrl.

  • Fetch the targetUrl via text/html, check for a webmention endpoint.
  • If webmention endpoint exists, abort ActivityPub and send a webmention for sourceUrl to targetUrl
  • If webmention endpoint does not exist, attempt to fetch the targetUrl as application/activity+json
    • If targetUrl doesn't return JSON, targetUrl doesn't accept ActivityPub, abort.
    • If targetUrl returns JSON, check for a top-level @context attribute. This can be an array or a string, check if it contains "https://www.w3.org/ns/activitystreams".
      • If targetUrl's JSON response does not return the right details, abort.
      • If targetUrl's JSON response returns the correct info, check the attributedTo attribute for the author's ActivityPub profile.
        • Fetch the author's ActivityPub profile url as application/activity+json and check top-level inbox attribute for the author's ActivityPub inbox endpoint.
        • Send an ActivityPub notification to the author's ActivityPub inbox endpoint.

Tips & Tricks for Sending ActivityPub notifications

  • Mastodon requires that you include a "Mention" in the tags array, but you also need to include the person's preferredUsername in the post text to show it as a notification.
  • Technically attributedTo can be an object, but this hasn't been seen in the wild yet.

How To

(this section is a stub, please add links to How To articles for ActivityPub)

IndieWebCamp Sessions

(pretty sure there's been more sessions, e.g. re: Bridging that was brainstormed and developed at 2017 or 2018)

Criticism

(this section needs organizing into discrete rational criticisms, even better if they can be filed as issues on the specs and moved to an "Issues" section instead)

See Also