Commit a146f6ac authored by Alex Gleason's avatar Alex Gleason
Browse files

Merge branch 'mentions-mrf-replies-only' into 'develop'

ForceMentionsInContent: don't apply it to top-level posts

See merge request pleroma/pleroma!3624
parents 2bab9dd1 27cb3d62
Pipeline #38890 passed with stages
in 69 minutes and 55 seconds
......@@ -72,8 +72,13 @@ defp clean_recipients(recipients, object) do
end
@impl true
def filter(%{"type" => "Create", "object" => %{"type" => "Note", "to" => to}} = object)
when is_list(to) do
def filter(
%{
"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
content = object["object"]["content"] || ""
......
......@@ -109,4 +109,29 @@ test "don't mention self" do
{:ok, %{"object" => %{"content" => filtered}}} = ForceMentionsInContent.filter(activity)
assert filtered == "I'ma tired..."
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment