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
-
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
. -
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”.
-
Any action related to the post in Mastodon does not appear in Discourse.
-
Any action related to the post in Discourse does not appear in Mastodon.
-
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
-
Enables federation on a per-category basis using a category setting. Federation can only be enabled in categories visible to “everyone” on public instances.
-
Sets the category’s federated username via the category settings UI (cannot be changed).
-
Sets allow and deny lists of domains via site settings from which activity is automatically accepted or rejected.
-
Sets a “block list” of federated usernames to be part of a Block object(s) in the server outbox.
-
Sets the maximum character length of a federated note using a site setting i.e.
activitypub_note_excerpt_maxlength
. -
Sets the text associated with the link included in the first post of a federated Discourse topic in “Customize > Text”.
-
Sets whether the link back (and text) to the forum is included in federated posts on a per-category basis.
-
Adds a key pair via site settings to sign federated content with.
Technical
-
The plugin will include comprehensive testing (unit / integration and js tests).
-
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.
-
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’spreferredUsername
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. -
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).
-
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.
-
Discourse posts would be federated as ActivityStream Notes, with the content as HTML.
-
Authentication will be handled using HTTP Signatures, see here and here. All other Security Considerations in the ActivityPub spec will be addressed as appropriate.
-
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.