mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-23 17:54:22 +00:00
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,10 +14,15 @@ 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
|
||||||
opts[:relationships]
|
Map.has_key?(opts, :relationships) ->
|
||||||
else
|
opts[:relationships]
|
||||||
UserRelationship.view_relationships_option(opts[:for], users)
|
|
||||||
|
is_nil(opts[:for]) ->
|
||||||
|
UserRelationship.view_relationships_option(nil, [])
|
||||||
|
|
||||||
|
true ->
|
||||||
|
UserRelationship.view_relationships_option(opts[:for], users)
|
||||||
end
|
end
|
||||||
|
|
||||||
opts = Map.put(opts, :relationships, relationships_opt)
|
opts = Map.put(opts, :relationships, relationships_opt)
|
||||||
|
@ -134,10 +139,15 @@ 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
|
||||||
opts[:relationships]
|
Map.has_key?(opts, :relationships) ->
|
||||||
else
|
opts[:relationships]
|
||||||
UserRelationship.view_relationships_option(user, targets)
|
|
||||||
|
is_nil(opts[:for]) ->
|
||||||
|
UserRelationship.view_relationships_option(nil, [])
|
||||||
|
|
||||||
|
true ->
|
||||||
|
UserRelationship.view_relationships_option(user, targets)
|
||||||
end
|
end
|
||||||
|
|
||||||
render_opts = %{as: :target, user: user, relationships: relationships_opt}
|
render_opts = %{as: :target, user: user, relationships: relationships_opt}
|
||||||
|
|
|
@ -32,21 +32,26 @@ 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
|
||||||
opts[:relationships]
|
Map.has_key?(opts, :relationships) ->
|
||||||
else
|
opts[:relationships]
|
||||||
move_activities_targets =
|
|
||||||
activities
|
|
||||||
|> Enum.filter(&(Activity.mastodon_notification_type(&1) == "move"))
|
|
||||||
|> Enum.map(&User.get_cached_by_ap_id(&1.data["target"]))
|
|
||||||
|
|
||||||
actors =
|
is_nil(opts[:for]) ->
|
||||||
activities
|
UserRelationship.view_relationships_option(nil, [])
|
||||||
|> Enum.map(fn a -> User.get_cached_by_ap_id(a.data["actor"]) end)
|
|
||||||
|> Enum.filter(& &1)
|
|
||||||
|> Kernel.++(move_activities_targets)
|
|
||||||
|
|
||||||
UserRelationship.view_relationships_option(reading_user, actors)
|
true ->
|
||||||
|
move_activities_targets =
|
||||||
|
activities
|
||||||
|
|> Enum.filter(&(Activity.mastodon_notification_type(&1) == "move"))
|
||||||
|
|> Enum.map(&User.get_cached_by_ap_id(&1.data["target"]))
|
||||||
|
|
||||||
|
actors =
|
||||||
|
activities
|
||||||
|
|> Enum.map(fn a -> User.get_cached_by_ap_id(a.data["actor"]) end)
|
||||||
|
|> Enum.filter(& &1)
|
||||||
|
|> Kernel.++(move_activities_targets)
|
||||||
|
|
||||||
|
UserRelationship.view_relationships_option(reading_user, actors)
|
||||||
end
|
end
|
||||||
|
|
||||||
opts = %{
|
opts = %{
|
||||||
|
|
|
@ -87,11 +87,17 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
||||||
relationships_opt =
|
relationships_opt =
|
||||||
if Map.has_key?(opts, :relationships) do
|
cond do
|
||||||
opts[:relationships]
|
Map.has_key?(opts, :relationships) ->
|
||||||
else
|
opts[:relationships]
|
||||||
actors = Enum.map(activities ++ parent_activities, &get_user(&1.data["actor"]))
|
|
||||||
UserRelationship.view_relationships_option(opts[:for], actors)
|
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
|
end
|
||||||
|
|
||||||
opts =
|
opts =
|
||||||
|
|
Loading…
Reference in a new issue