Add `approval_pending` field to User
authorAlex Gleason <alex@alexgleason.me>
Mon, 13 Jul 2020 00:11:30 +0000 (19:11 -0500)
committerAlex Gleason <alex@alexgleason.me>
Mon, 13 Jul 2020 01:27:14 +0000 (20:27 -0500)
lib/pleroma/user.ex
priv/repo/migrations/20200712234852_add_approval_pending_to_users.exs [new file with mode: 0644]
test/user_test.exs

index b9989f9018194122f2499918afedf2f88d73ad4f..25c63fc44fa137f9c9de92e5fa950347c9d4579b 100644 (file)
@@ -106,6 +106,7 @@ defmodule Pleroma.User do
     field(:locked, :boolean, default: false)
     field(:confirmation_pending, :boolean, default: false)
     field(:password_reset_pending, :boolean, default: false)
+    field(:approval_pending, :boolean, default: false)
     field(:confirmation_token, :string, default: nil)
     field(:default_scope, :string, default: "public")
     field(:domain_blocks, {:array, :string}, default: [])
@@ -262,6 +263,7 @@ defmodule Pleroma.User do
   @spec account_status(User.t()) :: account_status()
   def account_status(%User{deactivated: true}), do: :deactivated
   def account_status(%User{password_reset_pending: true}), do: :password_reset_pending
+  def account_status(%User{approval_pending: true}), do: :approval_pending
 
   def account_status(%User{confirmation_pending: true}) do
     if Config.get([:instance, :account_activation_required]) do
diff --git a/priv/repo/migrations/20200712234852_add_approval_pending_to_users.exs b/priv/repo/migrations/20200712234852_add_approval_pending_to_users.exs
new file mode 100644 (file)
index 0000000..f7eb817
--- /dev/null
@@ -0,0 +1,9 @@
+defmodule Pleroma.Repo.Migrations.AddApprovalPendingToUsers do
+  use Ecto.Migration
+
+  def change do
+    alter table(:users) do
+      add(:approval_pending, :boolean)
+    end
+  end
+end
index 9788e09d9b24f5d74bace103993e53c6c6d5797a..040f532fe8745ab580bc50cc2f6469b2941d424a 100644 (file)
@@ -1342,6 +1342,11 @@ defmodule Pleroma.UserTest do
       user = insert(:user, local: true, confirmation_pending: false, deactivated: true)
       assert User.account_status(user) == :deactivated
     end
+
+    test "returns :approval_pending for unapproved user" do
+      user = insert(:user, local: true, confirmation_pending: false, approval_pending: true)
+      assert User.account_status(user) == :approval_pending
+    end
   end
 
   describe "superuser?/1" do