diff options
author | Lain Soykaf <lain@lain.com> | 2023-12-16 20:26:08 +0400 |
---|---|---|
committer | Lain Soykaf <lain@lain.com> | 2023-12-16 20:26:08 +0400 |
commit | 3fbc80eb585b44e2f315b9bf02b655b50ee473d3 (patch) | |
tree | d99d0febc9a3d3d0c77e301a7776e0498a0a7d45 /test | |
parent | 147b37b89324055d92f7230a7d504a4a82deaf1e (diff) | |
download | pleroma-3fbc80eb585b44e2f315b9bf02b655b50ee473d3.tar.gz pleroma-3fbc80eb585b44e2f315b9bf02b655b50ee473d3.zip |
B ActivityPub.Publisher: Prioritize direct mentions
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/activity_pub/publisher_test.exs | 67 | ||||
-rw-r--r-- | test/support/factory.ex | 2 |
2 files changed, 53 insertions, 16 deletions
diff --git a/test/pleroma/web/activity_pub/publisher_test.exs b/test/pleroma/web/activity_pub/publisher_test.exs index c5137cbb7..9800144b5 100644 --- a/test/pleroma/web/activity_pub/publisher_test.exs +++ b/test/pleroma/web/activity_pub/publisher_test.exs @@ -331,11 +331,40 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do assert res == :ok assert called( - Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ - inbox: "https://domain.com/users/nick1/inbox", - actor_id: actor.id, - id: note_activity.data["id"] - }) + Pleroma.Web.Federator.Publisher.enqueue_one( + Publisher, + %{ + inbox: "https://domain.com/users/nick1/inbox", + actor_id: actor.id, + id: note_activity.data["id"] + }, + priority: 1 + ) + ) + end + + test_with_mock "Publishes to directly addressed actors with higher priority.", + Pleroma.Web.Federator.Publisher, + [:passthrough], + [] do + note_activity = insert(:direct_note_activity) + + actor = Pleroma.User.get_by_ap_id(note_activity.data["actor"]) + + res = Publisher.publish(actor, note_activity) + + assert res == :ok + + assert called( + Pleroma.Web.Federator.Publisher.enqueue_one( + Publisher, + %{ + inbox: :_, + actor_id: actor.id, + id: note_activity.data["id"] + }, + priority: 0 + ) ) end @@ -414,19 +443,27 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do assert res == :ok assert called( - Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ - inbox: "https://domain.com/users/nick1/inbox", - actor_id: actor.id, - id: delete.data["id"] - }) + Pleroma.Web.Federator.Publisher.enqueue_one( + Publisher, + %{ + inbox: "https://domain.com/users/nick1/inbox", + actor_id: actor.id, + id: delete.data["id"] + }, + priority: 1 + ) ) assert called( - Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{ - inbox: "https://domain2.com/users/nick1/inbox", - actor_id: actor.id, - id: delete.data["id"] - }) + Pleroma.Web.Federator.Publisher.enqueue_one( + Publisher, + %{ + inbox: "https://domain2.com/users/nick1/inbox", + actor_id: actor.id, + id: delete.data["id"] + }, + priority: 1 + ) ) end end diff --git a/test/support/factory.ex b/test/support/factory.ex index d94544717..20bc5162e 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -212,7 +212,7 @@ defmodule Pleroma.Factory do end def direct_note_factory do - user2 = insert(:user) + user2 = insert(:user, local: false, inbox: "http://example.com/inbox") %Pleroma.Object{data: data} = note_factory() %Pleroma.Object{data: Map.merge(data, %{"to" => [user2.ap_id]})} |