logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: edaf0a05f8d3b9476d868e153fbca029e74b4bd3
parent 749445dd50ba9376779c902584da3b55be7270bb
Author: Mark Felder <feld@feld.me>
Date:   Sat, 12 Nov 2022 18:05:58 -0500

Add same optimized join for excluding invisible users

Diffstat:

Mlib/pleroma/web/activity_pub/activity_pub.ex11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1243,12 +1243,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do defp exclude_invisible_actors(query, %{invisible_actors: true}), do: query defp exclude_invisible_actors(query, _opts) do - invisible_ap_ids = - User.Query.build(%{invisible: true, select: [:ap_id]}) - |> Repo.all() - |> Enum.map(fn %{ap_id: ap_id} -> ap_id end) - - from([activity] in query, where: activity.actor not in ^invisible_ap_ids) + query + |> join(:inner, [activity], u in User, + as: :u, + on: activity.actor == u.ap_id and u.invisible == false + ) end defp exclude_id(query, %{exclude_id: id}) when is_binary(id) do