ForceMentionsInContent: don't apply it to top-level posts
This commit is contained in:
parent
2bab9dd175
commit
27cb3d6273
@ -72,8 +72,13 @@ defmodule Pleroma.Web.ActivityPub.MRF.ForceMentionsInContent do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(%{"type" => "Create", "object" => %{"type" => "Note", "to" => to}} = object)
|
def filter(
|
||||||
when is_list(to) do
|
%{
|
||||||
|
"type" => "Create",
|
||||||
|
"object" => %{"type" => "Note", "to" => to, "inReplyTo" => in_reply_to}
|
||||||
|
} = object
|
||||||
|
)
|
||||||
|
when is_list(to) and is_binary(in_reply_to) do
|
||||||
# image-only posts from pleroma apparently reach this MRF without the content field
|
# image-only posts from pleroma apparently reach this MRF without the content field
|
||||||
content = object["object"]["content"] || ""
|
content = object["object"]["content"] || ""
|
||||||
|
|
||||||
|
@ -109,4 +109,29 @@ defmodule Pleroma.Web.ActivityPub.MRF.ForceMentionsInContentTest do
|
|||||||
{:ok, %{"object" => %{"content" => filtered}}} = ForceMentionsInContent.filter(activity)
|
{:ok, %{"object" => %{"content" => filtered}}} = ForceMentionsInContent.filter(activity)
|
||||||
assert filtered == "I'ma tired..."
|
assert filtered == "I'ma tired..."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "don't mention in top-level posts" do
|
||||||
|
mario = insert(:user, nickname: "mario")
|
||||||
|
luigi = insert(:user, nickname: "luigi")
|
||||||
|
|
||||||
|
{:ok, post} = CommonAPI.post(mario, %{status: "Letsa go"})
|
||||||
|
|
||||||
|
activity = %{
|
||||||
|
"type" => "Create",
|
||||||
|
"actor" => mario.ap_id,
|
||||||
|
"object" => %{
|
||||||
|
"type" => "Note",
|
||||||
|
"actor" => mario.ap_id,
|
||||||
|
"content" => "Mama mia!",
|
||||||
|
"to" => [
|
||||||
|
luigi.ap_id,
|
||||||
|
Constants.as_public()
|
||||||
|
],
|
||||||
|
"quoteUrl" => Object.normalize(post).data["id"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{:ok, %{"object" => %{"content" => filtered}}} = ForceMentionsInContent.filter(activity)
|
||||||
|
assert filtered == "Mama mia!"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user