From 50cd1cc5f7b6592fccd3c5cf3f650b5fe658140d Mon Sep 17 00:00:00 2001 From: fef Date: Sat, 3 Dec 2022 08:24:23 +0000 Subject: [PATCH] support Undo action for EmojiReaction --- app/lib/activitypub/activity/undo.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/lib/activitypub/activity/undo.rb b/app/lib/activitypub/activity/undo.rb index 9eff1b71c..54cda1947 100644 --- a/app/lib/activitypub/activity/undo.rb +++ b/app/lib/activitypub/activity/undo.rb @@ -11,6 +11,8 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity undo_follow when 'Like' undo_like + when 'EmojiReact' + undo_emoji_react when 'Block' undo_block when nil @@ -113,6 +115,22 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity end end + def undo_emoji_react + name = @object['content'] + return if name.nil? + + status = status_from_uri(target_uri) + + return if status.nil? || !status.account.local? + + if @account.reacted?(status, name.delete(':')) + reaction = status.status_reactions.where(account: @account, name: name).first + reaction&.destroy + else + delete_later!(object_uri) + end + end + def undo_block target_account = account_from_uri(target_uri)