mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-30 17:11:40 +00:00
Merge branch 'feature/mrf-simple-accept-lists' into 'develop'
mrf simple: add accept lists See merge request pleroma/pleroma!231
This commit is contained in:
commit
ad28854f47
|
@ -49,7 +49,8 @@ Restricts the visibility of posts from certain instances.
|
||||||
media_removal: [],
|
media_removal: [],
|
||||||
media_nsfw: [],
|
media_nsfw: [],
|
||||||
federated_timeline_removal: [],
|
federated_timeline_removal: [],
|
||||||
reject: []
|
reject: [],
|
||||||
|
accept: []
|
||||||
|
|
||||||
* `media_removal`: posts from these instances will have attachments
|
* `media_removal`: posts from these instances will have attachments
|
||||||
removed
|
removed
|
||||||
|
@ -58,6 +59,7 @@ Restricts the visibility of posts from certain instances.
|
||||||
* `federated_timeline_removal`: posts from these instances will be
|
* `federated_timeline_removal`: posts from these instances will be
|
||||||
marked as unlisted
|
marked as unlisted
|
||||||
* `reject`: posts from these instances will be dropped
|
* `reject`: posts from these instances will be dropped
|
||||||
|
* `accept`: if not empty, only posts from these instances will be accepted
|
||||||
|
|
||||||
### RejectNonPublic
|
### RejectNonPublic
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,8 @@ config :pleroma, :mrf_simple,
|
||||||
media_removal: [],
|
media_removal: [],
|
||||||
media_nsfw: [],
|
media_nsfw: [],
|
||||||
federated_timeline_removal: [],
|
federated_timeline_removal: [],
|
||||||
reject: []
|
reject: [],
|
||||||
|
accept: []
|
||||||
|
|
||||||
config :pleroma, :media_proxy,
|
config :pleroma, :media_proxy,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|
|
@ -4,6 +4,15 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
|
|
||||||
@mrf_policy Application.get_env(:pleroma, :mrf_simple)
|
@mrf_policy Application.get_env(:pleroma, :mrf_simple)
|
||||||
|
|
||||||
|
@accept Keyword.get(@mrf_policy, :accept)
|
||||||
|
defp check_accept(actor_info, object) do
|
||||||
|
if length(@accept) > 0 and not actor_info.host in @accept do
|
||||||
|
{:reject, nil}
|
||||||
|
else
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@reject Keyword.get(@mrf_policy, :reject)
|
@reject Keyword.get(@mrf_policy, :reject)
|
||||||
defp check_reject(actor_info, object) do
|
defp check_reject(actor_info, object) do
|
||||||
if actor_info.host in @reject do
|
if actor_info.host in @reject do
|
||||||
|
@ -74,7 +83,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
def filter(object) do
|
def filter(object) do
|
||||||
actor_info = URI.parse(object["actor"])
|
actor_info = URI.parse(object["actor"])
|
||||||
|
|
||||||
with {:ok, object} <- check_reject(actor_info, object),
|
with {:ok, object} <- check_accept(actor_info, object),
|
||||||
|
{:ok, object} <- check_reject(actor_info, object),
|
||||||
{:ok, object} <- check_media_removal(actor_info, object),
|
{:ok, object} <- check_media_removal(actor_info, object),
|
||||||
{:ok, object} <- check_media_nsfw(actor_info, object),
|
{:ok, object} <- check_media_nsfw(actor_info, object),
|
||||||
{:ok, object} <- check_ftl_removal(actor_info, object) do
|
{:ok, object} <- check_ftl_removal(actor_info, object) do
|
||||||
|
|
Loading…
Reference in a new issue