kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
See #192: added .well-known/nodeinfo endpoint
rodzic
6ff8c2c8da
commit
d88b7869fe
|
@ -85,13 +85,31 @@ class InstanceActorViewSet(FederationMixin, viewsets.GenericViewSet):
|
|||
return response.Response({}, status=200)
|
||||
|
||||
|
||||
class WellKnownViewSet(FederationMixin, viewsets.GenericViewSet):
|
||||
class WellKnownViewSet(viewsets.GenericViewSet):
|
||||
authentication_classes = []
|
||||
permission_classes = []
|
||||
renderer_classes = [renderers.WebfingerRenderer]
|
||||
|
||||
@list_route(methods=['get'])
|
||||
def nodeinfo(self, request, *args, **kwargs):
|
||||
if not preferences.get('instance__nodeinfo_enabled'):
|
||||
return HttpResponse(status=404)
|
||||
data = {
|
||||
'links': [
|
||||
{
|
||||
'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.0',
|
||||
'href': utils.full_url(
|
||||
reverse('api:v1:instance:nodeinfo-2.0')
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
return response.Response(data)
|
||||
|
||||
@list_route(methods=['get'])
|
||||
def webfinger(self, request, *args, **kwargs):
|
||||
if not preferences.get('federation__enabled'):
|
||||
return HttpResponse(status=405)
|
||||
try:
|
||||
resource_type, resource = webfinger.clean_resource(
|
||||
request.GET['resource'])
|
||||
|
|
|
@ -70,6 +70,32 @@ def test_wellknown_webfinger_system(
|
|||
assert response.data == serializer.data
|
||||
|
||||
|
||||
def test_wellknown_nodeinfo(db, preferences, api_client, settings):
|
||||
expected = {
|
||||
'links': [
|
||||
{
|
||||
'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.0',
|
||||
'href': '{}{}'.format(
|
||||
settings.FUNKWHALE_URL,
|
||||
reverse('api:v1:instance:nodeinfo-2.0')
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
url = reverse('federation:well-known-nodeinfo')
|
||||
response = api_client.get(url)
|
||||
assert response.status_code == 200
|
||||
assert response['Content-Type'] == 'application/jrd+json'
|
||||
assert response.data == expected
|
||||
|
||||
|
||||
def test_wellknown_nodeinfo_disabled(db, preferences, api_client):
|
||||
preferences['instance__nodeinfo_enabled'] = False
|
||||
url = reverse('federation:well-known-nodeinfo')
|
||||
response = api_client.get(url)
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_audio_file_list_requires_authenticated_actor(
|
||||
db, preferences, api_client):
|
||||
preferences['federation__music_needs_approval'] = True
|
||||
|
|
Ładowanie…
Reference in New Issue