Remove User.restrict_deactivated/1

Everything else is in User.Query, no need for this odd kludge.
This commit is contained in:
Mark Felder 2020-10-12 18:21:46 -05:00 committed by Mark Felder
parent 860b5c7804
commit cd1e5d76ab
2 changed files with 4 additions and 8 deletions

View File

@ -217,7 +217,8 @@ def unquote(:"#{outgoing_relation_target}_relation")(user, restrict_deactivated?
target_users_query = assoc(user, unquote(outgoing_relation_target)) target_users_query = assoc(user, unquote(outgoing_relation_target))
if restrict_deactivated? do if restrict_deactivated? do
restrict_deactivated(target_users_query) target_users_query
|> User.Query.build(%{deactivated: false})
else else
target_users_query target_users_query
end end
@ -386,11 +387,6 @@ def ap_followers(%User{} = user), do: "#{ap_id(user)}/followers"
def ap_following(%User{following_address: fa}) when is_binary(fa), do: fa def ap_following(%User{following_address: fa}) when is_binary(fa), do: fa
def ap_following(%User{} = user), do: "#{ap_id(user)}/following" def ap_following(%User{} = user), do: "#{ap_id(user)}/following"
@spec restrict_deactivated(Ecto.Query.t()) :: Ecto.Query.t()
def restrict_deactivated(query) do
from(u in query, where: u.is_active == ^true)
end
defp truncate_fields_param(params) do defp truncate_fields_param(params) do
if Map.has_key?(params, :fields) do if Map.has_key?(params, :fields) do
Map.put(params, :fields, Enum.map(params[:fields], &truncate_field/1)) Map.put(params, :fields, Enum.map(params[:fields], &truncate_field/1))

View File

@ -137,7 +137,7 @@ defp compose_query({:local, _}, query), do: location_query(query, true)
defp compose_query({:external, _}, query), do: location_query(query, false) defp compose_query({:external, _}, query), do: location_query(query, false)
defp compose_query({:active, _}, query) do defp compose_query({:active, _}, query) do
User.restrict_deactivated(query) where(query, [u], u.is_active == true)
|> where([u], u.approval_pending == false) |> where([u], u.approval_pending == false)
end end
@ -147,7 +147,7 @@ defp compose_query({:legacy_active, _}, query) do
end end
defp compose_query({:deactivated, false}, query) do defp compose_query({:deactivated, false}, query) do
User.restrict_deactivated(query) where(query, [u], u.is_active == true)
end end
defp compose_query({:deactivated, true}, query) do defp compose_query({:deactivated, true}, query) do