Compare commits

...

3 commits

Author SHA1 Message Date
Surinna Curtis 8375ed1cfd fix wrong name in extension route 2017-09-23 21:38:58 +00:00
Surinna Curtis 3d80ba01d7 Link the extensions endpoint from AP's "endpoints"
This is in line with cwebber's proposal at
https://github.com/swicg/general/issues/22
2017-09-23 21:04:19 +00:00
Surinna Curtis f02150468b Expose an /api/v1/extensions endpoint.
We don't have any extensions listed or link this in the "endpoints" field on
actors yet. The endpoint also doesn't currently provide a way to expose any
additional metadata about an extension beyond its URL (in part because the
SWICG proposal currently doesn't include that).

We can add extensions to the endpoint's response by calling
Mastodon::Extension::register with the extension URL.
2017-09-23 20:50:46 +00:00
4 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,8 @@
# frozen_string_literal: true
require 'mastodon/extension'
class Api::V1::ExtensionsController < Api::BaseController
def index
render json: Mastodon::Extension.all
end
end

View file

@ -27,7 +27,11 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer
class EndpointsSerializer < ActiveModel::Serializer
include RoutingHelper
attributes :shared_inbox
attributes :extensions, :shared_inbox
def extensions
api_v1_extensions_url
end
def shared_inbox
inbox_url

View file

@ -238,6 +238,8 @@ Rails.application.routes.draw do
post :unmute
end
end
resources :extensions, only: :index
end
namespace :web do

View file

@ -0,0 +1,17 @@
class Mastodon::Extension
@@extensions = []
def self.register url
@extensions << Extension.new(url)
end
def self.all
@extensions
end
def initialize url
@url = url
end
attr_reader :url
end