fix quoting of custom emoji

Fixes #3
This commit is contained in:
FloatingGhost 2022-06-11 14:08:13 +01:00
parent 8dd7daf5ee
commit 71f4281850
2 changed files with 21 additions and 6 deletions

View file

@ -146,4 +146,23 @@ defmodule Pleroma.Emoji do
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

View file

@ -543,14 +543,10 @@ defmodule Pleroma.Web.ActivityPub.Utils 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()