Ensured no auxiliary computations (actors list preparation etc.) related to relationships preloading if no user is present (for statuses / accounts / relationships rendering).
This commit is contained in:
parent
112101ca52
commit
6b793d3f83
@ -14,9 +14,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||||||
|
|
||||||
def render("index.json", %{users: users} = opts) do
|
def render("index.json", %{users: users} = opts) do
|
||||||
relationships_opt =
|
relationships_opt =
|
||||||
if Map.has_key?(opts, :relationships) do
|
cond do
|
||||||
|
Map.has_key?(opts, :relationships) ->
|
||||||
opts[:relationships]
|
opts[:relationships]
|
||||||
else
|
|
||||||
|
is_nil(opts[:for]) ->
|
||||||
|
UserRelationship.view_relationships_option(nil, [])
|
||||||
|
|
||||||
|
true ->
|
||||||
UserRelationship.view_relationships_option(opts[:for], users)
|
UserRelationship.view_relationships_option(opts[:for], users)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -134,9 +139,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||||||
|
|
||||||
def render("relationships.json", %{user: user, targets: targets} = opts) do
|
def render("relationships.json", %{user: user, targets: targets} = opts) do
|
||||||
relationships_opt =
|
relationships_opt =
|
||||||
if Map.has_key?(opts, :relationships) do
|
cond do
|
||||||
|
Map.has_key?(opts, :relationships) ->
|
||||||
opts[:relationships]
|
opts[:relationships]
|
||||||
else
|
|
||||||
|
is_nil(opts[:for]) ->
|
||||||
|
UserRelationship.view_relationships_option(nil, [])
|
||||||
|
|
||||||
|
true ->
|
||||||
UserRelationship.view_relationships_option(user, targets)
|
UserRelationship.view_relationships_option(user, targets)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,9 +32,14 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
|
|||||||
|> Pleroma.Repo.all()
|
|> Pleroma.Repo.all()
|
||||||
|
|
||||||
relationships_opt =
|
relationships_opt =
|
||||||
if Map.has_key?(opts, :relationships) do
|
cond do
|
||||||
|
Map.has_key?(opts, :relationships) ->
|
||||||
opts[:relationships]
|
opts[:relationships]
|
||||||
else
|
|
||||||
|
is_nil(opts[:for]) ->
|
||||||
|
UserRelationship.view_relationships_option(nil, [])
|
||||||
|
|
||||||
|
true ->
|
||||||
move_activities_targets =
|
move_activities_targets =
|
||||||
activities
|
activities
|
||||||
|> Enum.filter(&(Activity.mastodon_notification_type(&1) == "move"))
|
|> Enum.filter(&(Activity.mastodon_notification_type(&1) == "move"))
|
||||||
|
@ -87,10 +87,16 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
||||||
relationships_opt =
|
relationships_opt =
|
||||||
if Map.has_key?(opts, :relationships) do
|
cond do
|
||||||
|
Map.has_key?(opts, :relationships) ->
|
||||||
opts[:relationships]
|
opts[:relationships]
|
||||||
else
|
|
||||||
|
is_nil(opts[:for]) ->
|
||||||
|
UserRelationship.view_relationships_option(nil, [])
|
||||||
|
|
||||||
|
true ->
|
||||||
actors = Enum.map(activities ++ parent_activities, &get_user(&1.data["actor"]))
|
actors = Enum.map(activities ++ parent_activities, &get_user(&1.data["actor"]))
|
||||||
|
|
||||||
UserRelationship.view_relationships_option(opts[:for], actors)
|
UserRelationship.view_relationships_option(opts[:for], actors)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user