Merge remote-tracking branch 'pleroma/develop' into feature/addressable-lists
[akkoma] / test / web / activity_pub / activity_pub_test.exs
index 5d0d5a40e4c30aeaed1e8053bb87396995c93ef8..2bed1563937d3a3dd5f7d409bb212d2d84f6479e 100644 (file)
@@ -1193,6 +1193,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
       CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
 
     activity = Repo.preload(activity, :bookmark)
+    activity = %Activity{activity | thread_muted?: !!activity.thread_muted?}
 
     assert ActivityPub.fetch_activities([], %{"user" => user}) == [activity]
   end
@@ -1200,4 +1201,33 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
   def data_uri do
     File.read!("test/fixtures/avatar_data_uri")
   end
+
+  describe "fetch_activities_bounded" do
+    test "fetches private posts for followed users" do
+      user = insert(:user)
+
+      {:ok, activity} =
+        CommonAPI.post(user, %{
+          "status" => "thought I looked cute might delete later :3",
+          "visibility" => "private"
+        })
+
+      [result] = ActivityPub.fetch_activities_bounded([user.follower_address], [])
+      assert result.id == activity.id
+    end
+
+    test "fetches only public posts for other users" do
+      user = insert(:user)
+      {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe", "visibility" => "public"})
+
+      {:ok, _private_activity} =
+        CommonAPI.post(user, %{
+          "status" => "why is tenshi eating a corndog so cute?",
+          "visibility" => "private"
+        })
+
+      [result] = ActivityPub.fetch_activities_bounded([], [user.follower_address])
+      assert result.id == activity.id
+    end
+  end
 end