ForceBotUnlistedPolicy: format

This commit is contained in:
Alibek Omarov 2020-09-07 22:53:45 +02:00 committed by Gitea
parent 57cf0cc3b3
commit 8b695c3eeb
2 changed files with 21 additions and 20 deletions

View File

@ -21,14 +21,14 @@ defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy do
@impl true @impl true
def filter( def filter(
%{ %{
"type" => "Create", "type" => "Create",
"to" => to, "to" => to,
"cc" => cc, "cc" => cc,
"actor" => actor, "actor" => actor,
"object" => object "object" => object
} = message } = message
) do ) do
user = User.get_cached_by_ap_id(actor) user = User.get_cached_by_ap_id(actor)
isbot = 0.8 < botness_score(user) isbot = 0.8 < botness_score(user)

View File

@ -10,18 +10,19 @@ defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicyTest do
defp generate_messages(actor) do defp generate_messages(actor) do
{%{ {%{
"actor" => actor.ap_id, "actor" => actor.ap_id,
"type" => "Create", "type" => "Create",
"object" => %{}, "object" => %{},
"to" => [@public, "f"], "to" => [@public, "f"],
"cc" => [actor.follower_address, "d"] "cc" => [actor.follower_address, "d"]
}, %{ },
"actor" => actor.ap_id, %{
"type" => "Create", "actor" => actor.ap_id,
"object" => %{"to" => ["f", actor.follower_address], "cc" => ["d", @public]}, "type" => "Create",
"to" => ["f", actor.follower_address], "object" => %{"to" => ["f", actor.follower_address], "cc" => ["d", @public]},
"cc" => ["d", @public] "to" => ["f", actor.follower_address],
}} "cc" => ["d", @public]
}}
end end
test "removes from the federated timeline by nickname heuristics 1" do test "removes from the federated timeline by nickname heuristics 1" do