A Rails engine that implements the non-provider side of the Fediverse Auxiliary Service Provider (FASP) standard.
- Base URL discovery ✅
- Request integrity ✅
- Authentication ✅
- Provider registration ✅
- Accepting registration requests ✅
- Selecting capabilities ✅
- Fetching FASP information ✅
- Discovery APIs
- account_search ✅
- follow_recomendation ✅
- data_sharing ✅ + ⏳ (no backfill yet)
- trends ⏳
Add to your application's Gemfile:
gem "fasp_client"
Install configuration and run migrations (you'll also want to do this when upgrading).
bin/rails generate fasp_client:install && bin/rails db:migrate
You will probably want to customise the view templates used for editing and listing providers. You can copy the default views like so:
bin/rails generate fasp_client:views
Mount the engine in your routes.rb
file:
mount FaspClient::Engine => "/fasp"
Add the base URL to your nodeinfo metadata:
"faspBaseUrl" => Rails.application.routes.url_helpers.fasp_client_url
If you're using Federails, you can add this to the metadata using the configuration option (currently only on the nodeinfo-metadata
branch):
conf.nodeinfo_metadata = -> do
{"faspBaseUrl" => Rails.application.routes.url_helpers.fasp_client_url}
end
Edit config/initializers/fasp_client.rb
and add customise the template authenticate
method. It should return true if the current user should be able to access the provider approval/edit pages.
Once you've done that, you can sign up to FASP providers using the URL of your site, and you should be able to register, approve, and choose capabilities.
Get a list of accounts matching the provided search term, returned as a simple array of account URIs. Provide the optional limit
parameter to control now many results are returned (default = 20).
my_provider.account_search("mastodon", limit: 5)
=> ["https://mastodon.social/users/Gargron"]
Automatically shares data from your app to the FASP on demand. To configure one of your models to be included in data sharing, include the appropriate concern and set the configuration:
class MyModel < ApplicationRecord
include FaspClient::DataSharing::Lifecycle
fasp_share_lifecycle category: "account", uri_method: :my_canonical_uri
def my_canonical_uri
# Any method that returns the canonical activitypub URI for this object
end
end
Only lifecycle events are currently supported, trending events will be implemented in future. Valid categories are currently account
, or content
(see the spec for details).
The actual announcements are then sent to all subscribed providers by a background ActiveJob, using the default
queue. You can set a specific queue name by adding an optional queue
parameter to fasp_share_lifecycle
:
fasp_share_lifecycle category: "account", uri_method: :my_canonical_uri, queue: "fasp_broadcasts"
You can also add an only_if
argument to point to a method that returns true if an item should be shared, allowing you to only share certain items:
fasp_share_lifecycle category: "account", uri_method: :my_canonical_uri, only_if: :public?
Only new lifecycle events are currently sent. Whilst backfill requests can be made, they aren't serviced yet (see #25).
Get a list of follow recommendations, returned as a simple array of account URIs. The account URI argument is required by the spec, but won't necessarily affect the results, depending on the server implementation.
my_provider.follow_recommendation(your_account_uri)
=> [
"https://mastodon.me.uk/users/Floppy",
"https://mastodon.social/users/Gargron"
]
The gem is available as open source under the terms of the MIT License.
This code was originally written for the Manyfold project, which is funded through NGI0 Entrust, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.