Skip to content
Snippets Groups Projects
Commit cda1406a authored by Agate's avatar Agate :speech_balloon:
Browse files

Merge branch 'patch-1' into 'develop'

Handle invalid JSON returned by nodeinfo endpoint

Closes #1057

See merge request !1201
parents d4a256b2 36bbc5c0
No related branches found
No related tags found
No related merge requests found
import json import json
import logging
from django.conf import settings from django.conf import settings
...@@ -18,6 +19,9 @@ from . import nodeinfo ...@@ -18,6 +19,9 @@ from . import nodeinfo
NODEINFO_2_CONTENT_TYPE = "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8" # noqa NODEINFO_2_CONTENT_TYPE = "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8" # noqa
logger = logging.getLogger(__name__)
class AdminSettings(preferences_viewsets.GlobalPreferencesViewSet): class AdminSettings(preferences_viewsets.GlobalPreferencesViewSet):
pagination_class = None pagination_class = None
permission_classes = [oauth_permissions.ScopePermission] permission_classes = [oauth_permissions.ScopePermission]
...@@ -44,7 +48,11 @@ class NodeInfo(views.APIView): ...@@ -44,7 +48,11 @@ class NodeInfo(views.APIView):
authentication_classes = [] authentication_classes = []
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
try:
data = nodeinfo.get() data = nodeinfo.get()
except ValueError:
logger.warn("nodeinfo returned invalid json")
data = {}
return Response(data, status=200, content_type=NODEINFO_2_CONTENT_TYPE) return Response(data, status=200, content_type=NODEINFO_2_CONTENT_TYPE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment