Check unsupported types before attempting to serialize

This commit is contained in:
Mouse Reeve 2022-05-16 10:20:13 -07:00
parent fd43b56d31
commit b2775c5160
2 changed files with 3 additions and 3 deletions

View file

@ -39,12 +39,12 @@ def naive_parse(activity_objects, activity_json, serializer=None):
activity_json["type"] = "PublicKey"
activity_type = activity_json.get("type")
if activity_type in ["Question", "Article"]:
return None
try:
serializer = activity_objects[activity_type]
except KeyError as err:
# we know this exists and that we can't handle it
if activity_type in ["Question", "Article"]:
return None
raise ActivitySerializerError(err)
return serializer(activity_objects=activity_objects, **activity_json)

View file

@ -219,7 +219,7 @@ class InboxCreate(TestCase):
views.inbox.activity_task(activity)
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["object"] = {
"id": "https://example.com/status/887",