Add same optimized join for excluding invisible users

This commit is contained in:
Mark Felder 2022-11-12 18:05:58 -05:00 committed by Francis Dinh
parent 11fc1beba5
commit 0022fa7d49
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE

View file

@ -1251,12 +1251,11 @@ defp exclude_invisible_actors(query, %{type: "Flag"}), do: query
defp exclude_invisible_actors(query, %{invisible_actors: true}), do: query defp exclude_invisible_actors(query, %{invisible_actors: true}), do: query
defp exclude_invisible_actors(query, _opts) do defp exclude_invisible_actors(query, _opts) do
invisible_ap_ids = query
User.Query.build(%{invisible: true, select: [:ap_id]}) |> join(:inner, [activity], u in User,
|> Repo.all() as: :u,
|> Enum.map(fn %{ap_id: ap_id} -> ap_id end) on: activity.actor == u.ap_id and u.invisible == false
)
from([activity] in query, where: activity.actor not in ^invisible_ap_ids)
end end
defp exclude_id(query, %{exclude_id: id}) when is_binary(id) do defp exclude_id(query, %{exclude_id: id}) when is_binary(id) do