Another fix to content types accepted by activitypub_object_view

merge-requests/132/head
Jason Robinson 2018-09-30 17:52:09 +03:00
rodzic 882711a31a
commit bc99fe42b4
2 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -12,11 +12,17 @@ def activitypub_object_view(func):
type doesn't match.
"""
def inner(request, *args, **kwargs):
if request.META.get('HTTP_ACCEPT') not in (
'application/json', 'application/activity+json', 'application/ld+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
fallback = True
accept = request.META.get('HTTP_ACCEPT', '')
for content_type in (
'application/json', 'application/activity+json', 'application/ld+json',
):
if accept.find(content_type) > -1:
fallback = False
break
if fallback:
return func(request, *args, **kwargs)
get_object_function = get_function_from_config('get_object_function')
obj = get_object_function(request.build_absolute_uri())
if not obj:

Wyświetl plik

@ -24,6 +24,7 @@ class TestActivityPubObjectView:
@pytest.mark.parametrize('content_type', (
'application/json', 'application/activity+json', 'application/ld+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'application/activity+json, application/ld+json',
))
def test_renders_as2(self, content_type):
request = RequestFactory().get("/", HTTP_ACCEPT=content_type)
@ -37,6 +38,7 @@ class TestActivityPubObjectView:
@pytest.mark.parametrize('content_type', (
'application/json', 'application/activity+json', 'application/ld+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'application/activity+json, application/ld+json',
))
def test_renders_as2__cbv(self, content_type):
request = RequestFactory().get("/", HTTP_ACCEPT=content_type)