Extract deactivated users query to a join

This commit is contained in:
FloatingGhost 2022-10-10 15:55:58 +01:00 committed by Mark Felder
parent 3d1828f43b
commit 4d321be05c

View file

@ -361,9 +361,11 @@ defmodule Pleroma.Activity do
end end
def restrict_deactivated_users(query) do def restrict_deactivated_users(query) do
deactivated_users_query = from(u in User.Query.build(%{deactivated: true}), select: u.ap_id) query
|> join(:inner, [activity], user in User,
from(activity in query, where: activity.actor not in subquery(deactivated_users_query)) as: :user,
on: activity.actor == user.ap_id and user.is_active == true
)
end end
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search