update mastofe paths (#95)
[akkoma] / test / pleroma / web / mastodon_api / controllers / timeline_controller_test.exs
index 066762748c20b6580a201d1395f9a17a5ee877aa..187982d92572b42b0cb21552bbc353de94aa6132 100644 (file)
@@ -131,22 +131,22 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       refute remote_activity.id in only_local_media_ids
       assert with_media.id in only_local_media_ids
 
-      only_remote_ids =
+      remote_ids =
         conn
-        |> get("/api/v1/timelines/home?only_remote=true")
+        |> get("/api/v1/timelines/home?remote=true")
         |> json_response_and_validate_schema(200)
         |> Enum.map(& &1["id"])
 
-      refute local_activity.id in only_remote_ids
-      assert remote_activity.id in only_remote_ids
-      refute with_media.id in only_remote_ids
+      refute local_activity.id in remote_ids
+      assert remote_activity.id in remote_ids
+      refute with_media.id in remote_ids
 
       assert conn
-             |> get("/api/v1/timelines/home?only_remote=true&only_media=true")
+             |> get("/api/v1/timelines/home?remote=true&only_media=true")
              |> json_response_and_validate_schema(200) == []
 
       assert conn
-             |> get("/api/v1/timelines/home?only_remote=true&local=true")
+             |> get("/api/v1/timelines/home?remote=true&local=true")
              |> json_response_and_validate_schema(200) == []
     end
   end
@@ -210,7 +210,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
 
       assert [%{"id" => ^remote_id}] =
                conn
-               |> get("/api/v1/timelines/public?only_remote=true")
+               |> get("/api/v1/timelines/public?remote=true")
                |> json_response_and_validate_schema(:ok)
 
       with_media_id = with_media.id
@@ -221,7 +221,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
                |> json_response_and_validate_schema(:ok)
 
       assert conn
-             |> get("/api/v1/timelines/public?only_remote=true&only_media=true")
+             |> get("/api/v1/timelines/public?remote=true&only_media=true")
              |> json_response_and_validate_schema(:ok) == []
 
       # does not contain repeats
@@ -273,6 +273,24 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       [%{"id" => ^reply_from_me}, %{"id" => ^activity_id}] = response
     end
 
+    test "doesn't return posts from users who blocked you when :blockers_visible is disabled" do
+      clear_config([:activitypub, :blockers_visible], false)
+
+      %{conn: conn, user: blockee} = oauth_access(["read:statuses"])
+      blocker = insert(:user)
+      {:ok, _} = User.block(blocker, blockee)
+
+      conn = assign(conn, :user, blockee)
+
+      {:ok, _} = CommonAPI.post(blocker, %{status: "hey!"})
+
+      response =
+        get(conn, "/api/v1/timelines/public")
+        |> json_response_and_validate_schema(200)
+
+      assert length(response) == 0
+    end
+
     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)
@@ -657,7 +675,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
              ] = result
     end
 
-    test "filering", %{user: user, conn: conn} do
+    test "filtering", %{user: user, conn: conn} do
       {:ok, list} = Pleroma.List.create("name", user)
 
       local_user = insert(:user)
@@ -699,18 +717,18 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       assert with_media.id in only_local_media_ids
       refute remote_activity.id in only_local_media_ids
 
-      only_remote_ids =
+      remote_ids =
         conn
-        |> get("/api/v1/timelines/list/#{list.id}?only_remote=true")
+        |> get("/api/v1/timelines/list/#{list.id}?remote=true")
         |> json_response_and_validate_schema(200)
         |> Enum.map(& &1["id"])
 
-      refute local_activity.id in only_remote_ids
-      refute with_media.id in only_remote_ids
-      assert remote_activity.id in only_remote_ids
+      refute local_activity.id in remote_ids
+      refute with_media.id in remote_ids
+      assert remote_activity.id in remote_ids
 
       assert conn
-             |> get("/api/v1/timelines/list/#{list.id}?only_remote=true&only_media=true")
+             |> get("/api/v1/timelines/list/#{list.id}?remote=true&only_media=true")
              |> json_response_and_validate_schema(200) == []
 
       only_media_ids =
@@ -724,9 +742,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       refute remote_activity.id in only_media_ids
 
       assert conn
-             |> get(
-               "/api/v1/timelines/list/#{list.id}?only_media=true&local=true&only_remote=true"
-             )
+             |> get("/api/v1/timelines/list/#{list.id}?only_media=true&local=true&remote=true")
              |> json_response_and_validate_schema(200) == []
     end
   end
@@ -777,7 +793,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
 
       remote_ids =
         conn
-        |> get("/api/v1/timelines/tag/2hu?only_remote=true")
+        |> get("/api/v1/timelines/tag/2hu?remote=true")
         |> json_response_and_validate_schema(:ok)
         |> Enum.map(& &1["id"])
 
@@ -807,7 +823,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
 
       ids =
         conn
-        |> get("/api/v1/timelines/tag/2hu?only_media=true&local=true&only_remote=true")
+        |> get("/api/v1/timelines/tag/2hu?only_media=true&local=true&remote=true")
         |> json_response_and_validate_schema(:ok)
         |> Enum.map(& &1["id"])
 
@@ -816,7 +832,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       refute remote_activity.id in ids
 
       assert conn
-             |> get("/api/v1/timelines/tag/2hu?only_media=true&only_remote=true")
+             |> get("/api/v1/timelines/tag/2hu?only_media=true&remote=true")
              |> json_response_and_validate_schema(:ok) == []
     end
 
@@ -907,10 +923,10 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       %{conn: auth_conn} = oauth_access(["read:statuses"])
 
       res_conn = get(auth_conn, "#{base_uri}?local=true")
-      assert length(json_response(res_conn, 200)) == 1
+      assert length(json_response_and_validate_schema(res_conn, 200)) == 1
 
       res_conn = get(auth_conn, "#{base_uri}?local=false")
-      assert length(json_response(res_conn, 200)) == 2
+      assert length(json_response_and_validate_schema(res_conn, 200)) == 2
     end
 
     test "with default settings on private instances, returns 403 for unauthenticated users", %{
@@ -924,7 +940,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       for local <- [true, false] do
         res_conn = get(conn, "#{base_uri}?local=#{local}")
 
-        assert json_response(res_conn, :unauthorized) == error_response
+        assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
       end
 
       ensure_authenticated_access(base_uri)
@@ -941,7 +957,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       for local <- [true, false] do
         res_conn = get(conn, "#{base_uri}?local=#{local}")
 
-        assert json_response(res_conn, :unauthorized) == error_response
+        assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
       end
 
       ensure_authenticated_access(base_uri)
@@ -953,10 +969,10 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       clear_config([:restrict_unauthenticated, :timelines, :federated], true)
 
       res_conn = get(conn, "#{base_uri}?local=true")
-      assert length(json_response(res_conn, 200)) == 1
+      assert length(json_response_and_validate_schema(res_conn, 200)) == 1
 
       res_conn = get(conn, "#{base_uri}?local=false")
-      assert json_response(res_conn, :unauthorized) == error_response
+      assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
 
       ensure_authenticated_access(base_uri)
     end
@@ -968,11 +984,11 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
       clear_config([:restrict_unauthenticated, :timelines, :federated], false)
 
       res_conn = get(conn, "#{base_uri}?local=true")
-      assert json_response(res_conn, :unauthorized) == error_response
+      assert json_response_and_validate_schema(res_conn, :unauthorized) == error_response
 
       # Note: local activities get delivered as part of federated timeline
       res_conn = get(conn, "#{base_uri}?local=false")
-      assert length(json_response(res_conn, 200)) == 2
+      assert length(json_response_and_validate_schema(res_conn, 200)) == 2
 
       ensure_authenticated_access(base_uri)
     end