Skip to content
Snippets Groups Projects
Verified Commit 73cfcbd1 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fixed broken json parsing

parent ffca67ef
No related branches found
No related tags found
No related merge requests found
from django.conf import settings
from django.utils import timezone
import json
from .. import providers
from . import activitypub
......@@ -38,6 +39,7 @@ class Activitypub(Source):
]
async def get(self, lookup, session, cache):
try:
actor_data = await cache.get("activitypub:profile:{}".format(lookup))
except cache.NotFound:
......@@ -45,7 +47,8 @@ class Activitypub(Source):
lookup, headers={"Accept": "application/activity+json"}
) as response:
response.raise_for_status()
actor_data = await response.json()
text = await response.read()
actor_data = json.loads(text)
await cache.set("activitypub:profile:{}".format(lookup), actor_data)
serializer = activitypub.ActorSerializer(data=actor_data)
serializer.is_valid(raise_exception=True)
......@@ -55,7 +58,7 @@ class Activitypub(Source):
data = {
"links": activitypub.extract_urls_from_attachments(
serializer.validated_data["attachment"]
serializer.validated_data.get("attachment", [])
)
+ activitypub.extract_urls_from_summary(
serializer.validated_data["summary"]
......
import json
from rest_framework import serializers
from . import exceptions
......@@ -19,7 +21,8 @@ async def lookup(name, session, cache):
params={"resource": "acct:{}".format(name)},
) as response:
response.raise_for_status()
payload = await response.json()
text = await response.read()
payload = json.loads(text)
await cache.set("webfinger:links:{}".format(name), payload)
return payload
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment