diff options
Diffstat (limited to 'test/web/mastodon_api')
| -rw-r--r-- | test/web/mastodon_api/controllers/timeline_controller_test.exs | 68 | 
1 files changed, 68 insertions, 0 deletions
| diff --git a/test/web/mastodon_api/controllers/timeline_controller_test.exs b/test/web/mastodon_api/controllers/timeline_controller_test.exs index 2375ac8e8..3474c0cf9 100644 --- a/test/web/mastodon_api/controllers/timeline_controller_test.exs +++ b/test/web/mastodon_api/controllers/timeline_controller_test.exs @@ -90,6 +90,74 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do        res_conn = get(conn, "/api/v1/timelines/public")        assert length(json_response_and_validate_schema(res_conn, 200)) == 1      end + +    test "doesn't return replies if follower is posting with blocked user" do +      %{conn: conn, user: blocker} = oauth_access(["read:statuses"]) +      [blockee, friend] = insert_list(2, :user) +      {:ok, blocker} = User.follow(blocker, friend) +      {:ok, _} = User.block(blocker, blockee) + +      conn = assign(conn, :user, blocker) + +      {:ok, %{id: activity_id} = activity} = CommonAPI.post(friend, %{status: "hey!"}) + +      {:ok, reply_from_blockee} = +        CommonAPI.post(blockee, %{status: "heya", in_reply_to_status_id: activity}) + +      {:ok, _reply_from_friend} = +        CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee}) + +      res_conn = get(conn, "/api/v1/timelines/public") +      [%{"id" => ^activity_id}] = json_response_and_validate_schema(res_conn, 200) +    end + +    # TODO: update after benchmarks +    test "doesn't return replies if follow is posting with users from blocked domain" do +      %{conn: conn, user: blocker} = oauth_access(["read:statuses"]) +      friend = insert(:user) +      blockee = insert(:user, ap_id: "https://example.com/users/blocked") +      {:ok, blocker} = User.follow(blocker, friend) +      {:ok, blocker} = User.block_domain(blocker, "example.com") + +      conn = assign(conn, :user, blocker) + +      {:ok, %{id: activity_id} = activity} = CommonAPI.post(friend, %{status: "hey!"}) + +      {:ok, reply_from_blockee} = +        CommonAPI.post(blockee, %{status: "heya", in_reply_to_status_id: activity}) + +      {:ok, _reply_from_friend} = +        CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee}) + +      res_conn = get(conn, "/api/v1/timelines/public?method=fun") + +      activities = json_response_and_validate_schema(res_conn, 200) +      [%{"id" => ^activity_id}] = activities +    end + +    # TODO: update after benchmarks +    test "doesn't return replies if follow is posting with users from blocked domain with unnest param" do +      %{conn: conn, user: blocker} = oauth_access(["read:statuses"]) +      friend = insert(:user) +      blockee = insert(:user, ap_id: "https://example.com/users/blocked") +      {:ok, blocker} = User.follow(blocker, friend) +      {:ok, blocker} = User.block_domain(blocker, "example.com") + +      conn = assign(conn, :user, blocker) + +      {:ok, %{id: activity_id} = activity} = CommonAPI.post(friend, %{status: "hey!"}) + +      {:ok, reply_from_blockee} = +        CommonAPI.post(blockee, %{status: "heya", in_reply_to_status_id: activity}) + +      {:ok, _reply_from_friend} = +        CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee}) + +      res_conn = get(conn, "/api/v1/timelines/public?method=unnest") + +      activities = json_response_and_validate_schema(res_conn, 200) +      [%{"id" => ^activity_id}] = activities +    end    end    defp local_and_remote_activities do | 
