Don't crash trying to fetch parents we don't have

This commit is contained in:
Andrew Godwin 2022-12-20 15:02:20 +00:00
parent d1e398a7b7
commit 12a838eb0e

View file

@ -67,6 +67,8 @@ class PostService:
ancestor = self.post
while ancestor.in_reply_to and len(ancestors) < num_ancestors:
ancestor = cast(Post, ancestor.in_reply_to_post())
if ancestor is None:
break
if ancestor.state in [PostStates.deleted, PostStates.deleted_fanned_out]:
break
ancestors.append(ancestor)