From 083cd169d21b0f20332eac80b4481adb41810a64 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 13 Nov 2017 09:48:56 +0100 Subject: [PATCH] MastoAPI: Fix repeat api bug. Documentation was wrong, reblogging actually returns the reblog, not the reblogged status. --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 5 ++--- test/web/mastodon_api/mastodon_api_controller_test.exs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 41fbe55e7..c15c47fa1 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -223,9 +223,8 @@ def delete_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do end def reblog_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do - with {:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.repeat(ap_id_or_id, user), - %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do - render conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity} + with {:ok, announce, _activity} = CommonAPI.repeat(ap_id_or_id, user) do + render conn, StatusView, "status.json", %{activity: announce, for: user, as: :activity} end end diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index f506d56a1..25d92d010 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -200,7 +200,7 @@ test "reblogs and returns the reblogged status", %{conn: conn} do |> assign(:user, user) |> post("/api/v1/statuses/#{activity.id}/reblog") - assert %{"id" => id, "reblogged" => true, "reblogs_count" => 1} = json_response(conn, 200) + assert %{"reblog" => %{"id" => id, "reblogged" => true, "reblogs_count" => 1}} = json_response(conn, 200) assert to_string(activity.id) == id end end