Added some more normalization calls all in mastodon api controller

This commit is contained in:
rinpatch 2019-04-17 13:04:58 +03:00
parent 462028688b
commit b09ae02c04
4 changed files with 9 additions and 8 deletions

View file

@ -127,7 +127,7 @@ defmodule Pleroma.Web.CommonAPI do
in_reply_to ->
# XXX: these heuristics should be moved out of MastodonAPI.
with %Object{} = object <- Object.normalize(in_reply_to) do
Pleroma.Web.MastodonAPI.StatusView.get_visibility(object.data)
Pleroma.Web.MastodonAPI.StatusView.get_visibility(object)
end
end
end

View file

@ -543,10 +543,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
def bookmark_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
with %Activity{} = activity <- Activity.get_by_id(id),
with %Activity{} = activity <- Activity.get_by_id_with_object(id),
%Object{} = object <- Object.normalize(activity),
%User{} = user <- User.get_by_nickname(user.nickname),
true <- Visibility.visible_for_user?(activity, user),
{:ok, user} <- User.bookmark(user, activity.data["object"]["id"]) do
{:ok, user} <- User.bookmark(user, object.data["id"]) do
conn
|> put_view(StatusView)
|> try_render("status.json", %{activity: activity, for: user, as: :activity})

View file

@ -125,8 +125,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
}
end
def render("status.json", %{activity: %{data: %{"object" => object}} = activity} = opts) do
object = Object.normalize(object)
def render("status.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
object = Object.normalize(activity)
user = get_user(activity.data["actor"])
@ -320,8 +320,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
end
end
def get_reply_to(%{data: %{"object" => object}}, _) do
object = Object.normalize(object)
def get_reply_to(%{data: %{"object" => _object}} = activity, _) do
object = Object.normalize(activity)
if object.data["inReplyTo"] && object.data["inReplyTo"] != "" do
Activity.get_create_by_object_ap_id(object.data["inReplyTo"])

View file

@ -1879,7 +1879,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
capture_log(fn ->
conn =
conn
|> get("/api/v1/search", %{"q" => activity.data["object"]["id"]})
|> get("/api/v1/search", %{"q" => Object.normalize(activity).id})
assert results = json_response(conn, 200)