diff options
author | rinpatch <rinpatch@sdf.org> | 2019-05-31 14:17:05 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-05-31 14:17:05 +0300 |
commit | a9eaa558853460b811d134b49fb00b017b772e94 (patch) | |
tree | e7a266e2dabe0ddec5a32f52f76bd3ac610086d1 /test | |
parent | ab3f3af7cff831acde2d612d593593f4cc843542 (diff) | |
download | pleroma-a9eaa558853460b811d134b49fb00b017b772e94.tar.gz pleroma-a9eaa558853460b811d134b49fb00b017b772e94.zip |
Fix fix_explicit_addressing moving follower collection to cc and add tests for it
Diffstat (limited to 'test')
-rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index c24b50f8c..ee71de8d0 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -1209,4 +1209,44 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, _} = Transmogrifier.prepare_outgoing(activity.data) end end + + describe "fix_explicit_addressing" do + test "moves non-explicitly mentioned actors to cc" do + user = insert(:user) + + explicitly_mentioned_actors = [ + "https://pleroma.gold/users/user1", + "https://pleroma.gold/user2" + ] + + object = %{ + "actor" => user.ap_id, + "to" => explicitly_mentioned_actors ++ ["https://social.beepboop.ga/users/dirb"], + "cc" => [], + "tag" => + Enum.map(explicitly_mentioned_actors, fn href -> + %{"type" => "Mention", "href" => href} + end) + } + + fixed_object = Transmogrifier.fix_explicit_addressing(object) + assert Enum.all?(explicitly_mentioned_actors, &(&1 in fixed_object["to"])) + refute "https://social.beepboop.ga/users/dirb" in fixed_object["to"] + assert "https://social.beepboop.ga/users/dirb" in fixed_object["cc"] + end + + test "does not move actor's follower collection to cc" do + user = insert(:user) + + object = %{ + "actor" => user.ap_id, + "to" => [user.follower_address], + "cc" => [] + } + + fixed_object = Transmogrifier.fix_explicit_addressing(object) + assert user.follower_address in fixed_object["to"] + refute user.follower_address in fixed_object["cc"] + end + end end |