From: Ivan Tashkinov Date: Wed, 13 May 2020 09:42:36 +0000 (+0300) Subject: Merge remote-tracking branch 'remotes/origin/develop' into restricted-relations-embedding X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=fd2fb2bb2e2292997fbe6f70c4d12b50c56cfab9;p=akkoma Merge remote-tracking branch 'remotes/origin/develop' into restricted-relations-embedding # 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 --- fd2fb2bb2e2292997fbe6f70c4d12b50c56cfab9 diff --cc lib/pleroma/web/mastodon_api/controllers/status_controller.ex index 2b2e4a896,25e499a77..9dbf4f33c --- a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex @@@ -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 = diff --cc test/web/mastodon_api/controllers/timeline_controller_test.exs index 47541979d,f8b9289f3..2375ac8e8 --- a/test/web/mastodon_api/controllers/timeline_controller_test.exs +++ b/test/web/mastodon_api/controllers/timeline_controller_test.exs @@@ -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 @@@ -39,19 -41,83 +39,17 @@@ 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 diff --cc test/web/mastodon_api/views/status_view_test.exs index d46f5c396,ffad65b01..5d7adbe29 --- a/test/web/mastodon_api/views/status_view_test.exs +++ b/test/web/mastodon_api/views/status_view_test.exs @@@ -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) @@@ -588,8 -606,13 +604,9 @@@ 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