Revert "Merge branch 'mrf-silence-2' into 'develop'"
This reverts merge request !2820
This commit is contained in:
parent
1ac0969c72
commit
010d77ec85
@ -1543,12 +1543,6 @@ config :pleroma, :config_description, [
|
|||||||
suggestions: ["example.com", "*.example.com"]
|
suggestions: ["example.com", "*.example.com"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :followers_only,
|
|
||||||
type: {:list, :string},
|
|
||||||
description: "Force posts from the given instances to be visible by followers only",
|
|
||||||
suggestions: ["example.com", "*.example.com"]
|
|
||||||
},
|
|
||||||
%{
|
|
||||||
key: :report_removal,
|
key: :report_removal,
|
||||||
type: {:list, :string},
|
type: {:list, :string},
|
||||||
description: "List of instances to reject reports from",
|
description: "List of instances to reject reports from",
|
||||||
|
@ -125,7 +125,6 @@ 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.
|
||||||
* `followers_only`: List of instances to decrease post visibility to only the followers, including for DM mentions.
|
|
||||||
* `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.
|
||||||
|
@ -95,11 +95,7 @@ defmodule Pleroma.FollowingRelationship do
|
|||||||
|> where([r], r.state == ^:follow_accept)
|
|> where([r], r.state == ^:follow_accept)
|
||||||
end
|
end
|
||||||
|
|
||||||
def followers_ap_ids(user, from_ap_ids \\ nil)
|
def followers_ap_ids(%User{} = user, from_ap_ids \\ nil) do
|
||||||
|
|
||||||
def followers_ap_ids(_, []), do: []
|
|
||||||
|
|
||||||
def followers_ap_ids(%User{} = user, from_ap_ids) do
|
|
||||||
query =
|
query =
|
||||||
user
|
user
|
||||||
|> followers_query()
|
|> followers_query()
|
||||||
|
@ -7,7 +7,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
|||||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.FollowingRelationship
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.MRF
|
alias Pleroma.Web.ActivityPub.MRF
|
||||||
|
|
||||||
@ -109,35 +108,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
|||||||
{:ok, object}
|
{:ok, object}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp intersection(list1, list2) do
|
|
||||||
list1 -- list1 -- list2
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_followers_only(%{host: actor_host} = _actor_info, object) do
|
|
||||||
followers_only =
|
|
||||||
Config.get([:mrf_simple, :followers_only])
|
|
||||||
|> MRF.subdomains_regex()
|
|
||||||
|
|
||||||
object =
|
|
||||||
with true <- MRF.subdomain_match?(followers_only, actor_host),
|
|
||||||
user <- User.get_cached_by_ap_id(object["actor"]) do
|
|
||||||
# Don't use Map.get/3 intentionally, these must not be nil
|
|
||||||
fixed_to = object["to"] || []
|
|
||||||
fixed_cc = object["cc"] || []
|
|
||||||
|
|
||||||
to = FollowingRelationship.followers_ap_ids(user, fixed_to)
|
|
||||||
cc = FollowingRelationship.followers_ap_ids(user, fixed_cc)
|
|
||||||
|
|
||||||
object
|
|
||||||
|> Map.put("to", intersection([user.follower_address | to], fixed_to))
|
|
||||||
|> Map.put("cc", intersection([user.follower_address | cc], fixed_cc))
|
|
||||||
else
|
|
||||||
_ -> object
|
|
||||||
end
|
|
||||||
|
|
||||||
{:ok, object}
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_report_removal(%{host: actor_host} = _actor_info, %{"type" => "Flag"} = object) do
|
defp check_report_removal(%{host: actor_host} = _actor_info, %{"type" => "Flag"} = object) do
|
||||||
report_removal =
|
report_removal =
|
||||||
Config.get([:mrf_simple, :report_removal])
|
Config.get([:mrf_simple, :report_removal])
|
||||||
@ -204,7 +174,6 @@ 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_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
|
||||||
|
@ -7,7 +7,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
|
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
|
||||||
alias Pleroma.Web.CommonAPI
|
|
||||||
|
|
||||||
setup do:
|
setup do:
|
||||||
clear_config(:mrf_simple,
|
clear_config(:mrf_simple,
|
||||||
@ -16,7 +15,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||||||
federated_timeline_removal: [],
|
federated_timeline_removal: [],
|
||||||
report_removal: [],
|
report_removal: [],
|
||||||
reject: [],
|
reject: [],
|
||||||
followers_only: [],
|
|
||||||
accept: [],
|
accept: [],
|
||||||
avatar_removal: [],
|
avatar_removal: [],
|
||||||
banner_removal: [],
|
banner_removal: [],
|
||||||
@ -263,64 +261,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when :followers_only" do
|
|
||||||
test "is empty" do
|
|
||||||
Config.put([:mrf_simple, :followers_only], [])
|
|
||||||
{_, ftl_message} = build_ftl_actor_and_message()
|
|
||||||
local_message = build_local_message()
|
|
||||||
|
|
||||||
assert SimplePolicy.filter(ftl_message) == {:ok, ftl_message}
|
|
||||||
assert SimplePolicy.filter(local_message) == {:ok, local_message}
|
|
||||||
end
|
|
||||||
|
|
||||||
test "has a matching host" do
|
|
||||||
actor = insert(:user)
|
|
||||||
following_user = insert(:user)
|
|
||||||
non_following_user = insert(:user)
|
|
||||||
|
|
||||||
{:ok, _, _, _} = CommonAPI.follow(following_user, actor)
|
|
||||||
|
|
||||||
activity = %{
|
|
||||||
"actor" => actor.ap_id,
|
|
||||||
"to" => [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public",
|
|
||||||
following_user.ap_id,
|
|
||||||
non_following_user.ap_id
|
|
||||||
],
|
|
||||||
"cc" => [actor.follower_address, "http://foo.bar/qux"]
|
|
||||||
}
|
|
||||||
|
|
||||||
dm_activity = %{
|
|
||||||
"actor" => actor.ap_id,
|
|
||||||
"to" => [
|
|
||||||
following_user.ap_id,
|
|
||||||
non_following_user.ap_id
|
|
||||||
],
|
|
||||||
"cc" => []
|
|
||||||
}
|
|
||||||
|
|
||||||
actor_domain =
|
|
||||||
activity
|
|
||||||
|> Map.fetch!("actor")
|
|
||||||
|> URI.parse()
|
|
||||||
|> Map.fetch!(:host)
|
|
||||||
|
|
||||||
Config.put([:mrf_simple, :followers_only], [actor_domain])
|
|
||||||
|
|
||||||
assert {:ok, new_activity} = SimplePolicy.filter(activity)
|
|
||||||
assert actor.follower_address in new_activity["cc"]
|
|
||||||
assert following_user.ap_id in new_activity["to"]
|
|
||||||
refute "https://www.w3.org/ns/activitystreams#Public" in new_activity["to"]
|
|
||||||
refute "https://www.w3.org/ns/activitystreams#Public" in new_activity["cc"]
|
|
||||||
refute non_following_user.ap_id in new_activity["to"]
|
|
||||||
refute non_following_user.ap_id in new_activity["cc"]
|
|
||||||
|
|
||||||
assert {:ok, new_dm_activity} = SimplePolicy.filter(dm_activity)
|
|
||||||
assert new_dm_activity["to"] == [following_user.ap_id]
|
|
||||||
assert new_dm_activity["cc"] == []
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "when :accept" do
|
describe "when :accept" do
|
||||||
test "is empty" do
|
test "is empty" do
|
||||||
Config.put([:mrf_simple, :accept], [])
|
Config.put([:mrf_simple, :accept], [])
|
||||||
|
Loading…
Reference in New Issue
Block a user