Merge remote-tracking branch 'pleroma/develop' into feature/addressable-lists
[akkoma] / test / web / activity_pub / transmogrifier_test.exs
index 80832d1d8a93110fa755f12e1fb19d9b8b0e18ae..e6388f88af2671e9f9fc77dde4b89bf5934299ec 100644 (file)
@@ -1077,6 +1077,18 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
       assert modified["directMessage"] == true
     end
+
+    test "it strips BCC field" do
+      user = insert(:user)
+      {:ok, list} = Pleroma.List.create("foo", user)
+
+      {:ok, activity} =
+        CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
+
+      {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+      assert is_nil(modified["bcc"])
+    end
   end
 
   describe "user upgrade" do
@@ -1284,9 +1296,12 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
   end
 
   describe "fix_explicit_addressing" do
-    test "moves non-explicitly mentioned actors to cc" do
+    setup do
       user = insert(:user)
+      [user: user]
+    end
 
+    test "moves non-explicitly mentioned actors to cc", %{user: user} do
       explicitly_mentioned_actors = [
         "https://pleroma.gold/users/user1",
         "https://pleroma.gold/user2"
@@ -1308,9 +1323,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert "https://social.beepboop.ga/users/dirb" in fixed_object["cc"]
     end
 
-    test "does not move actor's follower collection to cc" do
-      user = insert(:user)
-
+    test "does not move actor's follower collection to cc", %{user: user} do
       object = %{
         "actor" => user.ap_id,
         "to" => [user.follower_address],
@@ -1321,5 +1334,21 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert user.follower_address in fixed_object["to"]
       refute user.follower_address in fixed_object["cc"]
     end
+
+    test "removes recipient's follower collection from cc", %{user: user} do
+      recipient = insert(:user)
+
+      object = %{
+        "actor" => user.ap_id,
+        "to" => [recipient.ap_id, "https://www.w3.org/ns/activitystreams#Public"],
+        "cc" => [user.follower_address, recipient.follower_address]
+      }
+
+      fixed_object = Transmogrifier.fix_explicit_addressing(object)
+
+      assert user.follower_address in fixed_object["cc"]
+      refute recipient.follower_address in fixed_object["cc"]
+      refute recipient.follower_address in fixed_object["to"]
+    end
   end
 end