From 2ef709b6421b238025276aa53bf1c3764696a660 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Tue, 15 Nov 2022 18:36:39 -0700 Subject: Accept incoming action undos --- activities/models/post_interaction.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'activities/models') diff --git a/activities/models/post_interaction.py b/activities/models/post_interaction.py index ea95cdf..4f1eb03 100644 --- a/activities/models/post_interaction.py +++ b/activities/models/post_interaction.py @@ -285,3 +285,18 @@ class PostInteraction(StatorModel): TimelineEvent.add_post_interaction(interaction.post.author, interaction) # Force it into fanned_out as it's not ours interaction.transition_perform(PostInteractionStates.fanned_out) + + @classmethod + def handle_undo_ap(cls, data): + """ + Handles an incoming undo for a announce/like + """ + # Find it + interaction = cls.by_ap(data["object"]) + # Verify the actor matches + if data["actor"] != interaction.identity.actor_uri: + raise ValueError("Actor mismatch on interaction undo") + # Delete all events that reference it + interaction.timeline_events.all().delete() + # Force it into undone_fanned_out as it's not ours + interaction.transition_perform(PostInteractionStates.undone_fanned_out) -- cgit v1.2.3