allow undoing
This commit is contained in:
parent
e724da2a42
commit
e910f21d8d
1 changed files with 24 additions and 4 deletions
|
@ -349,10 +349,17 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
) do
|
) do
|
||||||
reactions = get_cached_emoji_reactions(object)
|
reactions = get_cached_emoji_reactions(object)
|
||||||
emoji = stripped_emoji_name(emoji)
|
emoji = stripped_emoji_name(emoji)
|
||||||
|
url = emoji_url(emoji, activity)
|
||||||
new_reactions =
|
new_reactions =
|
||||||
case Enum.find_index(reactions, fn [candidate, _, _] -> emoji == candidate end) do
|
case Enum.find_index(reactions, fn [candidate, _, candidate_url] ->
|
||||||
|
if is_nil(candidate_url) do
|
||||||
|
emoji == candidate
|
||||||
|
else
|
||||||
|
url == candidate_url
|
||||||
|
end
|
||||||
|
end) do
|
||||||
nil ->
|
nil ->
|
||||||
reactions ++ [[emoji, [actor], emoji_url(emoji, activity)]]
|
reactions ++ [[emoji, [actor], url]]
|
||||||
|
|
||||||
index ->
|
index ->
|
||||||
List.update_at(
|
List.update_at(
|
||||||
|
@ -386,12 +393,20 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_emoji_reaction_from_object(
|
def remove_emoji_reaction_from_object(
|
||||||
%Activity{data: %{"content" => emoji, "actor" => actor}},
|
%Activity{data: %{"content" => emoji, "actor" => actor}} = activity,
|
||||||
object
|
object
|
||||||
) do
|
) do
|
||||||
|
emoji = stripped_emoji_name(emoji)
|
||||||
reactions = get_cached_emoji_reactions(object)
|
reactions = get_cached_emoji_reactions(object)
|
||||||
|
url = emoji_url(emoji, activity)
|
||||||
new_reactions =
|
new_reactions =
|
||||||
case Enum.find_index(reactions, fn [candidate, _, _] -> emoji == candidate end) do
|
case Enum.find_index(reactions, fn [candidate, _, candidate_url] ->
|
||||||
|
if is_nil(candidate_url) do
|
||||||
|
emoji == candidate
|
||||||
|
else
|
||||||
|
url == candidate_url
|
||||||
|
end
|
||||||
|
end) do
|
||||||
nil ->
|
nil ->
|
||||||
reactions
|
reactions
|
||||||
|
|
||||||
|
@ -521,6 +536,11 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
|
|
||||||
def get_latest_reaction(internal_activity_id, %{ap_id: ap_id}, emoji) do
|
def get_latest_reaction(internal_activity_id, %{ap_id: ap_id}, emoji) do
|
||||||
%{data: %{"object" => object_ap_id}} = Activity.get_by_id(internal_activity_id)
|
%{data: %{"object" => object_ap_id}} = Activity.get_by_id(internal_activity_id)
|
||||||
|
emoji = if String.starts_with?(emoji, ":") do
|
||||||
|
emoji
|
||||||
|
else
|
||||||
|
":#{emoji}:"
|
||||||
|
end
|
||||||
|
|
||||||
"EmojiReact"
|
"EmojiReact"
|
||||||
|> Activity.Queries.by_type()
|
|> Activity.Queries.by_type()
|
||||||
|
|
Loading…
Reference in a new issue