Federation support for Discourse

An update here. Pavilion and CDCK (Discourse.org) are discussing building an ActivityPub plugin for Discourse. After some discussion, we’ve landed on the spec below. Any comments or suggestions welcome before we finalise it. Note that

  • Support for incoming content (e.g. posts on Mastodon etc being imported into Discourse) is intentionally excluded. It will be possible to add this in a later version.

  • Support for following users (as opposed to categories) is also intentionally excluded. It would also be possible to add this in a later version.

  • Substantial parts of the specification are following the approach taken by Lemmy.

  • Pavilion will be building the MVP plugin (I’ll be working on it), and CDCK will own and host it (i.e. it will be a CDCK plugin, not a Pavilion plugin).

Overview

An ActivityPub (AP) Plugin for Discourse.

The goal of the plugin is an MVP implementation of the ActivityPub, ActivityVocab and ActivityStreams specs in Discourse with one demonstrated integration of the MVP functionality for an AP compliant platform, namely Mastodon. As far as possible, the implementation will be built to support further support of the protocols, and any extensions.

This specification concerns enabling AP support on a per-category basis where only the first post in each topic in an AP-enabled category is federated (“first post only”).

Users

The plugin usage will be documented comprehensively on meta in a plugin topic.

Normal User

  1. Subscribes to (aka “follows”) a federation-enabled Discourse category (FDC) on Mastodon (or any other fediverse service) using the category’s handle, e.g. @announcements@meta.discourse.org.

  2. Sees an excerpt of the first post of all FDC topics (posted after they subscribe) in their Mastodon feed, each with a link back to the associated topic, e.g. “Discuss on our forum”.

  3. Any action related to the post in Mastodon does not appear in Discourse.

  4. Any action related to the post in Discourse does not appear in Mastodon.

  5. Federated posts excerpts can be controlled by the post author using markup similar to that used to control topic excerpts, e.g. <div class="note">{text}</div>

Admin

  1. Enables federation on a per-category basis using a category setting. Federation can only be enabled in categories visible to “everyone” on public instances.

  2. Sets the category’s federated username via the category settings UI (cannot be changed).

  3. Sets allow and deny lists of domains via site settings from which activity is automatically accepted or rejected.

  4. Sets a “block list” of federated usernames to be part of a Block object(s) in the server outbox.

  5. Sets the maximum character length of a federated note using a site setting i.e. activitypub_note_excerpt_maxlength.

  6. Sets the text associated with the link included in the first post of a federated Discourse topic in “Customize > Text”.

  7. Sets whether the link back (and text) to the forum is included in federated posts on a per-category basis.

  8. Adds a key pair via site settings to sign federated content with.

Technical

  1. The plugin will include comprehensive testing (unit / integration and js tests).

  2. The category is an automated ActivityPub Actor within Discourse (as a Group ActorType). The federated preferredUsername is set at by the admin when enabling federation and stored in a category custom field. The federated name (aka display name) is the full_name of the category.

  3. Users are Actors in the content federated by the category Actor. The federated preferredUsername is the user’s Discourse username at the time of federation. A user’s preferredUsername is stored in a user custom field in case the user changes their Discourse username. The federated name (aka display name) is the user’s Discourse name.

  4. In general, ActivityPub objects will be associated with their equivalent Discourse objects using custom fields where appropriate (e.g. object or actor ids), and new tables where appropriate (e.g. inbox and outbox).

  5. The primary ActivityPub Activity to implement is Follow and associated activities and models required to implement it, i.e. inbox, outbox and required associated Actions and Collections.

  6. Discourse posts would be federated as ActivityStream Notes, with the content as HTML.

  7. Authentication will be handled using HTTP Signatures, see here and here. All other Security Considerations in the ActivityPub spec will be addressed as appropriate.

  8. Federation endpoints will be protected as appropriate for the specification, i.e. ensure redirect_to_login_if_required is used in controllers, add guardian for category everyone can see permission.

34 Likes