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_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)