Merge branch 'merge-upstream' into 'develop'
Merge upstream See merge request soapbox-pub/soapbox!82
This commit is contained in:
commit
f72b9644c0
3 changed files with 33 additions and 3 deletions
|
@ -10,7 +10,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy do
|
|||
require Pleroma.Constants
|
||||
|
||||
defp check_by_actor_type(user), do: user.actor_type in ["Application", "Service"]
|
||||
defp check_by_nickname(user), do: Regex.match?(~r/bot@|ebooks@/i, user.nickname)
|
||||
defp check_by_nickname(user), do: Regex.match?(~r/.bot@|ebooks@/i, user.nickname)
|
||||
|
||||
defp check_if_bot(user), do: check_by_actor_type(user) or check_by_nickname(user)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue