Change user.deactivated field to user.is_active
authorMark Felder <feld@FreeBSD.org>
Mon, 12 Oct 2020 22:42:27 +0000 (17:42 -0500)
committerMark Felder <feld@feld.me>
Fri, 15 Jan 2021 17:24:46 +0000 (11:24 -0600)
40 files changed:
lib/mix/tasks/pleroma/email.ex
lib/mix/tasks/pleroma/user.ex
lib/pleroma/following_relationship.ex
lib/pleroma/notification.ex
lib/pleroma/stats.ex
lib/pleroma/user.ex
lib/pleroma/user/query.ex
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/object_validators/common_validations.ex
lib/pleroma/web/admin_api/controllers/user_controller.ex
lib/pleroma/web/admin_api/views/account_view.ex
lib/pleroma/web/api_spec/operations/admin/report_operation.ex
lib/pleroma/web/api_spec/operations/admin/status_operation.ex
lib/pleroma/web/mastodon_api/views/account_view.ex
lib/pleroma/web/mongoose_im/mongoose_im_controller.ex
lib/pleroma/web/pleroma_api/views/emoji_reaction_view.ex
lib/pleroma/web/twitter_api/twitter_api.ex
priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs [new file with mode: 0644]
test/mix/tasks/pleroma/email_test.exs
test/mix/tasks/pleroma/user_test.exs
test/pleroma/user_test.exs
test/pleroma/web/activity_pub/side_effects/delete_test.exs
test/pleroma/web/activity_pub/side_effects_test.exs
test/pleroma/web/activity_pub/transmogrifier/chat_message_test.exs
test/pleroma/web/activity_pub/transmogrifier/delete_handling_test.exs
test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs
test/pleroma/web/admin_api/controllers/status_controller_test.exs
test/pleroma/web/admin_api/controllers/user_controller_test.exs
test/pleroma/web/admin_api/search_test.exs
test/pleroma/web/common_api_test.exs
test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
test/pleroma/web/mastodon_api/controllers/auth_controller_test.exs
test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs
test/pleroma/web/mastodon_api/mastodon_api_test.exs
test/pleroma/web/mastodon_api/views/account_view_test.exs
test/pleroma/web/mongoose_im_controller_test.exs
test/pleroma/web/o_auth/o_auth_controller_test.exs
test/pleroma/web/plugs/user_enabled_plug_test.exs
test/pleroma/web/twitter_api/remote_follow_controller_test.exs
test/pleroma/web/twitter_api/util_controller_test.exs

index 54f158f73479d07c91bcc09208d82387d8b6839e..665d3b88ef7557a3af40d789bc2fe83876e94d70 100644 (file)
@@ -33,7 +33,7 @@ defmodule Mix.Tasks.Pleroma.Email do
 
     Pleroma.User.Query.build(%{
       local: true,
-      deactivated: false,
+      is_active: true,
       confirmation_pending: true,
       invisible: false
     })
index f90c045fe3c71113b11de3b718d712af5f9e5ddb..9cd74efde9d90494739c9b35508e8f18bb886a44 100644 (file)
@@ -111,10 +111,10 @@ defmodule Mix.Tasks.Pleroma.User do
     start_pleroma()
 
     with %User{} = user <- User.get_cached_by_nickname(nickname) do
-      {:ok, user} = User.deactivate(user, !user.deactivated)
+      {:ok, user} = User.deactivate(user, user.is_active)
 
       shell_info(
-        "Activation status of #{nickname}: #{if(user.deactivated, do: "de", else: "")}activated"
+        "Activation status of #{nickname}: #{unless(user.is_active, do: "de", else: "")}activated"
       )
     else
       _ ->
@@ -365,7 +365,7 @@ defmodule Mix.Tasks.Pleroma.User do
 
     Pleroma.User.Query.build(%{
       local: true,
-      deactivated: false,
+      is_active: true,
       is_moderator: false,
       is_admin: false,
       invisible: false
@@ -383,7 +383,7 @@ defmodule Mix.Tasks.Pleroma.User do
 
     Pleroma.User.Query.build(%{
       local: true,
-      deactivated: false,
+      is_active: true,
       is_moderator: false,
       is_admin: false,
       invisible: false
@@ -420,7 +420,7 @@ defmodule Mix.Tasks.Pleroma.User do
         shell_info(
           "#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
             user.is_locked
-          }, deactivated: #{user.deactivated}"
+          }, is_active: #{user.is_active}"
         )
       end)
     end)
index 147cb9df0e82574c6f76f71e282ae7ac3882357b..a0c7e6e393a3ca5574832716738cbc1d480d3095 100644 (file)
@@ -152,7 +152,7 @@ defmodule Pleroma.FollowingRelationship do
     |> join(:inner, [r], f in assoc(r, :follower))
     |> where([r], r.state == ^:follow_pending)
     |> where([r], r.following_id == ^id)
-    |> where([r, f], f.deactivated != true)
+    |> where([r, f], f.is_active == true)
     |> select([r, f], f)
     |> Repo.all()
   end
index 7a69dacde4aa9b684b1e6110eb6d0584b850182d..55b51321287426fd00abb22e0e8185b59066b6ee 100644 (file)
@@ -115,7 +115,7 @@ defmodule Pleroma.Notification do
     |> where(
       [n, a],
       fragment(
-        "? not in (SELECT ap_id FROM users WHERE deactivated = 'true')",
+        "? not in (SELECT ap_id FROM users WHERE is_active = 'false')",
         a.actor
       )
     )
index 77505bb042ca4aebc7cba21d86ddf1d28d27bf1c..b096a9b1e8ea43a0a3fa958eafcaf2a9262829eb 100644 (file)
@@ -75,7 +75,7 @@ defmodule Pleroma.Stats do
 
     users_query =
       from(u in User,
-        where: u.deactivated != true,
+        where: u.is_active == true,
         where: u.local == true,
         where: not is_nil(u.nickname),
         where: not u.invisible
index 6a81adfd6a37f76cd73f95f39d332972f74f2174..2ae95ebdd912eab6a07076f1b2d46416846c695b 100644 (file)
@@ -117,7 +117,7 @@ defmodule Pleroma.User do
     field(:confirmation_token, :string, default: nil)
     field(:default_scope, :string, default: "public")
     field(:domain_blocks, {:array, :string}, default: [])
-    field(:deactivated, :boolean, default: false)
+    field(:is_active, :boolean, default: true)
     field(:no_rich_text, :boolean, default: false)
     field(:ap_enabled, :boolean, default: false)
     field(:is_moderator, :boolean, default: false)
@@ -286,7 +286,7 @@ defmodule Pleroma.User do
 
   @doc "Returns status account"
   @spec account_status(User.t()) :: account_status()
-  def account_status(%User{deactivated: true}), do: :deactivated
+  def account_status(%User{is_active: false}), do: :deactivated
   def account_status(%User{password_reset_pending: true}), do: :password_reset_pending
   def account_status(%User{local: true, approval_pending: true}), do: :approval_pending
 
@@ -388,7 +388,7 @@ defmodule Pleroma.User do
 
   @spec restrict_deactivated(Ecto.Query.t()) :: Ecto.Query.t()
   def restrict_deactivated(query) do
-    from(u in query, where: u.deactivated != ^true)
+    from(u in query, where: u.is_active == ^true)
   end
 
   defp truncate_fields_param(params) do
@@ -785,7 +785,7 @@ defmodule Pleroma.User do
     candidates = Config.get([:instance, :autofollowed_nicknames])
 
     autofollowed_users =
-      User.Query.build(%{nickname: candidates, local: true, deactivated: false})
+      User.Query.build(%{nickname: candidates, local: true, is_active: true})
       |> Repo.all()
 
     follow_all(user, autofollowed_users)
@@ -946,7 +946,7 @@ defmodule Pleroma.User do
     deny_follow_blocked = Config.get([:user, :deny_follow_blocked])
 
     cond do
-      followed.deactivated ->
+      followed.is_active == false ->
         {:error, "Could not follow user: #{followed.nickname} is deactivated."}
 
       deny_follow_blocked and blocks?(followed, follower) ->
@@ -1181,7 +1181,7 @@ defmodule Pleroma.User do
 
   @spec get_followers_query(User.t(), pos_integer() | nil) :: Ecto.Query.t()
   def get_followers_query(%User{} = user, nil) do
-    User.Query.build(%{followers: user, deactivated: false})
+    User.Query.build(%{followers: user, is_active: true})
   end
 
   def get_followers_query(%User{} = user, page) do
@@ -1357,7 +1357,7 @@ defmodule Pleroma.User do
   @spec get_users_from_set([String.t()], keyword()) :: [User.t()]
   def get_users_from_set(ap_ids, opts \\ []) do
     local_only = Keyword.get(opts, :local_only, true)
-    criteria = %{ap_id: ap_ids, deactivated: false}
+    criteria = %{ap_id: ap_ids, is_active: true}
     criteria = if local_only, do: Map.put(criteria, :local, true), else: criteria
 
     User.Query.build(criteria)
@@ -1368,7 +1368,7 @@ defmodule Pleroma.User do
   def get_recipients_from_activity(%Activity{recipients: to, actor: actor}) do
     to = [actor | to]
 
-    query = User.Query.build(%{recipients_from_activity: to, local: true, deactivated: false})
+    query = User.Query.build(%{recipients_from_activity: to, local: true, is_active: true})
 
     query
     |> Repo.all()
@@ -1600,7 +1600,7 @@ defmodule Pleroma.User do
   end
 
   def deactivate(%User{} = user, status) do
-    with {:ok, user} <- set_activation_status(user, status) do
+    with {:ok, user} <- set_activation_status(user, !status) do
       user
       |> get_followers()
       |> Enum.filter(& &1.local)
@@ -1688,7 +1688,7 @@ defmodule Pleroma.User do
       registration_reason: nil,
       confirmation_token: nil,
       domain_blocks: [],
-      deactivated: true,
+      is_active: false,
       ap_enabled: false,
       is_moderator: false,
       is_admin: false,
@@ -2056,7 +2056,7 @@ defmodule Pleroma.User do
 
   @spec all_superusers() :: [User.t()]
   def all_superusers do
-    User.Query.build(%{super_users: true, local: true, deactivated: false})
+    User.Query.build(%{super_users: true, local: true, is_active: true})
     |> Repo.all()
   end
 
@@ -2097,7 +2097,7 @@ defmodule Pleroma.User do
       left_join: a in Pleroma.Activity,
       on: u.ap_id == a.actor,
       where: not is_nil(u.nickname),
-      where: u.deactivated != ^true,
+      where: u.is_active == ^true,
       where: u.id not in ^has_read_notifications,
       group_by: u.id,
       having:
@@ -2218,9 +2218,9 @@ defmodule Pleroma.User do
   end
 
   # Internal function; public one is `deactivate/2`
-  defp set_activation_status(user, deactivated) do
+  defp set_activation_status(user, status) do
     user
-    |> cast(%{deactivated: deactivated}, [:deactivated])
+    |> cast(%{is_active: status}, [:is_active])
     |> update_and_set_cache()
   end
 
index ab9554bd212a64639397073e98d4f4317f477569..c3551a0aa4d74eb8ad9d2459cf255d838b1a54a0 100644 (file)
@@ -151,7 +151,7 @@ defmodule Pleroma.User.Query do
   end
 
   defp compose_query({:deactivated, true}, query) do
-    where(query, [u], u.deactivated == ^true)
+    where(query, [u], u.is_active == false)
   end
 
   defp compose_query({:confirmation_pending, bool}, query) do
index c5bc08153b1c46f1d160db17e8b5b87f6147d271..d0bb07aab8f2327a2acab59901bf1f7a671a2a70 100644 (file)
@@ -56,7 +56,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
 
   defp check_actor_is_active(actor) when is_binary(actor) do
     case User.get_cached_by_ap_id(actor) do
-      %User{deactivated: deactivated} -> not deactivated
+      %User{is_active: true} -> true
       _ -> false
     end
   end
index f5f87ca5d596aa6d63c1edc3d973a70cf6554a3a..093549a45873124904298545313f2d223812109b 100644 (file)
@@ -35,7 +35,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations do
     cng
     |> validate_change(field_name, fn field_name, actor ->
       case User.get_cached_by_ap_id(actor) do
-        %User{deactivated: true} ->
+        %User{is_active: false} ->
           [{field_name, "user is deactivated"}]
 
         %User{} ->
index fa710c7ec219ec9de9caa3298386acd7aba0fc21..83dd3c918965ed9e49cc4409d9998018a10f467b 100644 (file)
@@ -172,9 +172,9 @@ defmodule Pleroma.Web.AdminAPI.UserController do
   def toggle_activation(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
     user = User.get_cached_by_nickname(nickname)
 
-    {:ok, updated_user} = User.deactivate(user, !user.deactivated)
+    {:ok, updated_user} = User.deactivate(user, !user.is_active)
 
-    action = if user.deactivated, do: "activate", else: "deactivate"
+    action = if !user.is_active, do: "activate", else: "deactivate"
 
     ModerationLog.insert_log(%{
       actor: admin,
index 37188bfeb27ef64d8a99c5a1305ffc0268035f18..c4be096a9ce362920a5fd0ee65d0423310887093 100644 (file)
@@ -73,7 +73,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
       "avatar" => avatar,
       "nickname" => user.nickname,
       "display_name" => display_name,
-      "deactivated" => user.deactivated,
+      "is_active" => user.is_active,
       "local" => user.local,
       "roles" => User.roles(user),
       "tags" => user.tags || [],
index 526698fc1699dfe30826ccd467ef625eb8679957..6395cf20940f2af4d69e4ba739492b9239dd5392 100644 (file)
@@ -182,7 +182,7 @@ defmodule Pleroma.Web.ApiSpec.Admin.ReportOperation do
       properties:
         Map.merge(Account.schema().properties, %{
           nickname: %Schema{type: :string},
-          deactivated: %Schema{type: :boolean},
+          is_active: %Schema{type: :boolean},
           local: %Schema{type: :boolean},
           roles: %Schema{
             type: :object,
index a2319baccb8511bcae48f9f125c69c1632dac8c8..096e1a95c416689e5ffa6bf8aa7adf1a3d902dd3 100644 (file)
@@ -132,7 +132,7 @@ defmodule Pleroma.Web.ApiSpec.Admin.StatusOperation do
         avatar: %Schema{type: :string},
         nickname: %Schema{type: :string},
         display_name: %Schema{type: :string},
-        deactivated: %Schema{type: :boolean},
+        is_active: %Schema{type: :boolean},
         local: %Schema{type: :boolean},
         roles: %Schema{
           type: :object,
index 2768f02914090b546a90067bd3ebd562e8848f00..bd90026204ce9fa21b8fa5ca3aaf2e222f4f70cb 100644 (file)
@@ -376,7 +376,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
   defp maybe_put_allow_following_move(data, _, _), do: data
 
   defp maybe_put_activation_status(data, user, %User{is_admin: true}) do
-    Kernel.put_in(data, [:pleroma, :deactivated], user.deactivated)
+    Kernel.put_in(data, [:pleroma, :deactivated], !user.is_active)
   end
 
   defp maybe_put_activation_status(data, _, _), do: data
index e7903dde8b68ba010aafe54ef5a73037413d70cb..6ace3e0b5cac0124c29d2437357bf6cba413dd2f 100644 (file)
@@ -14,7 +14,7 @@ defmodule Pleroma.Web.MongooseIM.MongooseIMController do
   plug(RateLimiter, [name: :authentication, params: ["user"]] when action == :check_password)
 
   def user_exists(conn, %{"user" => username}) do
-    with %User{} <- Repo.get_by(User, nickname: username, local: true, deactivated: false) do
+    with %User{} <- Repo.get_by(User, nickname: username, local: true, is_active: true) do
       conn
       |> json(true)
     else
@@ -26,7 +26,7 @@ defmodule Pleroma.Web.MongooseIM.MongooseIMController do
   end
 
   def check_password(conn, %{"user" => username, "pass" => password}) do
-    with %User{password_hash: password_hash, deactivated: false} <-
+    with %User{password_hash: password_hash, is_active: true} <-
            Repo.get_by(User, nickname: username, local: true),
          true <- AuthenticationPlug.checkpw(password, password_hash) do
       conn
index 809ef9b4065c85ed8cb74fe681eab5814784ceef..c94527e6d284929e0879483cdd3fa0409250e1fb 100644 (file)
@@ -26,7 +26,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiReactionView do
     user_ap_ids
     |> Enum.map(&Pleroma.User.get_cached_by_ap_id/1)
     |> Enum.filter(fn
-      %{deactivated: false} -> true
+      %{is_active: true} -> true
       _ -> false
     end)
   end
index f6d721da6ed9cc22b41ac19a66b444577e131b5a..76ca82d20b6568e60ecd1a020c01e3a09b0c637e 100644 (file)
@@ -59,7 +59,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
 
   def password_reset(nickname_or_email) do
     with true <- is_binary(nickname_or_email),
-         %User{local: true, email: email, deactivated: false} = user when is_binary(email) <-
+         %User{local: true, email: email, is_active: true} = user when is_binary(email) <-
            User.get_by_nickname_or_email(nickname_or_email),
          {:ok, token_record} <- Pleroma.PasswordResetToken.create_token(user) do
       user
diff --git a/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs b/priv/repo/migrations/20201012173004_refactor_deactivated_user_field.exs
new file mode 100644 (file)
index 0000000..ac0afdd
--- /dev/null
@@ -0,0 +1,18 @@
+defmodule Pleroma.Repo.Migrations.RefactorDeactivatedUserField do
+  use Ecto.Migration
+
+  def up do
+    # Flip the values before we change the meaning of the column
+    execute("UPDATE users SET deactivated = NOT deactivated;")
+    execute("ALTER TABLE users RENAME COLUMN deactivated TO is_active;")
+    execute("ALTER TABLE users ALTER COLUMN is_active SET DEFAULT true;")
+    execute("ALTER INDEX users_deactivated_index RENAME TO users_is_active_index;")
+  end
+
+  def down do
+    execute("UPDATE users SET is_active = NOT is_active;")
+    execute("ALTER TABLE users RENAME COLUMN is_active TO deactivated;")
+    execute("ALTER TABLE users ALTER COLUMN deactivated SET DEFAULT false;")
+    execute("ALTER INDEX users_is_active_index RENAME TO users_deactivated_index;")
+  end
+end
index 78cdf178b08a0cdbefbf55afc8867c464f39a0f4..f8f941b5973516c2c25902adca4f85d4a6b58eec 100644 (file)
@@ -63,7 +63,7 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
         insert(:user, %{
           confirmation_pending: true,
           confirmation_token: "mytoken",
-          deactivated: false,
+          is_active: true,
           email: "local1@pleroma.com",
           local: true
         })
@@ -72,7 +72,7 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
         insert(:user, %{
           confirmation_pending: true,
           confirmation_token: "mytoken",
-          deactivated: false,
+          is_active: true,
           email: "local2@pleroma.com",
           local: true
         })
@@ -90,28 +90,28 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
       insert(:user, %{
         confirmation_pending: false,
         confirmation_token: "mytoken",
-        deactivated: false,
+        is_active: true,
         email: "confirmed@pleroma.com",
         local: true
       })
 
       # remote user
       insert(:user, %{
-        deactivated: false,
+        is_active: true,
         email: "remote@not-pleroma.com",
         local: false
       })
 
       # deactivated user =
       insert(:user, %{
-        deactivated: true,
+        is_active: false,
         email: "deactivated@pleroma.com",
         local: false
       })
 
       # invisible user
       insert(:user, %{
-        deactivated: false,
+        is_active: true,
         email: "invisible@pleroma.com",
         local: true,
         invisible: true
index 7c68b8a37e240be782fd9e2653c83aeb7f897c93..fdf2ceec4a82d61c2ff47e8f1faeac219d985f7b 100644 (file)
@@ -102,7 +102,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
         assert_received {:mix_shell, :info, [message]}
         assert message =~ " deleted"
-        assert %{deactivated: true} = User.get_by_nickname(user.nickname)
+        assert %{is_active: false} = User.get_by_nickname(user.nickname)
 
         assert called(Pleroma.Web.Federator.publish(:_))
       end
@@ -140,7 +140,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
         assert_received {:mix_shell, :info, [message]}
         assert message =~ " deleted"
-        assert %{deactivated: true} = User.get_by_nickname(user.nickname)
+        assert %{is_active: false} = User.get_by_nickname(user.nickname)
 
         assert called(Pleroma.Web.Federator.publish(:_))
         refute Pleroma.Repo.get(Pleroma.Activity, like_activity.id)
@@ -167,11 +167,11 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       assert message =~ " deactivated"
 
       user = User.get_cached_by_nickname(user.nickname)
-      assert user.deactivated
+      refute user.is_active
     end
 
     test "user is activated" do
-      user = insert(:user, deactivated: true)
+      user = insert(:user, is_active: false)
 
       Mix.Tasks.Pleroma.User.run(["toggle_activated", user.nickname])
 
@@ -179,7 +179,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       assert message =~ " activated"
 
       user = User.get_cached_by_nickname(user.nickname)
-      refute user.deactivated
+      assert user.is_active
     end
 
     test "no user to toggle" do
@@ -210,7 +210,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
       user = User.get_cached_by_nickname(user.nickname)
       assert Enum.empty?(Enum.filter(User.get_friends(user), & &1.local))
-      assert user.deactivated
+      refute user.is_active
     end
 
     test "no user to deactivate" do
index bdf17e96a094a8b1a6c57df48c9c7b03d6af06f7..42e37f0a51f28d4aa3279315323157fc3e4ae4ee 100644 (file)
@@ -202,11 +202,11 @@ defmodule Pleroma.UserTest do
 
   test "doesn't return follow requests for deactivated accounts" do
     locked = insert(:user, is_locked: true)
-    pending_follower = insert(:user, %{deactivated: true})
+    pending_follower = insert(:user, %{is_active: false})
 
     CommonAPI.follow(pending_follower, locked)
 
-    assert true == pending_follower.deactivated
+    refute pending_follower.is_active
     assert [] = User.get_follow_requests(locked)
   end
 
@@ -275,7 +275,7 @@ defmodule Pleroma.UserTest do
 
   test "can't follow a deactivated users" do
     user = insert(:user)
-    followed = insert(:user, %{deactivated: true})
+    followed = insert(:user, %{is_active: false})
 
     {:error, _} = User.follow(user, followed)
   end
@@ -1316,11 +1316,11 @@ defmodule Pleroma.UserTest do
   describe ".deactivate" do
     test "can de-activate then re-activate a user" do
       user = insert(:user)
-      assert false == user.deactivated
+      assert user.is_active
       {:ok, user} = User.deactivate(user)
-      assert true == user.deactivated
+      refute user.is_active
       {:ok, user} = User.deactivate(user, false)
-      assert false == user.deactivated
+      assert user.is_active
     end
 
     test "hide a user from followers" do
@@ -1544,7 +1544,7 @@ defmodule Pleroma.UserTest do
       follower = User.get_cached_by_id(follower.id)
 
       refute User.following?(follower, user)
-      assert %{deactivated: true} = User.get_by_id(user.id)
+      assert %{is_active: false} = User.get_by_id(user.id)
 
       assert [] == User.get_follow_requests(locked_user)
 
@@ -1585,8 +1585,8 @@ defmodule Pleroma.UserTest do
       {:ok, job} = User.delete(user)
       {:ok, _} = ObanHelpers.perform(job)
 
-      assert %{deactivated: true} = User.get_cached_by_id(user.id)
-      assert %{deactivated: true} = User.get_by_id(user.id)
+      assert %{is_active: false} = User.get_cached_by_id(user.id)
+      assert %{is_active: false} = User.get_by_id(user.id)
     end
   end
 
@@ -1622,7 +1622,7 @@ defmodule Pleroma.UserTest do
         registration_reason: "ahhhhh",
         confirmation_token: "qqqq",
         domain_blocks: ["lain.com"],
-        deactivated: true,
+        is_active: false,
         ap_enabled: true,
         is_moderator: true,
         is_admin: true,
@@ -1664,7 +1664,7 @@ defmodule Pleroma.UserTest do
              registration_reason: nil,
              confirmation_token: nil,
              domain_blocks: [],
-             deactivated: true,
+             is_active: false,
              ap_enabled: false,
              is_moderator: false,
              is_admin: false,
@@ -1750,7 +1750,7 @@ defmodule Pleroma.UserTest do
     end
 
     test "returns :deactivated for deactivated user" do
-      user = insert(:user, local: true, confirmation_pending: false, deactivated: true)
+      user = insert(:user, local: true, confirmation_pending: false, is_active: false)
       assert User.account_status(user) == :deactivated
     end
 
@@ -1908,7 +1908,7 @@ defmodule Pleroma.UserTest do
 
       users =
         Enum.map(1..total, fn _ ->
-          insert(:user, last_digest_emailed_at: days_ago(20), deactivated: false)
+          insert(:user, last_digest_emailed_at: days_ago(20), is_active: true)
         end)
 
       inactive_users_ids =
@@ -1926,7 +1926,7 @@ defmodule Pleroma.UserTest do
 
       users =
         Enum.map(1..total, fn _ ->
-          insert(:user, last_digest_emailed_at: days_ago(20), deactivated: false)
+          insert(:user, last_digest_emailed_at: days_ago(20), is_active: true)
         end)
 
       {inactive, active} = Enum.split(users, trunc(total / 2))
@@ -1959,7 +1959,7 @@ defmodule Pleroma.UserTest do
 
       users =
         Enum.map(1..total, fn _ ->
-          insert(:user, last_digest_emailed_at: days_ago(20), deactivated: false)
+          insert(:user, last_digest_emailed_at: days_ago(20), is_active: true)
         end)
 
       [sender | recipients] = users
@@ -2029,7 +2029,7 @@ defmodule Pleroma.UserTest do
       user1 = insert(:user, local: false, ap_id: "http://localhost:4001/users/masto_closed")
       user2 = insert(:user, local: false, ap_id: "http://localhost:4001/users/fuser2")
       insert(:user, local: true)
-      insert(:user, local: false, deactivated: true)
+      insert(:user, local: false, is_active: false)
       {:ok, user1: user1, user2: user2}
     end
 
index 35ced375bd85eedba9143e893f1d98a09cd2143e..20f0d4b70d4c65963f73377814c9c6b4c6268d63 100644 (file)
@@ -39,7 +39,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects.DeleteTest do
       {:ok, _delete, _} = SideEffects.handle(delete)
       ObanHelpers.perform_all()
 
-      assert User.get_cached_by_ap_id(user.ap_id).deactivated
+      refute User.get_cached_by_ap_id(user.ap_id).is_active
     end
   end
 
index 2d94f07c9f82945a6a569bdcc2af144b560225a9..c5c771c43b8ee12f99179d5a1cf1f14f40a5e99f 100644 (file)
@@ -170,7 +170,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
       {:ok, _, _} = SideEffects.handle(delete)
       ObanHelpers.perform_all()
 
-      assert User.get_cached_by_id(user.id).deactivated
+      refute User.get_cached_by_id(user.id).is_active
     end
 
     test "when activation is required", %{delete: delete, user: user} do
index a2d64620d36eb1307c7d6c064d35bbde353a72b4..958675835ed61039d4e9b05db0ecb5478606e80c 100644 (file)
@@ -134,7 +134,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
           ap_id: data["actor"],
           local: false,
           last_refreshed_at: DateTime.utc_now(),
-          deactivated: true
+          is_active: false
         )
 
       _recipient = insert(:user, ap_id: List.first(data["to"]), local: true)
index 33132dff67d802d2dd1c886e99585e0b3746fcdf..b7160bf589acb9f9f79afc2228e5aa53f22fe9cb 100644 (file)
@@ -97,7 +97,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
     {:ok, _} = Transmogrifier.handle_incoming(data)
     ObanHelpers.perform_all()
 
-    assert User.get_cached_by_ap_id(ap_id).deactivated
+    refute User.get_cached_by_ap_id(ap_id).is_active
   end
 
   test "it fails for incoming user deletes with spoofed origin" do
index 108f27ef726b5614537b2322db335601bb6a3263..be99ad93decef971b1960ebd47643b7647a97ab8 100644 (file)
@@ -154,7 +154,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
     test "it does not work for deactivated users" do
       data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
 
-      insert(:user, ap_id: data["actor"], deactivated: true)
+      insert(:user, ap_id: data["actor"], is_active: false)
 
       assert {:error, _} = Transmogrifier.handle_incoming(data)
     end
index 976990d5c047950b45d619c98ae362cb94fad705..17e09a1e84265a317145317e55b3eb9604b9f3b7 100644 (file)
@@ -47,7 +47,7 @@ defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
 
       assert account["id"] == actor.id
       assert account["nickname"] == actor.nickname
-      assert account["deactivated"] == actor.deactivated
+      assert account["is_active"] == actor.is_active
       assert account["confirmation_pending"] == actor.confirmation_pending
     end
   end
index 40d39aae77375d58e59c071843f18dce1123ccef..6759032177016c03e5b82cdc8e857297a378850d 100644 (file)
@@ -169,7 +169,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
       assert user.note_count == 1
       assert user.follower_count == 1
       assert user.following_count == 1
-      refute user.deactivated
+      assert user.is_active
 
       with_mock Pleroma.Web.Federator,
         publish: fn _ -> nil end,
@@ -181,7 +181,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
 
         ObanHelpers.perform_all()
 
-        assert User.get_by_nickname(user.nickname).deactivated
+        refute User.get_by_nickname(user.nickname).is_active
 
         log_entry = Repo.one(ModerationLog)
 
@@ -191,7 +191,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
         assert json_response(conn, 200) == [user.nickname]
 
         user = Repo.get(User, user.id)
-        assert user.deactivated
+        refute user.is_active
 
         assert user.avatar == %{}
         assert user.banner == %{}
@@ -621,7 +621,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
             "roles" => %{"admin" => true, "moderator" => false}
           }),
           user_response(old_admin, %{
-            "deactivated" => false,
+            "is_active" => true,
             "roles" => %{"admin" => true, "moderator" => false}
           })
         ]
@@ -694,11 +694,11 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
       users =
         [
           user_response(admin, %{
-            "deactivated" => false,
+            "is_active" => true,
             "roles" => %{"admin" => true, "moderator" => false}
           }),
           user_response(second_admin, %{
-            "deactivated" => false,
+            "is_active" => true,
             "roles" => %{"admin" => true, "moderator" => false}
           })
         ]
@@ -723,7 +723,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
                "page_size" => 50,
                "users" => [
                  user_response(moderator, %{
-                   "deactivated" => false,
+                   "is_active" => true,
                    "roles" => %{"admin" => false, "moderator" => true}
                  })
                ]
@@ -839,10 +839,10 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
     test "it works with multiple filters" do
       admin = insert(:user, nickname: "john", is_admin: true)
       token = insert(:oauth_admin_token, user: admin)
-      user = insert(:user, nickname: "bob", local: false, deactivated: true)
+      user = insert(:user, nickname: "bob", local: false, is_active: false)
 
-      insert(:user, nickname: "ken", local: true, deactivated: true)
-      insert(:user, nickname: "bobb", local: false, deactivated: false)
+      insert(:user, nickname: "ken", local: true, is_active: false)
+      insert(:user, nickname: "bobb", local: false, is_active: true)
 
       conn =
         build_conn()
@@ -873,8 +873,8 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
   end
 
   test "PATCH /api/pleroma/admin/users/activate", %{admin: admin, conn: conn} do
-    user_one = insert(:user, deactivated: true)
-    user_two = insert(:user, deactivated: true)
+    user_one = insert(:user, is_active: false)
+    user_two = insert(:user, is_active: false)
 
     conn =
       patch(
@@ -884,7 +884,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
       )
 
     response = json_response(conn, 200)
-    assert Enum.map(response["users"], & &1["deactivated"]) == [false, false]
+    assert Enum.map(response["users"], & &1["is_active"]) == [true, true]
 
     log_entry = Repo.one(ModerationLog)
 
@@ -893,8 +893,8 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
   end
 
   test "PATCH /api/pleroma/admin/users/deactivate", %{admin: admin, conn: conn} do
-    user_one = insert(:user, deactivated: false)
-    user_two = insert(:user, deactivated: false)
+    user_one = insert(:user, is_active: true)
+    user_two = insert(:user, is_active: true)
 
     conn =
       patch(
@@ -904,7 +904,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
       )
 
     response = json_response(conn, 200)
-    assert Enum.map(response["users"], & &1["deactivated"]) == [true, true]
+    assert Enum.map(response["users"], & &1["is_active"]) == [false, false]
 
     log_entry = Repo.one(ModerationLog)
 
@@ -940,7 +940,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
     assert json_response(conn, 200) ==
              user_response(
                user,
-               %{"deactivated" => !user.deactivated}
+               %{"is_active" => user.is_active}
              )
 
     log_entry = Repo.one(ModerationLog)
@@ -951,7 +951,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
 
   defp user_response(user, attrs \\ %{}) do
     %{
-      "deactivated" => user.deactivated,
+      "is_active" => user.is_active,
       "id" => user.id,
       "email" => user.email,
       "nickname" => user.nickname,
index 307578ae00a1a189447a3c9dd73f5ef50535c7ac..e5d1462561fd502a00e970bf898090415b9c4ec4 100644 (file)
@@ -47,9 +47,9 @@ defmodule Pleroma.Web.AdminAPI.SearchTest do
     end
 
     test "it returns active/deactivated users" do
-      insert(:user, deactivated: true)
-      insert(:user, deactivated: true)
-      insert(:user, deactivated: false)
+      insert(:user, is_active: false)
+      insert(:user, is_active: false)
+      insert(:user, is_active: true)
 
       {:ok, _results, active_count} =
         Search.user(%{
@@ -70,7 +70,7 @@ defmodule Pleroma.Web.AdminAPI.SearchTest do
     test "it returns specific user" do
       insert(:user)
       insert(:user)
-      user = insert(:user, nickname: "bob", local: true, deactivated: false)
+      user = insert(:user, nickname: "bob", local: true, is_active: true)
 
       {:ok, _results, total_count} = Search.user(%{query: ""})
 
index 2ece9280663e406fb6c7b29c8bccf09f1c4053b6..9d5a3d1191bf4c94d5704794c3bad2cd3b460170 100644 (file)
@@ -518,7 +518,7 @@ defmodule Pleroma.Web.CommonAPITest do
     end
 
     test "deactivated users can't post" do
-      user = insert(:user, deactivated: true)
+      user = insert(:user, is_active: false)
       assert {:error, _} = CommonAPI.post(user, %{status: "ye"})
     end
 
index 7b3cc7344d72be2332d498a07bafef63a36ee422..d44b97cc74b0bdd2835a9afd2b48130b44120dab 100644 (file)
@@ -126,7 +126,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
     end
 
     test "returns 404 for deactivated user", %{conn: conn} do
-      user = insert(:user, deactivated: true)
+      user = insert(:user, is_active: false)
 
       assert %{"error" => "Can't find user"} =
                conn
@@ -256,7 +256,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
     end
 
     test "deactivated user", %{conn: conn} do
-      user = insert(:user, deactivated: true)
+      user = insert(:user, is_active: false)
 
       assert %{"error" => "Can't find user"} ==
                conn
index 27c0fceffc36a2b47fa1571c93e48e39f21456b9..1872dfd594042d6e4c48558a483a18f0487a5d70 100644 (file)
@@ -136,7 +136,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthControllerTest do
     end
 
     test "it returns 204 when user is deactivated", %{conn: conn, user: user} do
-      {:ok, user} = Repo.update(Ecto.Changeset.change(user, deactivated: true, local: true))
+      {:ok, user} = Repo.update(Ecto.Changeset.change(user, is_active: false, local: true))
       conn = post(conn, "/auth/password?email=#{user.email}")
 
       assert empty_json_response(conn)
index 1d0f86e872656883db1c87c7016f44e0f1654ef6..d7bb0ffd89b4c8013732e2813fd4c43509c28e0a 100644 (file)
@@ -57,7 +57,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
     user = insert(:user, %{local: true})
 
     user2 = insert(:user, %{local: true})
-    {:ok, _user2} = User.deactivate(user2, !user2.deactivated)
+    {:ok, _user2} = User.deactivate(user2, user2.is_active)
 
     insert(:user, %{local: false, nickname: "u@peer1.com"})
     insert(:user, %{local: false, nickname: "u@peer2.com"})
index f14330908b0c5d22a9639ba5473a6e367cd28232..402bfd76f53d824f2e36d79aa0682622a59125e8 100644 (file)
@@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPITest do
   describe "follow/3" do
     test "returns error when followed user is deactivated" do
       follower = insert(:user)
-      user = insert(:user, local: true, deactivated: true)
+      user = insert(:user, local: true, is_active: false)
       assert {:error, _error} = MastodonAPI.follow(follower, user)
     end
 
index 32fe081968f317e9d81f2d6b66116e3a8ed60dde..ed8c7484d779a130685be922750edc0fe7d23db1 100644 (file)
@@ -211,7 +211,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
 
   test "Represent a deactivated user for an admin" do
     admin = insert(:user, is_admin: true)
-    deactivated_user = insert(:user, deactivated: true)
+    deactivated_user = insert(:user, is_active: false)
     represented = AccountView.render("show.json", %{user: deactivated_user, for: admin})
     assert represented[:pleroma][:deactivated] == true
   end
index a7225d45c23da9108bd41aafb64a57427386b014..43c4dfa33cdde5a5862e88ea4d5ad9a9bc1c65f3 100644 (file)
@@ -9,7 +9,7 @@ defmodule Pleroma.Web.MongooseIMControllerTest do
   test "/user_exists", %{conn: conn} do
     _user = insert(:user, nickname: "lain")
     _remote_user = insert(:user, nickname: "alice", local: false)
-    _deactivated_user = insert(:user, nickname: "konata", deactivated: true)
+    _deactivated_user = insert(:user, nickname: "konata", is_active: false)
 
     res =
       conn
@@ -46,7 +46,7 @@ defmodule Pleroma.Web.MongooseIMControllerTest do
     _deactivated_user =
       insert(:user,
         nickname: "konata",
-        deactivated: true,
+        is_active: false,
         password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt("cool")
       )
 
index bf47afed820cf05a39562b9298784fe302b223a7..236ecad4240ff7e57585475ecaf1534d525be8d2 100644 (file)
@@ -956,7 +956,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
       user =
         insert(:user,
           password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt(password),
-          deactivated: true
+          is_active: false
         )
 
       app = insert(:oauth_app)
index bee413fbfb717550aac2c3598ebc6f956cf149a5..9e7061189cc7664340dc890918f1ae2bb60c3e68 100644 (file)
@@ -33,7 +33,7 @@ defmodule Pleroma.Web.Plugs.UserEnabledPlugTest do
   end
 
   test "with a user that is deactivated, it removes that user", %{conn: conn} do
-    user = insert(:user, deactivated: true)
+    user = insert(:user, is_active: false)
 
     conn =
       conn
index 51db2fe5e8635f069b038f6df5211af9f7e98139..f9d9e05259dfd5c2c4f5d51bf4f3ce896067fc52 100644 (file)
@@ -141,7 +141,7 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
     end
 
     test "returns error when user is deactivated", %{conn: conn} do
-      user = insert(:user, deactivated: true)
+      user = insert(:user, is_active: false)
       user2 = insert(:user)
 
       response =
index 6d007ab66ff6d5da17782869d9a72d31e1f5c846..283c616780636a1b57d0310f4727f74c41b78abe 100644 (file)
@@ -164,7 +164,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
 
       user = User.get_cached_by_id(user.id)
 
-      assert user.deactivated == true
+      refute user.is_active
     end
 
     test "with valid permissions and invalid password, it returns an error", %{conn: conn} do
@@ -178,7 +178,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
       assert response == %{"error" => "Invalid password."}
       user = User.get_cached_by_id(user.id)
 
-      refute user.deactivated
+      assert user.is_active
     end
   end
 
@@ -428,7 +428,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
       assert json_response(conn, 200) == %{"status" => "success"}
 
       user = User.get_by_id(user.id)
-      assert user.deactivated == true
+      refute user.is_active
       assert user.name == nil
       assert user.bio == ""
       assert user.password_hash == nil