diff options
author | Andrew Godwin | 2022-12-15 13:47:12 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-12-15 13:47:12 -0700 |
commit | 13fd3785f276f028d945621374b5b0088a8a469c (patch) | |
tree | ccd5802925d540460c7e022878c9eca7e7f17bcb /activities/models | |
parent | c5f52581c9ff808517bc340cd6bba2b1a0f8a4a7 (diff) | |
download | takahe-13fd3785f276f028d945621374b5b0088a8a469c.tar.gz takahe-13fd3785f276f028d945621374b5b0088a8a469c.tar.bz2 takahe-13fd3785f276f028d945621374b5b0088a8a469c.zip |
Handle updates for already deleted posts
Diffstat (limited to 'activities/models')
-rw-r--r-- | activities/models/post.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activities/models/post.py b/activities/models/post.py index 97ee0e0..599a1ea 100644 --- a/activities/models/post.py +++ b/activities/models/post.py @@ -643,7 +643,7 @@ class Post(StatorModel): ) created = True else: - raise KeyError(f"No post with ID {data['id']}", data) + raise cls.DoesNotExist(f"No post with ID {data['id']}", data) if update or created: post.content = data["content"] post.summary = data.get("summary") @@ -755,7 +755,11 @@ class Post(StatorModel): if data["actor"] != data["object"]["attributedTo"]: raise ValueError("Create actor does not match its Post object", data) # Find it and update it - cls.by_ap(data["object"], create=False, update=True) + try: + cls.by_ap(data["object"], create=False, update=True) + except cls.DoesNotExist: + # We don't have a copy - assume we got a delete first and ignore. + pass @classmethod def handle_delete_ap(cls, data): |