Remove _misskey_reaction matching
This commit is contained in:
parent
08dfce98be
commit
c5838ebb43
4 changed files with 14 additions and 25 deletions
|
@ -21,6 +21,7 @@ defmodule Pleroma.Emoji do
|
|||
:named_table,
|
||||
{:read_concurrency, true}
|
||||
]
|
||||
@emoji_regex ~r/:[A-Za-z0-9_-]+(@.+)?:/
|
||||
|
||||
defstruct [:code, :file, :tags, :safe_code, :safe_file]
|
||||
|
||||
|
@ -205,4 +206,7 @@ def fully_qualify_emoji(unquote(unqualified)), do: unquote(qualified)
|
|||
end
|
||||
|
||||
def fully_qualify_emoji(emoji), do: emoji
|
||||
|
||||
def matches_shortcode?(nil), do: false
|
||||
def matches_shortcode?(s), do: Regex.match?(@emoji_regex, s)
|
||||
end
|
||||
|
|
|
@ -13,7 +13,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
|
|||
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||
|
||||
@primary_key false
|
||||
@emoji_regex ~r/:[A-Za-z0-9_-]+(@.+)?:/
|
||||
|
||||
embedded_schema do
|
||||
quote do
|
||||
|
@ -75,9 +74,6 @@ defp fix(data) do
|
|||
end
|
||||
end
|
||||
|
||||
defp matches_shortcode?(nil), do: false
|
||||
defp matches_shortcode?(s), do: Regex.match?(@emoji_regex, s)
|
||||
|
||||
defp fix_emoji_qualification(%{"content" => emoji} = data) do
|
||||
new_emoji = Pleroma.Emoji.fully_qualify_emoji(emoji)
|
||||
|
||||
|
@ -98,7 +94,7 @@ defp fix_emoji_qualification(data), do: data
|
|||
defp validate_emoji(cng) do
|
||||
content = get_field(cng, :content)
|
||||
|
||||
if Emoji.is_unicode_emoji?(content) || matches_shortcode?(content) do
|
||||
if Emoji.is_unicode_emoji?(content) || Emoji.matches_shortcode?(content) do
|
||||
cng
|
||||
else
|
||||
cng
|
||||
|
|
|
@ -419,28 +419,17 @@ def handle_incoming(%{"id" => id}, _options) when is_binary(id) and byte_size(id
|
|||
def handle_incoming(
|
||||
%{
|
||||
"type" => "Like",
|
||||
"_misskey_reaction" => reaction,
|
||||
"tag" => _
|
||||
"content" => reaction
|
||||
} = data,
|
||||
options
|
||||
) do
|
||||
data
|
||||
|> Map.put("type", "EmojiReact")
|
||||
|> Map.put("content", reaction)
|
||||
|> handle_incoming(options)
|
||||
end
|
||||
|
||||
def handle_incoming(
|
||||
%{
|
||||
"type" => "Like",
|
||||
"_misskey_reaction" => reaction
|
||||
} = data,
|
||||
options
|
||||
) do
|
||||
data
|
||||
|> Map.put("type", "EmojiReact")
|
||||
|> Map.put("content", reaction)
|
||||
|> handle_incoming(options)
|
||||
if Pleroma.Emoji.is_unicode_emoji?(reaction) or Pleroma.Emoji.matches_shortcode?(reaction) do
|
||||
data
|
||||
|> Map.put("type", "EmojiReact")
|
||||
|> handle_incoming(options)
|
||||
else
|
||||
handle_incoming(options)
|
||||
end
|
||||
end
|
||||
|
||||
def handle_incoming(
|
||||
|
|
|
@ -63,7 +63,7 @@ test "it works for incoming misskey likes that contain unicode emojis, turning t
|
|||
File.read!("test/fixtures/misskey-like.json")
|
||||
|> Jason.decode!()
|
||||
|> Map.put("object", activity.data["object"])
|
||||
|> Map.put("_misskey_reaction", "⭐")
|
||||
|> Map.put("content", "⭐")
|
||||
|
||||
_actor = insert(:user, ap_id: data["actor"], local: false)
|
||||
|
||||
|
|
Loading…
Reference in a new issue