mrf: simple policy: fix matching imported activitypub and ostatus statuses
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 26 May 2019 01:57:22 +0000 (01:57 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 26 May 2019 02:01:24 +0000 (02:01 +0000)
CHANGELOG.md
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
test/web/activity_pub/mrf/simple_policy_test.exs

index 7869e299bb293169083653f83fcba907f8af71bc..f689160e90635114d2c53ca14aa135b4f3242d8e 100644 (file)
@@ -113,6 +113,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Mastodon API: Exposing default scope of the user to anyone
 - Mastodon API: Make `irreversible` field default to `false` [`POST /api/v1/filters`]
 - User-Agent is now sent correctly for all HTTP requests.
+- MRF: Simple policy now properly delists imported or relayed statuses
 
 ## Removed
 - Configuration: `config :pleroma, :fe` in favor of the more flexible `config :pleroma, :frontend_configurations`
index 890d70a7a807cca0ca7756d244f2cf3b2fcf79e0..433d23c5f14b791539d4dacf27780c547ba1bf85 100644 (file)
@@ -74,8 +74,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
                actor_host
              ),
            user <- User.get_cached_by_ap_id(object["actor"]),
-           true <- "https://www.w3.org/ns/activitystreams#Public" in object["to"],
-           true <- user.follower_address in object["cc"] do
+           true <- "https://www.w3.org/ns/activitystreams#Public" in object["to"] do
         to =
           List.delete(object["to"], "https://www.w3.org/ns/activitystreams#Public") ++
             [user.follower_address]
index 3d1f26e60343c63f09e06c723350b5d67f894c35..0fd68e103814e73f57bdf0d8753cc8d0cf01ec17 100644 (file)
@@ -145,6 +145,24 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
 
       assert SimplePolicy.filter(local_message) == {:ok, local_message}
     end
+
+    test "has a matching host but only as:Public in to" do
+      {_actor, ftl_message} = build_ftl_actor_and_message()
+
+      ftl_message_actor_host =
+        ftl_message
+        |> Map.fetch!("actor")
+        |> URI.parse()
+        |> Map.fetch!(:host)
+
+      ftl_message = Map.put(ftl_message, "cc", [])
+
+      Config.put([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host])
+
+      assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
+      refute "https://www.w3.org/ns/activitystreams#Public" in ftl_message["to"]
+      assert "https://www.w3.org/ns/activitystreams#Public" in ftl_message["cc"]
+    end
   end
 
   defp build_ftl_actor_and_message do