mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
SimpleMRF: :silence --> :followers_only
This commit is contained in:
parent
2a99e7df8e
commit
93638935d7
4 changed files with 11 additions and 11 deletions
|
@ -1525,7 +1525,7 @@ config :pleroma, :config_description, [
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :silence,
|
key: :followers_only,
|
||||||
type: {:list, :string},
|
type: {:list, :string},
|
||||||
description: "Force posts from the given instances to be visible by followers only",
|
description: "Force posts from the given instances to be visible by followers only",
|
||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
|
|
|
@ -122,7 +122,7 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
* `federated_timeline_removal`: List of instances to remove from Federated (aka The Whole Known Network) Timeline.
|
* `federated_timeline_removal`: List of instances to remove from Federated (aka The Whole Known Network) Timeline.
|
||||||
* `reject`: List of instances to reject any activities from.
|
* `reject`: List of instances to reject any activities from.
|
||||||
* `accept`: List of instances to accept any activities from.
|
* `accept`: List of instances to accept any activities from.
|
||||||
* `silence`: List of instances to force posts as followers-only.
|
* `followers_only`: List of instances to force posts as followers-only.
|
||||||
* `report_removal`: List of instances to reject reports from.
|
* `report_removal`: List of instances to reject reports from.
|
||||||
* `avatar_removal`: List of instances to strip avatars from.
|
* `avatar_removal`: List of instances to strip avatars from.
|
||||||
* `banner_removal`: List of instances to strip banners from.
|
* `banner_removal`: List of instances to strip banners from.
|
||||||
|
|
|
@ -109,13 +109,13 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp check_silence(%{host: actor_host} = _actor_info, object) do
|
defp check_followers_only(%{host: actor_host} = _actor_info, object) do
|
||||||
silence =
|
followers_only =
|
||||||
Config.get([:mrf_simple, :silence])
|
Config.get([:mrf_simple, :followers_only])
|
||||||
|> MRF.subdomains_regex()
|
|> MRF.subdomains_regex()
|
||||||
|
|
||||||
object =
|
object =
|
||||||
with true <- MRF.subdomain_match?(silence, actor_host),
|
with true <- MRF.subdomain_match?(followers_only, actor_host),
|
||||||
user <- User.get_cached_by_ap_id(object["actor"]) do
|
user <- User.get_cached_by_ap_id(object["actor"]) do
|
||||||
# Don't use Map.get/3 intentionally, these must not be nil
|
# Don't use Map.get/3 intentionally, these must not be nil
|
||||||
fixed_to = object["to"] || []
|
fixed_to = object["to"] || []
|
||||||
|
@ -200,7 +200,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
{: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),
|
{:ok, object} <- check_ftl_removal(actor_info, object),
|
||||||
{:ok, object} <- check_silence(actor_info, object),
|
{:ok, object} <- check_followers_only(actor_info, object),
|
||||||
{:ok, object} <- check_report_removal(actor_info, object) do
|
{:ok, object} <- check_report_removal(actor_info, object) do
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
else
|
else
|
||||||
|
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
||||||
federated_timeline_removal: [],
|
federated_timeline_removal: [],
|
||||||
report_removal: [],
|
report_removal: [],
|
||||||
reject: [],
|
reject: [],
|
||||||
silence: [],
|
followers_only: [],
|
||||||
accept: [],
|
accept: [],
|
||||||
avatar_removal: [],
|
avatar_removal: [],
|
||||||
banner_removal: [],
|
banner_removal: [],
|
||||||
|
@ -263,9 +263,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when :silence" do
|
describe "when :followers_only" do
|
||||||
test "is empty" do
|
test "is empty" do
|
||||||
Config.put([:mrf_simple, :silence], [])
|
Config.put([:mrf_simple, :followers_only], [])
|
||||||
{_, ftl_message} = build_ftl_actor_and_message()
|
{_, ftl_message} = build_ftl_actor_and_message()
|
||||||
local_message = build_local_message()
|
local_message = build_local_message()
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
||||||
|> URI.parse()
|
|> URI.parse()
|
||||||
|> Map.fetch!(:host)
|
|> Map.fetch!(:host)
|
||||||
|
|
||||||
Config.put([:mrf_simple, :silence], [actor_domain])
|
Config.put([:mrf_simple, :followers_only], [actor_domain])
|
||||||
|
|
||||||
assert {:ok, new_activity} = SimplePolicy.filter(activity)
|
assert {:ok, new_activity} = SimplePolicy.filter(activity)
|
||||||
assert actor.follower_address in new_activity["to"]
|
assert actor.follower_address in new_activity["to"]
|
||||||
|
|
Loading…
Reference in a new issue