[#1149] Merge remote-tracking branch 'remotes/upstream/develop' into 1149-oban-job...
[akkoma] / test / web / activity_pub / activity_pub_test.exs
index 853c93ab517719b75119c1317ad75a7d2a067e09..1515f4eb6a677d62602e673693e8b8266c758803 100644 (file)
@@ -538,6 +538,29 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
     assert Enum.member?(activities, activity_one)
   end
 
+  test "doesn't return thread muted activities" do
+    user = insert(:user)
+    _activity_one = insert(:note_activity)
+    note_two = insert(:note, data: %{"context" => "suya.."})
+    activity_two = insert(:note_activity, note: note_two)
+
+    {:ok, _activity_two} = CommonAPI.add_mute(user, activity_two)
+
+    assert [_activity_one] = ActivityPub.fetch_activities([], %{"muting_user" => user})
+  end
+
+  test "returns thread muted activities when with_muted is set" do
+    user = insert(:user)
+    _activity_one = insert(:note_activity)
+    note_two = insert(:note, data: %{"context" => "suya.."})
+    activity_two = insert(:note_activity, note: note_two)
+
+    {:ok, _activity_two} = CommonAPI.add_mute(user, activity_two)
+
+    assert [_activity_two, _activity_one] =
+             ActivityPub.fetch_activities([], %{"muting_user" => user, "with_muted" => true})
+  end
+
   test "does include announces on request" do
     activity_three = insert(:note_activity)
     user = insert(:user)
@@ -677,14 +700,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
       assert object.data["likes"] == [user.ap_id]
       assert object.data["like_count"] == 1
 
-      [note_activity] = Activity.get_all_create_by_object_ap_id(object.data["id"])
-      assert note_activity.data["object"]["like_count"] == 1
-
       {:ok, _like_activity, object} = ActivityPub.like(user_two, object)
       assert object.data["like_count"] == 2
-
-      [note_activity] = Activity.get_all_create_by_object_ap_id(object.data["id"])
-      assert note_activity.data["object"]["like_count"] == 2
     end
   end
 
@@ -1149,16 +1166,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
           "http://localhost:4001/users/masto_closed/followers?page=1" ->
             %Tesla.Env{status: 403, body: ""}
 
-          "http://localhost:4001/users/masto_closed/following?page=1" ->
-            %Tesla.Env{
-              status: 200,
-              body:
-                Jason.encode!(%{
-                  "id" => "http://localhost:4001/users/masto_closed/following?page=1",
-                  "type" => "OrderedCollectionPage"
-                })
-            }
-
           _ ->
             apply(HttpRequestMock, :request, [env])
         end
@@ -1182,16 +1189,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
           "http://localhost:4001/users/masto_closed/following?page=1" ->
             %Tesla.Env{status: 403, body: ""}
 
-          "http://localhost:4001/users/masto_closed/followers?page=1" ->
-            %Tesla.Env{
-              status: 200,
-              body:
-                Jason.encode!(%{
-                  "id" => "http://localhost:4001/users/masto_closed/followers?page=1",
-                  "type" => "OrderedCollectionPage"
-                })
-            }
-
           _ ->
             apply(HttpRequestMock, :request, [env])
         end