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 @@ def get_visibility(%{"in_reply_to_status_id" => status_id}) when not is_nil(stat
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 @@ def unpin_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) 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 @@ def render(
}
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 @@ def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) 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 @@ test "search doesn't show statuses that it shouldn't", %{conn: conn} 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)