mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 07:49:29 +00:00
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.
This commit is contained in:
8
app/controllers/api/v1/extensions_controller.rb
Normal file
8
app/controllers/api/v1/extensions_controller.rb
Normal 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
|
||||
@@ -238,6 +238,8 @@ Rails.application.routes.draw do
|
||||
post :unmute
|
||||
end
|
||||
end
|
||||
|
||||
resources :extensions, only: :list
|
||||
end
|
||||
|
||||
namespace :web do
|
||||
|
||||
17
lib/mastodon/extensions.rb
Normal file
17
lib/mastodon/extensions.rb
Normal 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
|
||||
Reference in New Issue
Block a user