Merge remote-tracking branch 'remotes/origin/develop' into restricted-relations-embedding
authorIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 13 May 2020 09:42:36 +0000 (12:42 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 13 May 2020 09:42:36 +0000 (12:42 +0300)
# Conflicts:
# lib/pleroma/web/mastodon_api/controllers/status_controller.ex
# lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
# test/web/mastodon_api/controllers/timeline_controller_test.exs
# test/web/mastodon_api/views/status_view_test.exs

1  2 
lib/pleroma/web/admin_api/admin_api_controller.ex
lib/pleroma/web/mastodon_api/controllers/status_controller.ex
lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
lib/pleroma/web/mastodon_api/views/account_view.ex
test/web/mastodon_api/controllers/notification_controller_test.exs
test/web/mastodon_api/controllers/status_controller_test.exs
test/web/mastodon_api/controllers/timeline_controller_test.exs
test/web/mastodon_api/views/account_view_test.exs
test/web/mastodon_api/views/notification_view_test.exs
test/web/mastodon_api/views/status_view_test.exs

index 2b2e4a89623f868ef7c399293ec6f02b06af7b22,25e499a77bdfc6a025918b03745696892e269244..9dbf4f33cef82751b42e101cf83aaedff0ca4dd9
@@@ -102,7 -105,7 +105,7 @@@ defmodule Pleroma.Web.MastodonAPI.Statu
  
    `ids` query param is required
    """
-   def index(%{assigns: %{user: user}} = conn, %{"ids" => ids} = _params) do
 -  def index(%{assigns: %{user: user}} = conn, %{ids: ids} = params) do
++  def index(%{assigns: %{user: user}} = conn, %{ids: ids} = _params) do
      limit = 100
  
      activities =
index 47541979dea727737e0baa748f79fbf1707a7cce,f8b9289f37cb04c7d893e667ea3d8d7b152a9efd..2375ac8e8d88ec23d6df9d2ba153109d54b3f8c5
@@@ -24,9 -24,11 +24,9 @@@ defmodule Pleroma.Web.MastodonAPI.Timel
        user: user,
        conn: conn
      } do
 -      clear_config([:extensions, :output_relationships_in_statuses_by_default], false)
 -
        other_user = insert(:user)
  
-       {:ok, _} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
+       {:ok, _} = CommonAPI.post(other_user, %{status: "hi @#{user.nickname}"})
  
        response =
          conn
               end)
      end
  
 -    test "the home timeline", %{user: user, conn: conn} do
 -      uri = "/api/v1/timelines/home?with_relationships=1"
 -
 -      following = insert(:user, nickname: "followed")
 -      third_user = insert(:user, nickname: "repeated")
 -
 -      {:ok, _activity} = CommonAPI.post(following, %{status: "post"})
 -      {:ok, activity} = CommonAPI.post(third_user, %{status: "repeated post"})
 -      {:ok, _, _} = CommonAPI.repeat(activity.id, following)
 -
 -      ret_conn = get(conn, uri)
 -
 -      assert Enum.empty?(json_response_and_validate_schema(ret_conn, :ok))
 -
 -      {:ok, _user} = User.follow(user, following)
 -
 -      ret_conn = get(conn, uri)
 -
 -      assert [
 -               %{
 -                 "reblog" => %{
 -                   "content" => "repeated post",
 -                   "account" => %{
 -                     "pleroma" => %{
 -                       "relationship" => %{"following" => false, "followed_by" => false}
 -                     }
 -                   }
 -                 },
 -                 "account" => %{"pleroma" => %{"relationship" => %{"following" => true}}}
 -               },
 -               %{
 -                 "content" => "post",
 -                 "account" => %{
 -                   "acct" => "followed",
 -                   "pleroma" => %{"relationship" => %{"following" => true}}
 -                 }
 -               }
 -             ] = json_response_and_validate_schema(ret_conn, :ok)
 -
 -      {:ok, _user} = User.follow(third_user, user)
 -
 -      ret_conn = get(conn, uri)
 -
 -      assert [
 -               %{
 -                 "reblog" => %{
 -                   "content" => "repeated post",
 -                   "account" => %{
 -                     "acct" => "repeated",
 -                     "pleroma" => %{
 -                       "relationship" => %{"following" => false, "followed_by" => true}
 -                     }
 -                   }
 -                 },
 -                 "account" => %{"pleroma" => %{"relationship" => %{"following" => true}}}
 -               },
 -               %{
 -                 "content" => "post",
 -                 "account" => %{
 -                   "acct" => "followed",
 -                   "pleroma" => %{"relationship" => %{"following" => true}}
 -                 }
 -               }
 -             ] = json_response_and_validate_schema(ret_conn, :ok)
 -    end
 -
      test "the home timeline when the direct messages are excluded", %{user: user, conn: conn} do
-       {:ok, public_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
-       {:ok, direct_activity} = CommonAPI.post(user, %{"status" => ".", "visibility" => "direct"})
+       {:ok, public_activity} = CommonAPI.post(user, %{status: ".", visibility: "public"})
+       {:ok, direct_activity} = CommonAPI.post(user, %{status: ".", visibility: "direct"})
  
-       {:ok, unlisted_activity} =
-         CommonAPI.post(user, %{"status" => ".", "visibility" => "unlisted"})
+       {:ok, unlisted_activity} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"})
  
-       {:ok, private_activity} =
-         CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
+       {:ok, private_activity} = CommonAPI.post(user, %{status: ".", visibility: "private"})
  
-       conn = get(conn, "/api/v1/timelines/home", %{"exclude_visibilities" => ["direct"]})
+       conn = get(conn, "/api/v1/timelines/home?exclude_visibilities[]=direct")
  
-       assert status_ids = json_response(conn, :ok) |> Enum.map(& &1["id"])
+       assert status_ids = json_response_and_validate_schema(conn, :ok) |> Enum.map(& &1["id"])
        assert public_activity.id in status_ids
        assert unlisted_activity.id in status_ids
        assert private_activity.id in status_ids
index d46f5c3963e1dcad40f440cdf909dd6854a73d4a,ffad65b01eb6c77fa58058dd23db3292875c9def..5d7adbe290d9772e99588987d97f5a0cdbe0764c
@@@ -572,10 -587,13 +587,11 @@@ defmodule Pleroma.Web.MastodonAPI.Statu
  
      result = StatusView.render("show.json", %{activity: activity, for: other_user})
  
 -    assert result[:account][:pleroma][:relationship] ==
 -             AccountView.render("relationship.json", %{user: other_user, target: user})
 -
 +    assert result[:account][:pleroma][:relationship] == %{}
+     assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
    end
  
 -  test "embeds a relationship in the account in reposts" do
 +  test "does not embed a relationship in the account in reposts" do
      user = insert(:user)
      other_user = insert(:user)
  
  
      result = StatusView.render("show.json", %{activity: activity, for: user})
  
 -    assert result[:account][:pleroma][:relationship] ==
 -             AccountView.render("relationship.json", %{user: user, target: other_user})
 -
 -    assert result[:reblog][:account][:pleroma][:relationship] ==
 -             AccountView.render("relationship.json", %{user: user, target: user})
 -
 +    assert result[:account][:pleroma][:relationship] == %{}
 +    assert result[:reblog][:account][:pleroma][:relationship] == %{}
+     assert_schema(result, "Status", Pleroma.Web.ApiSpec.spec())
    end
  
    test "visibility/list" do