2018-12-23 13:04:54 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2018-12-31 08:41:47 -07:00
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 13:04:54 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-12-22 15:18:31 -07:00
|
|
|
defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
|
|
|
|
@behaviour Pleroma.Web.ActivityPub.MRF
|
|
|
|
|
|
|
|
@impl true
|
2018-12-23 04:24:53 -07:00
|
|
|
def filter(%{"type" => "Create"} = object) do
|
|
|
|
threshold = Pleroma.Config.get([:mrf_hellthread, :threshold])
|
|
|
|
recipients = (object["to"] || []) ++ (object["cc"] || [])
|
2018-12-22 15:18:31 -07:00
|
|
|
|
2018-12-23 04:24:53 -07:00
|
|
|
if length(recipients) > threshold do
|
2018-12-22 15:18:31 -07:00
|
|
|
{:reject, nil}
|
|
|
|
else
|
|
|
|
{:ok, object}
|
|
|
|
end
|
|
|
|
end
|
2018-12-23 04:24:53 -07:00
|
|
|
|
|
|
|
@impl true
|
|
|
|
def filter(object), do: {:ok, object}
|
2018-12-22 15:32:38 -07:00
|
|
|
end
|