Ability to control the output of account/pleroma/relationship in statuses in order to improve the rendering performance.
See `[:extensions, output_relationships_in_statuses_by_default]` setting and `with_relationships` param.
This commit is contained in:
parent
bfec45bf74
commit
2f2bd7fe72
25 changed files with 278 additions and 76 deletions
|
|
@ -12,6 +12,26 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "does NOT render account/pleroma/relationship if this is disabled by default" do
|
||||
clear_config([:extensions, :output_relationships_in_statuses_by_default], false)
|
||||
|
||||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, [_notification]} = Notification.create_notifications(activity)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/notifications")
|
||||
|> json_response(200)
|
||||
|
||||
assert Enum.all?(response, fn n ->
|
||||
get_in(n, ["account", "pleroma", "relationship"]) == %{}
|
||||
end)
|
||||
end
|
||||
|
||||
test "list of notifications" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -1043,6 +1043,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
end
|
||||
|
||||
test "bookmarks" do
|
||||
bookmarks_uri = "/api/v1/bookmarks?with_relationships=true"
|
||||
|
||||
%{conn: conn} = oauth_access(["write:bookmarks", "read:bookmarks"])
|
||||
author = insert(:user)
|
||||
|
||||
|
|
@ -1064,7 +1066,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
assert json_response(response2, 200)["bookmarked"] == true
|
||||
|
||||
bookmarks = get(conn, "/api/v1/bookmarks")
|
||||
bookmarks = get(conn, bookmarks_uri)
|
||||
|
||||
assert [json_response(response2, 200), json_response(response1, 200)] ==
|
||||
json_response(bookmarks, 200)
|
||||
|
|
@ -1073,7 +1075,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
assert json_response(response1, 200)["bookmarked"] == false
|
||||
|
||||
bookmarks = get(conn, "/api/v1/bookmarks")
|
||||
bookmarks = get(conn, bookmarks_uri)
|
||||
|
||||
assert [json_response(response2, 200)] == json_response(bookmarks, 200)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,7 +20,30 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
describe "home" do
|
||||
setup do: oauth_access(["read:statuses"])
|
||||
|
||||
test "does NOT render account/pleroma/relationship if this is disabled by default", %{
|
||||
user: user,
|
||||
conn: conn
|
||||
} do
|
||||
clear_config([:extensions, :output_relationships_in_statuses_by_default], false)
|
||||
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/timelines/home")
|
||||
|> json_response(200)
|
||||
|
||||
assert Enum.all?(response, fn n ->
|
||||
get_in(n, ["account", "pleroma", "relationship"]) == %{}
|
||||
end)
|
||||
end
|
||||
|
||||
test "the home timeline", %{user: user, conn: conn} do
|
||||
uri = "/api/v1/timelines/home?with_relationships=true"
|
||||
|
||||
following = insert(:user, nickname: "followed")
|
||||
third_user = insert(:user, nickname: "repeated")
|
||||
|
||||
|
|
@ -28,13 +51,13 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "repeated post"})
|
||||
{:ok, _, _} = CommonAPI.repeat(activity.id, following)
|
||||
|
||||
ret_conn = get(conn, "/api/v1/timelines/home")
|
||||
ret_conn = get(conn, uri)
|
||||
|
||||
assert Enum.empty?(json_response(ret_conn, :ok))
|
||||
|
||||
{:ok, _user} = User.follow(user, following)
|
||||
|
||||
ret_conn = get(conn, "/api/v1/timelines/home")
|
||||
ret_conn = get(conn, uri)
|
||||
|
||||
assert [
|
||||
%{
|
||||
|
|
@ -59,7 +82,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
|
||||
{:ok, _user} = User.follow(third_user, user)
|
||||
|
||||
ret_conn = get(conn, "/api/v1/timelines/home")
|
||||
ret_conn = get(conn, uri)
|
||||
|
||||
assert [
|
||||
%{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue