MastoAPI: Fix repeat api bug.
authorRoger Braun <roger@rogerbraun.net>
Mon, 13 Nov 2017 08:48:56 +0000 (09:48 +0100)
committerRoger Braun <roger@rogerbraun.net>
Mon, 13 Nov 2017 08:48:56 +0000 (09:48 +0100)
Documentation was wrong, reblogging actually returns the reblog, not
the reblogged status.

lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index 41fbe55e7c5aa07ed3895110825efadd01ee51cb..c15c47fa14dfd3d3646a842953656c5ab692bd46 100644 (file)
@@ -223,9 +223,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController 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
 
index f506d56a132f0c11c5d6f4aa978f81fbeb08aede..25d92d01038b29a41dbd2da08caf47bbbe81bec8 100644 (file)
@@ -200,7 +200,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest 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