added checks for public url and follower collections
This commit is contained in:
parent
ac72b578da
commit
1d727cd069
@ -14,6 +14,23 @@ defp delist_message(message) do
|
|||||||
|> Map.put("cc", ["https://www.w3.org/ns/activitystreams#Public"])
|
|> Map.put("cc", ["https://www.w3.org/ns/activitystreams#Public"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp get_recipient_count(message) do
|
||||||
|
recipients = (message["to"] || []) ++ (message["cc"] || [])
|
||||||
|
|
||||||
|
cond do
|
||||||
|
Enum.member?(recipients, "https://www.w3.org/ns/activitystreams#Public") &&
|
||||||
|
Enum.find(recipients, &String.ends_with?(&1, "/followers")) ->
|
||||||
|
length(recipients) - 2
|
||||||
|
|
||||||
|
Enum.member?(recipients, "https://www.w3.org/ns/activitystreams#Public") ||
|
||||||
|
Enum.find(recipients, &String.ends_with?(&1, "/followers")) ->
|
||||||
|
length(recipients) - 1
|
||||||
|
|
||||||
|
true ->
|
||||||
|
length(recipients)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def filter(%{"type" => "Create"} = message) do
|
def filter(%{"type" => "Create"} = message) do
|
||||||
delist_threshold = Pleroma.Config.get([:mrf_hellthread, :delist_threshold])
|
delist_threshold = Pleroma.Config.get([:mrf_hellthread, :delist_threshold])
|
||||||
@ -24,13 +41,13 @@ def filter(%{"type" => "Create"} = message) do
|
|||||||
Pleroma.Config.get([:mrf_hellthread, :threshold])
|
Pleroma.Config.get([:mrf_hellthread, :threshold])
|
||||||
)
|
)
|
||||||
|
|
||||||
recipients = (message["to"] || []) ++ (message["cc"] || [])
|
recipients = get_recipient_count(message)
|
||||||
|
|
||||||
cond do
|
cond do
|
||||||
length(recipients) > reject_threshold and reject_threshold > 0 ->
|
recipients > reject_threshold and reject_threshold > 0 ->
|
||||||
{:reject, nil}
|
{:reject, nil}
|
||||||
|
|
||||||
length(recipients) > delist_threshold and delist_threshold > 0 ->
|
recipients > delist_threshold and delist_threshold > 0 ->
|
||||||
if Enum.member?(message["to"], "https://www.w3.org/ns/activitystreams#Public") or
|
if Enum.member?(message["to"], "https://www.w3.org/ns/activitystreams#Public") or
|
||||||
Enum.member?(message["cc"], "https://www.w3.org/ns/activitystreams#Public") do
|
Enum.member?(message["cc"], "https://www.w3.org/ns/activitystreams#Public") do
|
||||||
{:ok, delist_message(message)}
|
{:ok, delist_message(message)}
|
||||||
|
Loading…
Reference in New Issue
Block a user