Change user.confirmation_pending field to user.is_confirmed
authorMark Felder <feld@FreeBSD.org>
Tue, 13 Oct 2020 19:29:34 +0000 (14:29 -0500)
committerMark Felder <feld@feld.me>
Fri, 15 Jan 2021 18:44:41 +0000 (12:44 -0600)
29 files changed:
lib/mix/tasks/pleroma/email.ex
lib/mix/tasks/pleroma/user.ex
lib/pleroma/user.ex
lib/pleroma/user/query.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/api_spec/operations/chat_operation.ex
lib/pleroma/web/api_spec/schemas/account.ex
lib/pleroma/web/api_spec/schemas/chat.ex
lib/pleroma/web/api_spec/schemas/status.ex
lib/pleroma/web/mastodon_api/views/account_view.ex
lib/pleroma/web/twitter_api/controller.ex
priv/repo/migrations/20201013184200_refactor_confirmation_pending_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_test.exs
test/pleroma/web/admin_api/controllers/admin_api_controller_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/mastodon_api/controllers/account_controller_test.exs
test/pleroma/web/mastodon_api/views/account_view_test.exs
test/pleroma/web/o_auth/o_auth_controller_test.exs
test/pleroma/web/pleroma_api/controllers/account_controller_test.exs
test/pleroma/web/plugs/user_enabled_plug_test.exs
test/pleroma/web/twitter_api/controller_test.exs
test/pleroma/web/twitter_api/twitter_api_test.exs

index 54f158f73479d07c91bcc09208d82387d8b6839e..6b7555fb81630dea18adaf7d786099ae3f8956ab 100644 (file)
@@ -34,7 +34,7 @@ defmodule Mix.Tasks.Pleroma.Email do
     Pleroma.User.Query.build(%{
       local: true,
       deactivated: false,
-      confirmation_pending: true,
+      is_confirmed: false,
       invisible: false
     })
     |> Pleroma.Repo.chunk_stream(500)
index f90c045fe3c71113b11de3b718d712af5f9e5ddb..a397d17488d8ab48c3a95e370b6e17e358970706 100644 (file)
@@ -74,7 +74,7 @@ defmodule Mix.Tasks.Pleroma.User do
         bio: bio
       }
 
-      changeset = User.register_changeset(%User{}, params, need_confirmation: false)
+      changeset = User.register_changeset(%User{}, params, is_confirmed: true)
       {:ok, _user} = User.register(changeset)
 
       shell_info("User #{nickname} created")
@@ -351,7 +351,7 @@ defmodule Mix.Tasks.Pleroma.User do
     with %User{} = user <- User.get_cached_by_nickname(nickname) do
       {:ok, user} = User.confirm(user)
 
-      message = if user.confirmation_pending, do: "needs", else: "doesn't need"
+      message = if !user.is_confirmed, do: "needs", else: "doesn't need"
 
       shell_info("#{nickname} #{message} confirmation.")
     else
@@ -457,7 +457,7 @@ defmodule Mix.Tasks.Pleroma.User do
   defp set_confirmed(user, value) do
     {:ok, user} = User.need_confirmation(user, !value)
 
-    shell_info("Confirmation pending status of #{user.nickname}: #{user.confirmation_pending}")
+    shell_info("Confirmation status of #{user.nickname}: #{user.is_confirmed}")
     user
   end
 end
index 6a81adfd6a37f76cd73f95f39d332972f74f2174..04ce1768d0a707db8209b41d47646caa400871c0 100644 (file)
@@ -110,7 +110,7 @@ defmodule Pleroma.User do
     field(:follower_count, :integer, default: 0)
     field(:following_count, :integer, default: 0)
     field(:is_locked, :boolean, default: false)
-    field(:confirmation_pending, :boolean, default: false)
+    field(:is_confirmed, :boolean, default: true)
     field(:password_reset_pending, :boolean, default: false)
     field(:approval_pending, :boolean, default: false)
     field(:registration_reason, :string, default: nil)
@@ -290,7 +290,7 @@ defmodule Pleroma.User do
   def account_status(%User{password_reset_pending: true}), do: :password_reset_pending
   def account_status(%User{local: true, approval_pending: true}), do: :approval_pending
 
-  def account_status(%User{local: true, confirmation_pending: true}) do
+  def account_status(%User{local: true, is_confirmed: false}) do
     if Config.get([:instance, :account_activation_required]) do
       :confirmation_pending
     else
@@ -808,7 +808,7 @@ defmodule Pleroma.User do
     end
   end
 
-  def post_register_action(%User{confirmation_pending: true} = user) do
+  def post_register_action(%User{is_confirmed: false} = user) do
     with {:ok, _} <- try_send_confirmation_email(user) do
       {:ok, user}
     end
@@ -821,7 +821,7 @@ defmodule Pleroma.User do
     end
   end
 
-  def post_register_action(%User{approval_pending: false, confirmation_pending: false} = user) do
+  def post_register_action(%User{approval_pending: false, is_confirmed: true} = user) do
     with {:ok, user} <- autofollow_users(user),
          {:ok, _} <- autofollowing_users(user),
          {:ok, user} <- set_cache(user),
@@ -882,7 +882,7 @@ defmodule Pleroma.User do
   def send_welcome_email(_), do: {:ok, :noop}
 
   @spec try_send_confirmation_email(User.t()) :: {:ok, :enqueued | :noop}
-  def try_send_confirmation_email(%User{confirmation_pending: true, email: email} = user)
+  def try_send_confirmation_email(%User{is_confirmed: false, email: email} = user)
       when is_binary(email) do
     if Config.get([:instance, :account_activation_required]) do
       send_confirmation_email(user)
@@ -1642,7 +1642,7 @@ defmodule Pleroma.User do
     end)
   end
 
-  def confirm(%User{confirmation_pending: true} = user) do
+  def confirm(%User{is_confirmed: false} = user) do
     with chg <- confirmation_changeset(user, need_confirmation: false),
          {:ok, user} <- update_and_set_cache(chg) do
       post_register_action(user)
@@ -1682,7 +1682,7 @@ defmodule Pleroma.User do
       follower_count: 0,
       following_count: 0,
       is_locked: false,
-      confirmation_pending: false,
+      is_confirmed: true,
       password_reset_pending: false,
       approval_pending: false,
       registration_reason: nil,
@@ -2313,17 +2313,17 @@ defmodule Pleroma.User do
     params =
       if need_confirmation? do
         %{
-          confirmation_pending: true,
+          is_confirmed: false,
           confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64()
         }
       else
         %{
-          confirmation_pending: false,
+          is_confirmed: true,
           confirmation_token: nil
         }
       end
 
-    cast(user, params, [:confirmation_pending, :confirmation_token])
+    cast(user, params, [:is_confirmed, :confirmation_token])
   end
 
   @spec approval_changeset(User.t(), keyword()) :: Changeset.t()
index ab9554bd212a64639397073e98d4f4317f477569..481c41d8c7dee35992bb44d45f852c6091081f27 100644 (file)
@@ -155,7 +155,7 @@ defmodule Pleroma.User.Query do
   end
 
   defp compose_query({:confirmation_pending, bool}, query) do
-    where(query, [u], u.confirmation_pending == ^bool)
+    where(query, [u], u.is_confirmed != ^bool)
   end
 
   defp compose_query({:need_approval, _}, query) do
@@ -163,7 +163,7 @@ defmodule Pleroma.User.Query do
   end
 
   defp compose_query({:unconfirmed, _}, query) do
-    where(query, [u], u.confirmation_pending)
+    where(query, [u], u.is_confirmed == false)
   end
 
   defp compose_query({:followers, %User{id: id}}, query) do
index 37188bfeb27ef64d8a99c5a1305ffc0268035f18..10d2e698b76dfe4f368742ec5cac2d16a1f966b8 100644 (file)
@@ -77,7 +77,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
       "local" => user.local,
       "roles" => User.roles(user),
       "tags" => user.tags || [],
-      "confirmation_pending" => user.confirmation_pending,
+      "is_confirmed" => user.is_confirmed,
       "approval_pending" => user.approval_pending,
       "url" => user.uri || user.ap_id,
       "registration_reason" => user.registration_reason,
index 526698fc1699dfe30826ccd467ef625eb8679957..d60e84a660ca70f3a1992935b0c01b35d3b4c315 100644 (file)
@@ -191,7 +191,7 @@ defmodule Pleroma.Web.ApiSpec.Admin.ReportOperation do
               moderator: %Schema{type: :boolean}
             }
           },
-          confirmation_pending: %Schema{type: :boolean}
+          is_confirmed: %Schema{type: :boolean}
         })
     }
   end
index a2319baccb8511bcae48f9f125c69c1632dac8c8..fed3da27a79570033602621c72731bae3ad26b3e 100644 (file)
@@ -142,7 +142,7 @@ defmodule Pleroma.Web.ApiSpec.Admin.StatusOperation do
           }
         },
         tags: %Schema{type: :string},
-        confirmation_pending: %Schema{type: :string}
+        is_confirmed: %Schema{type: :string}
       }
     }
   end
index a90bc4cc913701e4142002773ea6493d6553f976..e5ee6e695c510f53517a024cff5e7016fad66379 100644 (file)
@@ -236,7 +236,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
           "account" => %{
             "pleroma" => %{
               "is_admin" => false,
-              "confirmation_pending" => false,
+              "is_confirmed" => true,
               "hide_followers_count" => false,
               "is_moderator" => false,
               "hide_favorites" => true,
index 35158c14025207a5c2680c0c57d372e190a8ab61..4f9b564d1e9e885f81919952bb1e22db25e00295 100644 (file)
@@ -48,7 +48,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
           },
           background_image: %Schema{type: :string, nullable: true, format: :uri},
           chat_token: %Schema{type: :string},
-          confirmation_pending: %Schema{
+          is_confirmed: %Schema{
             type: :boolean,
             description:
               "whether the user account is waiting on email confirmation to be activated"
@@ -166,7 +166,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
       "pleroma" => %{
         "allow_following_move" => true,
         "background_image" => nil,
-        "confirmation_pending" => true,
+        "is_confirmed" => false,
         "hide_favorites" => true,
         "hide_followers" => false,
         "hide_followers_count" => false,
index b3912c17319b780402ea18542e2a5d3fcd84a520..4afed910d6cfc475440eab57038bc630018bd518 100644 (file)
@@ -23,7 +23,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
       "account" => %{
         "pleroma" => %{
           "is_admin" => false,
-          "confirmation_pending" => false,
+          "is_confirmed" => true,
           "hide_followers_count" => false,
           "is_moderator" => false,
           "hide_favorites" => true,
index 3f58709076e0b1852911b4e27c35afd99f47ac79..61ebd8089c7a6256cf4df7ffb7823108b3e888cf 100644 (file)
@@ -256,7 +256,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
         "note" => "Tester Number 6",
         "pleroma" => %{
           "background_image" => nil,
-          "confirmation_pending" => false,
+          "is_confirmed" => true,
           "hide_favorites" => true,
           "hide_followers" => false,
           "hide_followers_count" => false,
index 2768f02914090b546a90067bd3ebd562e8848f00..da1221d477cdcaab9dd2315389afaba161e82b6d 100644 (file)
@@ -266,7 +266,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       pleroma: %{
         ap_id: user.ap_id,
         also_known_as: user.also_known_as,
-        confirmation_pending: user.confirmation_pending,
+        is_confirmed: user.is_confirmed,
         tags: user.tags,
         hide_followers_count: user.hide_followers_count,
         hide_follows_count: user.hide_follows_count,
index 467c19e5e9e5c8f348c118e45ba641bf9556b861..077bfa70d5661db507bcfd106abd5e9460540a8f 100644 (file)
@@ -30,7 +30,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
 
   def confirm_email(conn, %{"user_id" => uid, "token" => token}) do
     with %User{} = user <- User.get_cached_by_id(uid),
-         true <- user.local and user.confirmation_pending and user.confirmation_token == token,
+         true <- user.local and !user.is_confirmed and user.confirmation_token == token,
          {:ok, _} <- User.confirm(user) do
       redirect(conn, to: "/")
     end
diff --git a/priv/repo/migrations/20201013184200_refactor_confirmation_pending_user_field.exs b/priv/repo/migrations/20201013184200_refactor_confirmation_pending_user_field.exs
new file mode 100644 (file)
index 0000000..d0dc428
--- /dev/null
@@ -0,0 +1,20 @@
+# Pleroma: A lightweight social networking server
+# Copyright Â© 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.RefactorConfirmationPendingUserField do
+  use Ecto.Migration
+
+  def up do
+    # Flip the values before we change the meaning of the column
+    execute("UPDATE users SET confirmation_pending = NOT confirmation_pending;")
+    execute("ALTER TABLE users RENAME COLUMN confirmation_pending TO is_confirmed;")
+    execute("ALTER TABLE users ALTER COLUMN is_confirmed SET DEFAULT true;")
+  end
+
+  def down do
+    execute("UPDATE users SET is_confirmed = NOT is_confirmed;")
+    execute("ALTER TABLE users RENAME COLUMN is_confirmed TO confirmation_pending;")
+    execute("ALTER TABLE users ALTER COLUMN confirmation_pending SET DEFAULT false;")
+  end
+end
index 78cdf178b08a0cdbefbf55afc8867c464f39a0f4..ef26142c4a830ef67c5b3b1a433b5cfe63213769 100644 (file)
@@ -61,7 +61,7 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
     test "Sends confirmation emails" do
       local_user1 =
         insert(:user, %{
-          confirmation_pending: true,
+          is_confirmed: false,
           confirmation_token: "mytoken",
           deactivated: false,
           email: "local1@pleroma.com",
@@ -70,7 +70,7 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
 
       local_user2 =
         insert(:user, %{
-          confirmation_pending: true,
+          is_confirmed: false,
           confirmation_token: "mytoken",
           deactivated: false,
           email: "local2@pleroma.com",
@@ -88,7 +88,7 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
     test "Does not send confirmation email to inappropriate users" do
       # confirmed user
       insert(:user, %{
-        confirmation_pending: false,
+        is_confirmed: true,
         confirmation_token: "mytoken",
         deactivated: false,
         email: "confirmed@pleroma.com",
index 7c68b8a37e240be782fd9e2653c83aeb7f897c93..a620e5960253dc47a291e4a8662d7bb4affd0401 100644 (file)
@@ -238,7 +238,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       assert message =~ ~r/Admin status .* true/
 
       assert_received {:mix_shell, :info, [message]}
-      assert message =~ ~r/Confirmation pending .* false/
+      assert message =~ ~r/Confirmation status.* true/
 
       assert_received {:mix_shell, :info, [message]}
       assert message =~ ~r/Locked status .* true/
@@ -250,7 +250,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       assert user.is_moderator
       assert user.is_locked
       assert user.is_admin
-      refute user.confirmation_pending
+      assert user.is_confirmed
     end
 
     test "All statuses unset" do
@@ -259,7 +259,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
           is_locked: true,
           is_moderator: true,
           is_admin: true,
-          confirmation_pending: true
+          is_confirmed: false
         )
 
       Mix.Tasks.Pleroma.User.run([
@@ -275,7 +275,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       assert message =~ ~r/Admin status .* false/
 
       assert_received {:mix_shell, :info, [message]}
-      assert message =~ ~r/Confirmation pending .* true/
+      assert message =~ ~r/Confirmation status.* false/
 
       assert_received {:mix_shell, :info, [message]}
       assert message =~ ~r/Locked status .* false/
@@ -287,7 +287,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       refute user.is_moderator
       refute user.is_locked
       refute user.is_admin
-      assert user.confirmation_pending
+      refute user.is_confirmed
     end
 
     test "no user to set status" do
@@ -464,27 +464,27 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
   describe "running confirm" do
     test "user is confirmed" do
-      %{id: id, nickname: nickname} = insert(:user, confirmation_pending: false)
+      %{id: id, nickname: nickname} = insert(:user, is_confirmed: true)
 
       assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
       assert_received {:mix_shell, :info, [message]}
       assert message == "#{nickname} doesn't need confirmation."
 
       user = Repo.get(User, id)
-      refute user.confirmation_pending
+      assert user.is_confirmed
       refute user.confirmation_token
     end
 
     test "user is not confirmed" do
       %{id: id, nickname: nickname} =
-        insert(:user, confirmation_pending: true, confirmation_token: "some token")
+        insert(:user, is_confirmed: false, confirmation_token: "some token")
 
       assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
       assert_received {:mix_shell, :info, [message]}
       assert message == "#{nickname} doesn't need confirmation."
 
       user = Repo.get(User, id)
-      refute user.confirmation_pending
+      assert user.is_confirmed
       refute user.confirmation_token
     end
 
@@ -579,29 +579,29 @@ defmodule Mix.Tasks.Pleroma.UserTest do
 
   describe "bulk confirm and unconfirm" do
     test "confirm all" do
-      user1 = insert(:user, confirmation_pending: true)
-      user2 = insert(:user, confirmation_pending: true)
+      user1 = insert(:user, is_confirmed: false)
+      user2 = insert(:user, is_confirmed: false)
 
-      assert user1.confirmation_pending
-      assert user2.confirmation_pending
+      refute user1.is_confirmed
+      refute user2.is_confirmed
 
       Mix.Tasks.Pleroma.User.run(["confirm_all"])
 
       user1 = User.get_cached_by_nickname(user1.nickname)
       user2 = User.get_cached_by_nickname(user2.nickname)
 
-      refute user1.confirmation_pending
-      refute user2.confirmation_pending
+      assert user1.is_confirmed
+      assert user2.is_confirmed
     end
 
     test "unconfirm all" do
-      user1 = insert(:user, confirmation_pending: false)
-      user2 = insert(:user, confirmation_pending: false)
-      admin = insert(:user, is_admin: true, confirmation_pending: false)
-      mod = insert(:user, is_moderator: true, confirmation_pending: false)
+      user1 = insert(:user, is_confirmed: true)
+      user2 = insert(:user, is_confirmed: true)
+      admin = insert(:user, is_admin: true, is_confirmed: true)
+      mod = insert(:user, is_moderator: true, is_confirmed: true)
 
-      refute user1.confirmation_pending
-      refute user2.confirmation_pending
+      assert user1.is_confirmed
+      assert user2.is_confirmed
 
       Mix.Tasks.Pleroma.User.run(["unconfirm_all"])
 
@@ -610,10 +610,10 @@ defmodule Mix.Tasks.Pleroma.UserTest do
       admin = User.get_cached_by_nickname(admin.nickname)
       mod = User.get_cached_by_nickname(mod.nickname)
 
-      assert user1.confirmation_pending
-      assert user2.confirmation_pending
-      refute admin.confirmation_pending
-      refute mod.confirmation_pending
+      refute user1.is_confirmed
+      refute user2.is_confirmed
+      assert admin.is_confirmed
+      assert mod.is_confirmed
     end
   end
 end
index bdf17e96a094a8b1a6c57df48c9c7b03d6af06f7..7e50d53d35565efd03c46e5d7bf3f47a70b61dda 100644 (file)
@@ -640,7 +640,7 @@ defmodule Pleroma.UserTest do
 
       {:ok, user} = Repo.insert(changeset)
 
-      refute user.confirmation_pending
+      assert user.is_confirmed
     end
   end
 
@@ -661,7 +661,7 @@ defmodule Pleroma.UserTest do
 
       {:ok, user} = Repo.insert(changeset)
 
-      assert user.confirmation_pending
+      refute user.is_confirmed
       assert user.confirmation_token
     end
 
@@ -671,7 +671,7 @@ defmodule Pleroma.UserTest do
 
       {:ok, user} = Repo.insert(changeset)
 
-      refute user.confirmation_pending
+      assert user.is_confirmed
       refute user.confirmation_token
     end
   end
@@ -1443,17 +1443,17 @@ defmodule Pleroma.UserTest do
 
   describe "confirm" do
     test "confirms a user" do
-      user = insert(:user, confirmation_pending: true)
-      assert true == user.confirmation_pending
+      user = insert(:user, is_confirmed: false)
+      refute user.is_confirmed
       {:ok, user} = User.confirm(user)
-      assert false == user.confirmation_pending
+      assert user.is_confirmed
     end
 
     test "confirms a list of users" do
       unconfirmed_users = [
-        insert(:user, confirmation_pending: true),
-        insert(:user, confirmation_pending: true),
-        insert(:user, confirmation_pending: true)
+        insert(:user, is_confirmed: false),
+        insert(:user, is_confirmed: false),
+        insert(:user, is_confirmed: false)
       ]
 
       {:ok, users} = User.confirm(unconfirmed_users)
@@ -1461,13 +1461,13 @@ defmodule Pleroma.UserTest do
       assert Enum.count(users) == 3
 
       Enum.each(users, fn user ->
-        assert false == user.confirmation_pending
+        assert user.is_confirmed
       end)
     end
 
     test "sends approval emails when `approval_pending: true`" do
       admin = insert(:user, is_admin: true)
-      user = insert(:user, confirmation_pending: true, approval_pending: true)
+      user = insert(:user, is_confirmed: false, approval_pending: true)
       User.confirm(user)
 
       ObanHelpers.perform_all()
@@ -1494,7 +1494,7 @@ defmodule Pleroma.UserTest do
     end
 
     test "confirming a confirmed user does not trigger post-register actions" do
-      user = insert(:user, confirmation_pending: false, approval_pending: true)
+      user = insert(:user, is_confirmed: true, approval_pending: true)
       User.confirm(user)
 
       ObanHelpers.perform_all()
@@ -1565,7 +1565,7 @@ defmodule Pleroma.UserTest do
 
   describe "delete/1 when confirmation is pending" do
     setup do
-      user = insert(:user, confirmation_pending: true)
+      user = insert(:user, is_confirmed: false)
       {:ok, user: user}
     end
 
@@ -1616,7 +1616,7 @@ defmodule Pleroma.UserTest do
         follower_count: 9,
         following_count: 9001,
         is_locked: true,
-        confirmation_pending: true,
+        is_confirmed: false,
         password_reset_pending: true,
         approval_pending: true,
         registration_reason: "ahhhhh",
@@ -1658,7 +1658,7 @@ defmodule Pleroma.UserTest do
              follower_count: 0,
              following_count: 0,
              is_locked: false,
-             confirmation_pending: false,
+             is_confirmed: true,
              password_reset_pending: false,
              approval_pending: false,
              registration_reason: nil,
@@ -1729,13 +1729,13 @@ defmodule Pleroma.UserTest do
 
     test "return confirmation_pending for unconfirm user" do
       Pleroma.Config.put([:instance, :account_activation_required], true)
-      user = insert(:user, confirmation_pending: true)
+      user = insert(:user, is_confirmed: false)
       assert User.account_status(user) == :confirmation_pending
     end
 
     test "return active for confirmed user" do
       Pleroma.Config.put([:instance, :account_activation_required], true)
-      user = insert(:user, confirmation_pending: false)
+      user = insert(:user, is_confirmed: true)
       assert User.account_status(user) == :active
     end
 
@@ -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, is_confirmed: true, deactivated: true)
       assert User.account_status(user) == :deactivated
     end
 
@@ -1758,7 +1758,7 @@ defmodule Pleroma.UserTest do
       user = insert(:user, local: true, approval_pending: true)
       assert User.account_status(user) == :approval_pending
 
-      user = insert(:user, local: true, confirmation_pending: true, approval_pending: true)
+      user = insert(:user, local: true, is_confirmed: false, approval_pending: true)
       assert User.account_status(user) == :approval_pending
     end
   end
@@ -1815,7 +1815,7 @@ defmodule Pleroma.UserTest do
     test "returns false when the account is unconfirmed and confirmation is required" do
       Pleroma.Config.put([:instance, :account_activation_required], true)
 
-      user = insert(:user, local: true, confirmation_pending: true)
+      user = insert(:user, local: true, is_confirmed: false)
       other_user = insert(:user, local: true)
 
       refute User.visible_for(user, other_user) == :visible
@@ -1824,14 +1824,14 @@ defmodule Pleroma.UserTest do
     test "returns true when the account is unconfirmed and confirmation is required but the account is remote" do
       Pleroma.Config.put([:instance, :account_activation_required], true)
 
-      user = insert(:user, local: false, confirmation_pending: true)
+      user = insert(:user, local: false, is_confirmed: false)
       other_user = insert(:user, local: true)
 
       assert User.visible_for(user, other_user) == :visible
     end
 
     test "returns true when the account is unconfirmed and confirmation is not required" do
-      user = insert(:user, local: true, confirmation_pending: true)
+      user = insert(:user, local: true, is_confirmed: false)
       other_user = insert(:user, local: true)
 
       assert User.visible_for(user, other_user) == :visible
@@ -1840,7 +1840,7 @@ defmodule Pleroma.UserTest do
     test "returns true when the account is unconfirmed and being viewed by a privileged account (confirmation required)" do
       Pleroma.Config.put([:instance, :account_activation_required], true)
 
-      user = insert(:user, local: true, confirmation_pending: true)
+      user = insert(:user, local: true, is_confirmed: false)
       other_user = insert(:user, local: true, is_admin: true)
 
       assert User.visible_for(user, other_user) == :visible
index 2d94f07c9f82945a6a569bdcc2af144b560225a9..e3f45ecdb62d2f21575d9a4dda3c49d34cad25b5 100644 (file)
@@ -159,7 +159,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
 
   describe "delete users with confirmation pending" do
     setup do
-      user = insert(:user, confirmation_pending: true)
+      user = insert(:user, is_confirmed: false)
       {:ok, delete_user_data, _meta} = Builder.delete(user, user.ap_id)
       {:ok, delete_user, _meta} = ActivityPub.persist(delete_user_data, local: true)
       {:ok, delete: delete_user, user: user}
index c54402e52c5ee89a8541d307e063c55f6ebe8979..65f2a124f8e0b436809f93741aa6ffe75d2b7db2 100644 (file)
@@ -891,10 +891,10 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
 
   describe "PATCH /confirm_email" do
     test "it confirms emails of two users", %{conn: conn, admin: admin} do
-      [first_user, second_user] = insert_pair(:user, confirmation_pending: true)
+      [first_user, second_user] = insert_pair(:user, is_confirmed: false)
 
-      assert first_user.confirmation_pending == true
-      assert second_user.confirmation_pending == true
+      refute first_user.is_confirmed
+      refute second_user.is_confirmed
 
       ret_conn =
         patch(conn, "/api/pleroma/admin/users/confirm_email", %{
@@ -906,8 +906,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
 
       assert ret_conn.status == 200
 
-      assert first_user.confirmation_pending == true
-      assert second_user.confirmation_pending == true
+      assert User.get_by_id(first_user.id).is_confirmed
+      assert User.get_by_id(second_user.id).is_confirmed
 
       log_entry = Repo.one(ModerationLog)
 
@@ -920,7 +920,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
 
   describe "PATCH /resend_confirmation_email" do
     test "it resend emails for two users", %{conn: conn, admin: admin} do
-      [first_user, second_user] = insert_pair(:user, confirmation_pending: true)
+      [first_user, second_user] = insert_pair(:user, is_confirmed: false)
 
       ret_conn =
         patch(conn, "/api/pleroma/admin/users/resend_confirmation_email", %{
index 976990d5c047950b45d619c98ae362cb94fad705..24e288c5fd281e80be89e27e864518ea7688169f 100644 (file)
@@ -48,7 +48,7 @@ defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
       assert account["id"] == actor.id
       assert account["nickname"] == actor.nickname
       assert account["deactivated"] == actor.deactivated
-      assert account["confirmation_pending"] == actor.confirmation_pending
+      assert account["is_confirmed"] == actor.is_confirmed
     end
   end
 
index 40d39aae77375d58e59c071843f18dce1123ccef..569343ed5847f067d872eb61efb212ca7159a922 100644 (file)
@@ -635,11 +635,11 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
     end
 
     test "only unconfirmed users", %{conn: conn} do
-      sad_user = insert(:user, nickname: "sadboy", confirmation_pending: true)
-      old_user = insert(:user, nickname: "oldboy", confirmation_pending: true)
+      sad_user = insert(:user, nickname: "sadboy", is_confirmed: false)
+      old_user = insert(:user, nickname: "oldboy", is_confirmed: false)
 
       insert(:user, nickname: "happyboy", approval_pending: false)
-      insert(:user, confirmation_pending: false)
+      insert(:user, is_confirmed: true)
 
       result =
         conn
@@ -649,7 +649,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
       users =
         Enum.map([old_user, sad_user], fn user ->
           user_response(user, %{
-            "confirmation_pending" => true,
+            "is_confirmed" => false,
             "approval_pending" => false
           })
         end)
@@ -960,7 +960,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
       "tags" => [],
       "avatar" => User.avatar_url(user) |> MediaProxy.url(),
       "display_name" => HTML.strip_tags(user.name || user.nickname),
-      "confirmation_pending" => false,
+      "is_confirmed" => true,
       "approval_pending" => false,
       "url" => user.ap_id,
       "registration_reason" => nil,
index 307578ae00a1a189447a3c9dd73f5ef50535c7ac..913dc374a6a4034126d9415ed4c44b726d40464f 100644 (file)
@@ -193,7 +193,7 @@ defmodule Pleroma.Web.AdminAPI.SearchTest do
     end
 
     test "it returns unconfirmed user" do
-      unconfirmed = insert(:user, confirmation_pending: true)
+      unconfirmed = insert(:user, is_confirmed: false)
       insert(:user)
       insert(:user)
 
index 7b3cc7344d72be2332d498a07bafef63a36ee422..2d929e532b436559693132f4bd1a616e1346f40e 100644 (file)
@@ -1027,7 +1027,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
       user = Repo.preload(token_from_db, :user).user
 
       assert user
-      refute user.confirmation_pending
+      assert user.is_confirmed
       refute user.approval_pending
     end
 
@@ -1088,7 +1088,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
       refute response["token_type"]
 
       user = Repo.get_by(User, email: "lain@example.org")
-      assert user.confirmation_pending
+      refute user.is_confirmed
     end
 
     test "registers but does not log in with :account_approval_required", %{conn: conn} do
index 32fe081968f317e9d81f2d6b66116e3a8ed60dde..f4e6c161ec21ee389efc5bdf759d1aabb4837c5b 100644 (file)
@@ -79,7 +79,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
         also_known_as: ["https://shitposter.zone/users/shp"],
         background_image: "https://example.com/images/asuka_hospital.png",
         favicon: nil,
-        confirmation_pending: false,
+        is_confirmed: true,
         tags: [],
         is_admin: false,
         is_moderator: false,
@@ -178,7 +178,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
         also_known_as: [],
         background_image: nil,
         favicon: nil,
-        confirmation_pending: false,
+        is_confirmed: true,
         tags: [],
         is_admin: false,
         is_moderator: false,
index bf47afed820cf05a39562b9298784fe302b223a7..254d4e9a4fdd0756959789febe1329a31193a72b 100644 (file)
@@ -1013,7 +1013,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
       user =
         insert(:user,
           password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt(password),
-          confirmation_pending: true
+          is_confirmed: false
         )
 
       app = insert(:oauth_app, scopes: ["read", "write"])
index baf2d01ab5bfd70fa03995ddeeaa64eca6d11a77..668bb46fb3f6d05e836d24ad395283a2d7b7faab 100644 (file)
@@ -20,7 +20,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
         |> User.confirmation_changeset(need_confirmation: true)
         |> User.update_and_set_cache()
 
-      assert user.confirmation_pending
+      refute user.is_confirmed
 
       [user: user]
     end
index bee413fbfb717550aac2c3598ebc6f956cf149a5..6d0f4fb7d8c81c53cdba9dd395bb310c08786646 100644 (file)
@@ -22,7 +22,7 @@ defmodule Pleroma.Web.Plugs.UserEnabledPlugTest do
        %{conn: conn} do
     Pleroma.Config.put([:instance, :account_activation_required], true)
 
-    user = insert(:user, confirmation_pending: true)
+    user = insert(:user, is_confirmed: false)
 
     conn =
       conn
index 23884e2234e4fefcbbafb0cc9726df5435aff177..8f29a4f63862b884c4e68c9af243facfb579ba57 100644 (file)
@@ -67,7 +67,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
         |> User.confirmation_changeset(need_confirmation: true)
         |> Repo.update()
 
-      assert user.confirmation_pending
+      refute user.is_confirmed
 
       [user: user]
     end
@@ -83,7 +83,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
 
       user = User.get_cached_by_id(user.id)
 
-      refute user.confirmation_pending
+      assert user.is_confirmed
       refute user.confirmation_token
     end
 
index 3be4812d31a3772d6a2510715523953daba42104..0ed1389f5b5aa3a3973b892ba90845c198784841 100644 (file)
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     {:ok, user} = TwitterAPI.register_user(data)
     ObanHelpers.perform_all()
 
-    assert user.confirmation_pending
+    refute user.is_confirmed
 
     email = Pleroma.Emails.UserEmail.account_confirmation_email(user)