Remove _misskey_reaction matching
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details

This commit is contained in:
FloatingGhost 2023-03-10 18:14:40 +00:00
parent 08dfce98be
commit c5838ebb43
4 changed files with 14 additions and 25 deletions

View File

@ -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 @@ defmodule Pleroma.Emoji do
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

View File

@ -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 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator 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 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
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

View File

@ -419,28 +419,17 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
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(

View File

@ -63,7 +63,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
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)