Merge branch 'develop' into frontend-switcher-9000
[akkoma] / test / pleroma / web / activity_pub / publisher_test.exs
index 95f12de2d869ffbe84f07f2f5f718fd6db4dfae8..93bf5c345e95084a7f6b4d3abb9e13f63895196b 100644 (file)
@@ -26,6 +26,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
   setup_all do
     clear_config([:instance, :federating], true)
     clear_config([:instance, :quarantined_instances], [])
+    clear_config([:mrf_simple, :reject], [])
   end
 
   describe "gather_webfinger_links/1" do
@@ -270,12 +271,14 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
   end
 
   describe "publish/2" do
-    test_with_mock "doesn't publish any activity to quarantined instances.",
+    test_with_mock "doesn't publish any activity to quarantined or rejected instances.",
                    Pleroma.Web.Federator.Publisher,
                    [:passthrough],
                    [] do
       Config.put([:instance, :quarantined_instances], [{"domain.com", "some reason"}])
 
+      Config.put([:mrf_simple, :reject], [{"rejected.com", "some reason"}])
+
       follower =
         insert(:user, %{
           local: false,
@@ -283,9 +286,18 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
           ap_enabled: true
         })
 
+      another_follower =
+        insert(:user, %{
+          local: false,
+          inbox: "https://rejected.com/users/nick2/inbox",
+          ap_enabled: true
+        })
+
       actor = insert(:user, follower_address: follower.ap_id)
 
       {:ok, follower, actor} = Pleroma.User.follow(follower, actor)
+      {:ok, _another_follower, actor} = Pleroma.User.follow(another_follower, actor)
+
       actor = refresh_record(actor)
 
       note_activity =
@@ -321,6 +333,22 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
                  id: public_note_activity.data["id"]
                })
              )
+
+      assert not called(
+               Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{
+                 inbox: "https://rejected.com/users/nick2/inbox",
+                 actor_id: actor.id,
+                 id: note_activity.data["id"]
+               })
+             )
+
+      assert not called(
+               Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{
+                 inbox: "https://rejected.com/users/nick2/inbox",
+                 actor_id: actor.id,
+                 id: public_note_activity.data["id"]
+               })
+             )
     end
 
     test_with_mock "Publishes a non-public activity to non-quarantined instances.",