summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTusooa Zhu <tusooa@kazv.moe>2021-09-12 21:52:44 -0400
committerTusooa Zhu <tusooa@kazv.moe>2021-12-28 01:11:08 -0500
commit4f44fd32eae100d5ce74b3c9bd5457858f145198 (patch)
tree5a62b884d36a39f59212f7b7022b8d947d8f215e /test
parente41eee5ed1c4e7001a28dababe046e28357d2ffd (diff)
downloadpleroma-4f44fd32eae100d5ce74b3c9bd5457858f145198.tar.gz
pleroma-4f44fd32eae100d5ce74b3c9bd5457858f145198.zip
Federate unfollow activity in move_following properly
0: Use the CommonAPI unfollow function to make sure the unfollow activity is federated. 1: Limit the follow and unfollow to local followers only, while let the romote servers decide whether to move their followers. Ref: emit-move
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/activity_pub/activity_pub_test.exs36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs
index 3021f2995..dec28f81b 100644
--- a/test/pleroma/web/activity_pub/activity_pub_test.exs
+++ b/test/pleroma/web/activity_pub/activity_pub_test.exs
@@ -1775,6 +1775,42 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert {:error, "Target account must have the origin in `alsoKnownAs`"} =
ActivityPub.move(old_user, new_user)
end
+
+ test "do not move remote user following relationships" do
+ %{ap_id: old_ap_id} = old_user = insert(:user)
+ %{ap_id: new_ap_id} = new_user = insert(:user, also_known_as: [old_ap_id])
+ follower_remote = insert(:user, local: false)
+
+ User.follow(follower_remote, old_user)
+
+ assert User.following?(follower_remote, old_user)
+
+ assert {:ok, activity} = ActivityPub.move(old_user, new_user)
+
+ assert %Activity{
+ actor: ^old_ap_id,
+ data: %{
+ "actor" => ^old_ap_id,
+ "object" => ^old_ap_id,
+ "target" => ^new_ap_id,
+ "type" => "Move"
+ },
+ local: true
+ } = activity
+
+ params = %{
+ "op" => "move_following",
+ "origin_id" => old_user.id,
+ "target_id" => new_user.id
+ }
+
+ assert_enqueued(worker: Pleroma.Workers.BackgroundWorker, args: params)
+
+ Pleroma.Workers.BackgroundWorker.perform(%Oban.Job{args: params})
+
+ assert User.following?(follower_remote, old_user)
+ refute User.following?(follower_remote, new_user)
+ end
end
test "doesn't retrieve replies activities with exclude_replies" do