diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index a52df0de3..a3e7e5353 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -146,4 +146,23 @@ def is_unicode_emoji?(unquote(emoji)), do: true end def is_unicode_emoji?(_), do: false + + def stripped_name(name) when is_binary(name) do + name + |> String.replace_leading(":", "") + |> String.replace_trailing(":", "") + end + + def stripped_name(name), do: name + + def maybe_quote(name) when is_binary(name) do + if is_unicode_emoji?(name) do + name + else + ":#{name}:" + end + end + + def maybe_quote(name), do: name + end diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 37f7a9173..637db3840 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -543,14 +543,10 @@ def fetch_latest_undo(%User{ap_id: ap_id}) do end def get_latest_reaction(internal_activity_id, %{ap_id: ap_id}, emoji) do + IO.inspect(emoji) %{data: %{"object" => object_ap_id}} = Activity.get_by_id(internal_activity_id) - emoji = - if String.starts_with?(emoji, ":") do - emoji - else - ":#{emoji}:" - end + emoji = Pleroma.Emoji.maybe_quote(emoji) "EmojiReact" |> Activity.Queries.by_type()