diff options
author | Andrew Godwin | 2022-11-24 17:11:04 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-24 17:11:04 -0700 |
commit | 786d6190f856fddb32157764717f871c6f8cb3fa (patch) | |
tree | 3e7569aba3c09fb58837158755679b0ee04d02b8 /activities/models/fan_out.py | |
parent | 3a608c2012b610a8f9b7e5179dcb93ab2e767251 (diff) | |
download | takahe-786d6190f856fddb32157764717f871c6f8cb3fa.tar.gz takahe-786d6190f856fddb32157764717f871c6f8cb3fa.tar.bz2 takahe-786d6190f856fddb32157764717f871c6f8cb3fa.zip |
Delete mechanics and refactor of post fanout
Diffstat (limited to 'activities/models/fan_out.py')
-rw-r--r-- | activities/models/fan_out.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/activities/models/fan_out.py b/activities/models/fan_out.py index 285ecc2..5eb20f3 100644 --- a/activities/models/fan_out.py +++ b/activities/models/fan_out.py @@ -20,21 +20,43 @@ class FanOutStates(StateGraph): fan_out = await instance.afetch_full() # Handle Posts if fan_out.type == FanOut.Types.post: + post = await fan_out.subject_post.afetch_full() if fan_out.identity.local: # Make a timeline event directly + # TODO: Exclude replies to people we don't follow await sync_to_async(TimelineEvent.add_post)( identity=fan_out.identity, - post=fan_out.subject_post, + post=post, ) + # We might have been mentioned + if fan_out.identity in list(post.mentions.all()): + TimelineEvent.add_mentioned( + identity=fan_out.identity, + post=post, + ) else: - # Send it to the remote inbox - post = await fan_out.subject_post.afetch_full() # Sign it and send it await post.author.signed_request( method="post", uri=fan_out.identity.inbox_uri, body=canonicalise(post.to_create_ap()), ) + # Handle deleting posts + elif fan_out.type == FanOut.Types.post_deleted: + post = await fan_out.subject_post.afetch_full() + if fan_out.identity.local: + # Remove all timeline events mentioning it + await TimelineEvent.objects.filter( + identity=fan_out.identity, + subject_post=post, + ).adelete() + else: + # Send it to the remote inbox + await post.author.signed_request( + method="post", + uri=fan_out.identity.inbox_uri, + body=canonicalise(post.to_delete_ap()), + ) # Handle boosts/likes elif fan_out.type == FanOut.Types.interaction: interaction = await fan_out.subject_post_interaction.afetch_full() @@ -79,6 +101,8 @@ class FanOut(StatorModel): class Types(models.TextChoices): post = "post" + post_edited = "post_edited" + post_deleted = "post_deleted" interaction = "interaction" undo_interaction = "undo_interaction" |