From 51e9977d558d218431c1af121e974425ed5a1aba Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 5 Oct 2020 15:23:39 -0700 Subject: [PATCH] Received bytes, expecting a string This doesn't seem like a *good* solution, but I'm not sure why sometimes this receives strings and sometimes bytes (maybe it's based on how the data is served). --- bookwyrm/incoming.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index 144400f9e..54e2fb24a 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -37,7 +37,10 @@ def shared_inbox(request): return HttpResponseNotFound() try: - activity = json.loads(request.body) + resp = request.body + if isinstance(resp, bytes): + resp = json.loads(resp) + activity = json.loads(resp) activity_object = activity['object'] except (json.decoder.JSONDecodeError, KeyError): return HttpResponseBadRequest()