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