unbreak polls
This commit is contained in:
parent
736d8ad6be
commit
21dacd4b15
@ -20,6 +20,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
|
|||||||
|> length() > 0
|
|> length() > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp contains_links?(_), do: false
|
||||||
|
|
||||||
def filter(%{"type" => "Create", "actor" => actor, "object" => object} = message) do
|
def filter(%{"type" => "Create", "actor" => actor, "object" => object} = message) do
|
||||||
with {:ok, %User{} = u} <- User.get_or_fetch_by_ap_id(actor),
|
with {:ok, %User{} = u} <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:contains_links, true} <- {:contains_links, contains_links?(object)},
|
{:contains_links, true} <- {:contains_links, contains_links?(object)},
|
||||||
|
@ -22,6 +22,14 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@response_message %{
|
||||||
|
"type" => "Create",
|
||||||
|
"object" => %{
|
||||||
|
"name" => "yes",
|
||||||
|
"type" => "Answer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe "with new user" do
|
describe "with new user" do
|
||||||
test "it allows posts without links" do
|
test "it allows posts without links" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
@ -117,4 +125,16 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do
|
|||||||
{:reject, _} = AntiLinkSpamPolicy.filter(message)
|
{:reject, _} = AntiLinkSpamPolicy.filter(message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "with contentless-objects" do
|
||||||
|
test "it does not reject them or error out" do
|
||||||
|
user = insert(:user, info: %{note_count: 1})
|
||||||
|
|
||||||
|
message =
|
||||||
|
@response_message
|
||||||
|
|> Map.put("actor", user.ap_id)
|
||||||
|
|
||||||
|
{:ok, _message} = AntiLinkSpamPolicy.filter(message)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user