Return target status in MastoAPI endpoint instead of reblog activity
authorFrancis Dinh <normandy@firemail.cc>
Tue, 17 Apr 2018 03:30:52 +0000 (23:30 -0400)
committerFrancis Dinh <normandy@firemail.cc>
Tue, 17 Apr 2018 03:30:52 +0000 (23:30 -0400)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index 1825e156f50712c784c06587402ab59c7e7a9bd6..6ddfc8b7514680d32ac56ebbb49648db2e6d57f6 100644 (file)
@@ -297,8 +297,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   end
 
   def unreblog_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
-    with {:ok, announce, _activity} = CommonAPI.unrepeat(ap_id_or_id, user) do
-      render(conn, StatusView, "status.json", %{activity: announce, for: user, as: :activity})
+    with {:ok, %{data: %{"id" => id}}} = CommonAPI.unrepeat(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})
     end
   end
 
index f3a9c1def1d2f20158224c43e9f9e102ab7553f0..2a24037d7b5b5fdb359845e9014e2fe43301fcf2 100644 (file)
@@ -276,7 +276,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
         |> assign(:user, user)
         |> post("/api/v1/statuses/#{activity.id}/unreblog")
 
-      assert %{"reblog" => %{"id" => id, "reblogged" => false, "reblogs_count" => 0}} =
+      assert %{"id" => id, "reblogged" => false, "reblogs_count" => 0} = 
                json_response(conn, 200)
 
       assert to_string(activity.id) == id