ActivityPub: implement MRF core hook and baseline noop policy object
This commit is contained in:
parent
fef8daa454
commit
4a178b3d65
@ -52,7 +52,8 @@ config :pleroma, :instance,
|
|||||||
limit: 5000,
|
limit: 5000,
|
||||||
upload_limit: 16_000_000,
|
upload_limit: 16_000_000,
|
||||||
registrations_open: true,
|
registrations_open: true,
|
||||||
federating: true
|
federating: true,
|
||||||
|
rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy
|
||||||
|
|
||||||
config :pleroma, :media_proxy,
|
config :pleroma, :media_proxy,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
@ -10,6 +10,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||||||
|
|
||||||
@httpoison Application.get_env(:pleroma, :httpoison)
|
@httpoison Application.get_env(:pleroma, :httpoison)
|
||||||
|
|
||||||
|
@instance Application.get_env(:pleroma, :instance)
|
||||||
|
@rewrite_policy Keyword.get(@instance, :rewrite_policy)
|
||||||
|
|
||||||
def get_recipients(data) do
|
def get_recipients(data) do
|
||||||
(data["to"] || []) ++ (data["cc"] || [])
|
(data["to"] || []) ++ (data["cc"] || [])
|
||||||
end
|
end
|
||||||
@ -17,7 +20,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||||||
def insert(map, local \\ true) when is_map(map) do
|
def insert(map, local \\ true) when is_map(map) do
|
||||||
with nil <- Activity.get_by_ap_id(map["id"]),
|
with nil <- Activity.get_by_ap_id(map["id"]),
|
||||||
map <- lazy_put_activity_defaults(map),
|
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} =
|
{:ok, activity} =
|
||||||
Repo.insert(%Activity{
|
Repo.insert(%Activity{
|
||||||
data: map,
|
data: map,
|
||||||
|
8
lib/pleroma/web/activity_pub/mrf/drop_policy.ex
Normal file
8
lib/pleroma/web/activity_pub/mrf/drop_policy.ex
Normal 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
|
5
lib/pleroma/web/activity_pub/mrf/noop_policy.ex
Normal file
5
lib/pleroma/web/activity_pub/mrf/noop_policy.ex
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
defmodule Pleroma.Web.ActivityPub.MRF.NoOpPolicy do
|
||||||
|
def filter(object) do
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user