Refresh the object in CommonAPI.vote instead of MastoAPI controller
authorrinpatch <rinpatch@sdf.org>
Sun, 2 Jun 2019 20:24:48 +0000 (23:24 +0300)
committerrinpatch <rinpatch@sdf.org>
Sun, 2 Jun 2019 20:24:48 +0000 (23:24 +0300)
lib/pleroma/web/common_api/common_api.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index f54f8a7b9e9f4e27ddef5ee1ce06f002226a1b2d..a12ee011bef12711c75ce0871ec60f700fcb4063 100644 (file)
@@ -141,6 +141,7 @@ defmodule Pleroma.Web.CommonAPI do
           })
         end)
 
+      object = Object.get_cached_by_ap_id(object.data["id"])
       {:ok, answer_activities, object}
     else
       {:author, _} -> {:error, "Already voted"}
index 8da31161f4e6ae72964bb933bd7d214de1f35a29..bab6d693d87fe601cf29deab997be6fd722f42ad 100644 (file)
@@ -436,8 +436,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
          %Activity{} = activity <- Activity.get_create_by_object_ap_id(object.data["id"]),
          true <- Visibility.visible_for_user?(activity, user),
          {:ok, _activities, object} <- CommonAPI.vote(user, object, choices) do
-      object = Object.get_cached_by_ap_id(object.data["id"])
-
       conn
       |> put_view(StatusView)
       |> try_render("poll.json", %{object: object, for: user})