forked from mirrors/bookwyrm
Check unsupported types before attempting to serialize
This commit is contained in:
parent
fd43b56d31
commit
b2775c5160
2 changed files with 3 additions and 3 deletions
|
@ -39,12 +39,12 @@ def naive_parse(activity_objects, activity_json, serializer=None):
|
||||||
activity_json["type"] = "PublicKey"
|
activity_json["type"] = "PublicKey"
|
||||||
|
|
||||||
activity_type = activity_json.get("type")
|
activity_type = activity_json.get("type")
|
||||||
|
if activity_type in ["Question", "Article"]:
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
serializer = activity_objects[activity_type]
|
serializer = activity_objects[activity_type]
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
# we know this exists and that we can't handle it
|
# we know this exists and that we can't handle it
|
||||||
if activity_type in ["Question", "Article"]:
|
|
||||||
return None
|
|
||||||
raise ActivitySerializerError(err)
|
raise ActivitySerializerError(err)
|
||||||
|
|
||||||
return serializer(activity_objects=activity_objects, **activity_json)
|
return serializer(activity_objects=activity_objects, **activity_json)
|
||||||
|
|
|
@ -219,7 +219,7 @@ class InboxCreate(TestCase):
|
||||||
views.inbox.activity_task(activity)
|
views.inbox.activity_task(activity)
|
||||||
|
|
||||||
def test_create_unsupported_type_article(self, *_):
|
def test_create_unsupported_type_article(self, *_):
|
||||||
""" special case in unsupported type because we do know what it is"""
|
"""special case in unsupported type because we do know what it is"""
|
||||||
activity = self.create_json
|
activity = self.create_json
|
||||||
activity["object"] = {
|
activity["object"] = {
|
||||||
"id": "https://example.com/status/887",
|
"id": "https://example.com/status/887",
|
||||||
|
|
Loading…
Reference in a new issue