mrf: allow a policy chain to be specified when filtering

This commit is contained in:
William Pitcock 2019-06-02 09:44:42 +00:00
parent 5402d04e3c
commit edf772d41e

View File

@ -5,8 +5,8 @@
defmodule Pleroma.Web.ActivityPub.MRF do defmodule Pleroma.Web.ActivityPub.MRF do
@callback filter(Map.t()) :: {:ok | :reject, Map.t()} @callback filter(Map.t()) :: {:ok | :reject, Map.t()}
def filter(object) do def filter(policies, %{} = object) do
get_policies() policies
|> Enum.reduce({:ok, object}, fn |> Enum.reduce({:ok, object}, fn
policy, {:ok, object} -> policy, {:ok, object} ->
policy.filter(object) policy.filter(object)
@ -16,6 +16,8 @@ def filter(object) do
end) end)
end end
def filter(%{} = object), do: get_policies() |> filter(object)
def get_policies do def get_policies do
Pleroma.Config.get([:instance, :rewrite_policy], []) |> get_policies() Pleroma.Config.get([:instance, :rewrite_policy], []) |> get_policies()
end end