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
|
||||
relationships_opt =
|
||||
if Map.has_key?(opts, :relationships) do
|
||||
cond do
|
||||
Map.has_key?(opts, :relationships) ->
|
||||
opts[:relationships]
|
||||
else
|
||||
|
||||
is_nil(opts[:for]) ->
|
||||
UserRelationship.view_relationships_option(nil, [])
|
||||
|
||||
true ->
|
||||
UserRelationship.view_relationships_option(opts[:for], users)
|
||||
end
|
||||
|
||||
@ -134,9 +139,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||
|
||||
def render("relationships.json", %{user: user, targets: targets} = opts) do
|
||||
relationships_opt =
|
||||
if Map.has_key?(opts, :relationships) do
|
||||
cond do
|
||||
Map.has_key?(opts, :relationships) ->
|
||||
opts[:relationships]
|
||||
else
|
||||
|
||||
is_nil(opts[:for]) ->
|
||||
UserRelationship.view_relationships_option(nil, [])
|
||||
|
||||
true ->
|
||||
UserRelationship.view_relationships_option(user, targets)
|
||||
end
|
||||
|
||||
|
@ -32,9 +32,14 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
|
||||
|> Pleroma.Repo.all()
|
||||
|
||||
relationships_opt =
|
||||
if Map.has_key?(opts, :relationships) do
|
||||
cond do
|
||||
Map.has_key?(opts, :relationships) ->
|
||||
opts[:relationships]
|
||||
else
|
||||
|
||||
is_nil(opts[:for]) ->
|
||||
UserRelationship.view_relationships_option(nil, [])
|
||||
|
||||
true ->
|
||||
move_activities_targets =
|
||||
activities
|
||||
|> Enum.filter(&(Activity.mastodon_notification_type(&1) == "move"))
|
||||
|
@ -87,10 +87,16 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||
|> Repo.all()
|
||||
|
||||
relationships_opt =
|
||||
if Map.has_key?(opts, :relationships) do
|
||||
cond do
|
||||
Map.has_key?(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"]))
|
||||
|
||||
UserRelationship.view_relationships_option(opts[:for], actors)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user