From 731164d0057f35991bbede48967b7f30e285b71b Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 3 Jan 2024 22:17:59 +0100 Subject: [PATCH] Feature: Implement FEP-2677 allowing discovery of the instance application actor --- app/serializers/node_info/discovery_serializer.rb | 5 ++++- spec/requests/well_known/node_info_spec.rb | 4 ++++ spec/routing/well_known_routes_spec.rb | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/serializers/node_info/discovery_serializer.rb b/app/serializers/node_info/discovery_serializer.rb index 07ab2a6eee..bb9e738522 100644 --- a/app/serializers/node_info/discovery_serializer.rb +++ b/app/serializers/node_info/discovery_serializer.rb @@ -6,6 +6,9 @@ class NodeInfo::DiscoverySerializer < ActiveModel::Serializer attribute :links def links - [{ rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', href: nodeinfo_schema_url }] + [ + { rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', href: nodeinfo_schema_url }, + { rel: 'https://www.w3.org/ns/activitystreams#Application', href: instance_actor_url }, + ] end end diff --git a/spec/requests/well_known/node_info_spec.rb b/spec/requests/well_known/node_info_spec.rb index 0934b0fde6..c62d7ac467 100644 --- a/spec/requests/well_known/node_info_spec.rb +++ b/spec/requests/well_known/node_info_spec.rb @@ -19,6 +19,10 @@ describe 'The well-known node-info endpoints' do include( rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', href: include('nodeinfo/2.0') + ), + include( + rel: 'https://www.w3.org/ns/activitystreams#Application', + href: end_with('/actor') ) ) ) diff --git a/spec/routing/well_known_routes_spec.rb b/spec/routing/well_known_routes_spec.rb index 8cf08c13c1..63d0867bc9 100644 --- a/spec/routing/well_known_routes_spec.rb +++ b/spec/routing/well_known_routes_spec.rb @@ -16,4 +16,16 @@ describe 'Well Known routes' do .to route_to('well_known/webfinger#show') end end + + describe 'the nodeinfo routes' do + it 'routes to discovery (index) route' do + expect(get('/.well-known/nodeinfo')) + .to route_to('well_known/node_info#index', format: 'json') + end + + it 'routes to the show route' do + expect(get('/nodeinfo/2.0')) + .to route_to('well_known/node_info#show') + end + end end