ActivityPub: implement MRF core hook and baseline noop policy object

This commit is contained in:
William Pitcock 2018-04-14 09:20:18 +00:00
parent fef8daa454
commit 4a178b3d65
4 changed files with 20 additions and 2 deletions

View file

@ -52,7 +52,8 @@ config :pleroma, :instance,
limit: 5000,
upload_limit: 16_000_000,
registrations_open: true,
federating: true
federating: true,
rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy
config :pleroma, :media_proxy,
enabled: false,

View file

@ -10,6 +10,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
@httpoison Application.get_env(:pleroma, :httpoison)
@instance Application.get_env(:pleroma, :instance)
@rewrite_policy Keyword.get(@instance, :rewrite_policy)
def get_recipients(data) do
(data["to"] || []) ++ (data["cc"] || [])
end
@ -17,7 +20,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
def insert(map, local \\ true) when is_map(map) do
with nil <- Activity.get_by_ap_id(map["id"]),
map <- lazy_put_activity_defaults(map),
:ok <- insert_full_object(map) do
:ok <- insert_full_object(map),
{:ok, map} <- @rewrite_policy.filter(map) do
{:ok, activity} =
Repo.insert(%Activity{
data: map,

View file

@ -0,0 +1,8 @@
defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do
require Logger
def filter(object) do
Logger.info("REJECTING #{inspect(object)}")
{:reject, object}
end
end

View file

@ -0,0 +1,5 @@
defmodule Pleroma.Web.ActivityPub.MRF.NoOpPolicy do
def filter(object) do
{:ok, object}
end
end