Catch error in serializing unknown boosts

This commit is contained in:
Mouse Reeve
2021-03-13 08:13:20 -08:00
parent 1f4b3e9586
commit 919b166241
4 changed files with 25 additions and 7 deletions

View File

@ -115,13 +115,18 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
def ignore_activity(cls, activity):
""" keep notes if they are replies to existing statuses """
if activity.type == "Announce":
# keep it if the booster or the boosted are local
boosted = activitypub.resolve_remote_id(activity.object, save=False)
try:
boosted = activitypub.resolve_remote_id(activity.object, save=False)
except activitypub.ActivitySerializerError:
# if we can't load the status, definitely ignore it
return True
# keep the boost if we would keep the status
return cls.ignore_activity(boosted.to_activity_dataclass())
# keep if it if it's a custom type
if activity.type != "Note":
return False
# keep it if it's a reply to an existing status
if cls.objects.filter(remote_id=activity.inReplyTo).exists():
return False