forked from AkkomaGang/akkoma
Added some more normalization calls all in mastodon api controller
This commit is contained in:
parent
462028688b
commit
b09ae02c04
4 changed files with 9 additions and 8 deletions
|
@ -127,7 +127,7 @@ def get_visibility(%{"in_reply_to_status_id" => status_id}) when not is_nil(stat
|
||||||
in_reply_to ->
|
in_reply_to ->
|
||||||
# XXX: these heuristics should be moved out of MastodonAPI.
|
# XXX: these heuristics should be moved out of MastodonAPI.
|
||||||
with %Object{} = object <- Object.normalize(in_reply_to) do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -543,10 +543,11 @@ def unpin_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def bookmark_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
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),
|
%User{} = user <- User.get_by_nickname(user.nickname),
|
||||||
true <- Visibility.visible_for_user?(activity, user),
|
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
|
conn
|
||||||
|> put_view(StatusView)
|
|> put_view(StatusView)
|
||||||
|> try_render("status.json", %{activity: activity, for: user, as: :activity})
|
|> try_render("status.json", %{activity: activity, for: user, as: :activity})
|
||||||
|
|
|
@ -125,8 +125,8 @@ def render(
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("status.json", %{activity: %{data: %{"object" => object}} = activity} = opts) do
|
def render("status.json", %{activity: %{data: %{"object" => _object}} = activity} = opts) do
|
||||||
object = Object.normalize(object)
|
object = Object.normalize(activity)
|
||||||
|
|
||||||
user = get_user(activity.data["actor"])
|
user = get_user(activity.data["actor"])
|
||||||
|
|
||||||
|
@ -320,8 +320,8 @@ def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_reply_to(%{data: %{"object" => object}}, _) do
|
def get_reply_to(%{data: %{"object" => _object}} = activity, _) do
|
||||||
object = Object.normalize(object)
|
object = Object.normalize(activity)
|
||||||
|
|
||||||
if object.data["inReplyTo"] && object.data["inReplyTo"] != "" do
|
if object.data["inReplyTo"] && object.data["inReplyTo"] != "" do
|
||||||
Activity.get_create_by_object_ap_id(object.data["inReplyTo"])
|
Activity.get_create_by_object_ap_id(object.data["inReplyTo"])
|
||||||
|
|
|
@ -1879,7 +1879,7 @@ test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
||||||
capture_log(fn ->
|
capture_log(fn ->
|
||||||
conn =
|
conn =
|
||||||
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)
|
assert results = json_response(conn, 200)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue