Remove User.restrict_deactivated/1
authorMark Felder <feld@FreeBSD.org>
Mon, 12 Oct 2020 23:21:46 +0000 (18:21 -0500)
committerMark Felder <feld@feld.me>
Fri, 15 Jan 2021 17:24:46 +0000 (11:24 -0600)
Everything else is in User.Query, no need for this odd kludge.

lib/pleroma/user.ex
lib/pleroma/user/query.ex

index 2ae95ebdd912eab6a07076f1b2d46416846c695b..f002c077c0f3f0120a035798d11ef8b67bb6c6a3 100644 (file)
@@ -217,7 +217,8 @@ defmodule Pleroma.User do
       target_users_query = assoc(user, unquote(outgoing_relation_target))
 
       if restrict_deactivated? do
-        restrict_deactivated(target_users_query)
+        target_users_query
+        |> User.Query.build(%{deactivated: false})
       else
         target_users_query
       end
@@ -386,11 +387,6 @@ defmodule Pleroma.User do
   def ap_following(%User{following_address: fa}) when is_binary(fa), do: fa
   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
     if Map.has_key?(params, :fields) do
       Map.put(params, :fields, Enum.map(params[:fields], &truncate_field/1))
index c3551a0aa4d74eb8ad9d2459cf255d838b1a54a0..e9cf5c0e7c71ff9a83c0006da22ab4d3c247878c 100644 (file)
@@ -137,7 +137,7 @@ defmodule Pleroma.User.Query do
   defp compose_query({:external, _}, query), do: location_query(query, false)
 
   defp compose_query({:active, _}, query) do
-    User.restrict_deactivated(query)
+    where(query, [u], u.is_active == true)
     |> where([u], u.approval_pending == false)
   end
 
@@ -147,7 +147,7 @@ defmodule Pleroma.User.Query do
   end
 
   defp compose_query({:deactivated, false}, query) do
-    User.restrict_deactivated(query)
+    where(query, [u], u.is_active == true)
   end
 
   defp compose_query({:deactivated, true}, query) do