Refresh the object in CommonAPI.vote instead of MastoAPI controller

This commit is contained in:
rinpatch 2019-06-02 23:24:48 +03:00
parent 67bcc3ccc4
commit e3c460353d
2 changed files with 1 additions and 2 deletions

View File

@ -141,6 +141,7 @@ def vote(user, object, choices) do
}) })
end) end)
object = Object.get_cached_by_ap_id(object.data["id"])
{:ok, answer_activities, object} {:ok, answer_activities, object}
else else
{:author, _} -> {:error, "Already voted"} {:author, _} -> {:error, "Already voted"}

View File

@ -436,8 +436,6 @@ def poll_vote(%{assigns: %{user: user}} = conn, %{"id" => id, "choices" => choic
%Activity{} = activity <- Activity.get_create_by_object_ap_id(object.data["id"]), %Activity{} = activity <- Activity.get_create_by_object_ap_id(object.data["id"]),
true <- Visibility.visible_for_user?(activity, user), true <- Visibility.visible_for_user?(activity, user),
{:ok, _activities, object} <- CommonAPI.vote(user, object, choices) do {:ok, _activities, object} <- CommonAPI.vote(user, object, choices) do
object = Object.get_cached_by_ap_id(object.data["id"])
conn conn
|> put_view(StatusView) |> put_view(StatusView)
|> try_render("poll.json", %{object: object, for: user}) |> try_render("poll.json", %{object: object, for: user})