From e759579f9749ac4198054ddab2d3bb77cc5f04ae Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 19 Jan 2021 16:39:55 -0600 Subject: [PATCH 1/5] Active users must be confirmed --- lib/pleroma/user/query.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/user/query.ex b/lib/pleroma/user/query.ex index 74ef1158a..4076925aa 100644 --- a/lib/pleroma/user/query.ex +++ b/lib/pleroma/user/query.ex @@ -139,6 +139,7 @@ defmodule Pleroma.User.Query do defp compose_query({:active, _}, query) do User.restrict_deactivated(query) |> where([u], u.is_approved == true) + |> where([u], u.is_confirmed == true) end defp compose_query({:legacy_active, _}, query) do From 704eef3c2d29c92316f4860c50982512824dd514 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 20 Jan 2021 11:14:15 -0600 Subject: [PATCH 2/5] Special handling for unconfirmed users based on instance config no longer needed. --- lib/pleroma/user.ex | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index d81abbd2b..2aeacf816 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -289,15 +289,7 @@ defmodule Pleroma.User do def account_status(%User{deactivated: true}), do: :deactivated def account_status(%User{password_reset_pending: true}), do: :password_reset_pending def account_status(%User{local: true, is_approved: false}), do: :approval_pending - - def account_status(%User{local: true, is_confirmed: false}) do - if Config.get([:instance, :account_activation_required]) do - :confirmation_pending - else - :active - end - end - + def account_status(%User{local: true, is_confirmed: false}), do: :confirmation_pending def account_status(%User{}), do: :active @spec visible_for(User.t(), User.t() | nil) :: From 3cb4d40ebf9fbf58fac6f9657f799571dc7f318e Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 20 Jan 2021 11:17:13 -0600 Subject: [PATCH 3/5] This scenario no longer exists. Users are auto-confirmed if confirmation not required at time of registration. --- test/pleroma/user_test.exs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index 617d9b755..a85e89a50 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -1830,13 +1830,6 @@ defmodule Pleroma.UserTest do 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, 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 being viewed by a privileged account (confirmation required)" do Pleroma.Config.put([:instance, :account_activation_required], true) From 5d344e5c7965651232c4a20a3a3cc187eb79f18d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 20 Jan 2021 11:26:14 -0600 Subject: [PATCH 4/5] Only need to test if unconfirmed users are successfully deleted It's no longer possible to have an active user account with User.is_confirmed == false --- test/pleroma/user_test.exs | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index a85e89a50..7e1e75404 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -1563,31 +1563,15 @@ defmodule Pleroma.UserTest do end end - describe "delete/1 when confirmation is pending" do - setup do - user = insert(:user, is_confirmed: false) - {:ok, user: user} - end + test "delete/1 when confirmation is pending deletes the user" do + clear_config([:instance, :account_activation_required], true) + user = insert(:user, is_confirmed: false) - test "deletes user from database when activation required", %{user: user} do - clear_config([:instance, :account_activation_required], true) + {:ok, job} = User.delete(user) + {:ok, _} = ObanHelpers.perform(job) - {:ok, job} = User.delete(user) - {:ok, _} = ObanHelpers.perform(job) - - refute User.get_cached_by_id(user.id) - refute User.get_by_id(user.id) - end - - test "deactivates user when activation is not required", %{user: user} do - clear_config([:instance, :account_activation_required], false) - - {: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) - end + refute User.get_cached_by_id(user.id) + refute User.get_by_id(user.id) end test "delete/1 when approval is pending deletes the user" do From dfc4cb6ebd61754ee5865c33092c5e1b782c12cd Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 20 Jan 2021 11:30:29 -0600 Subject: [PATCH 5/5] Special handling for unconfirmed users based on instance config no longer needed. --- test/pleroma/web/activity_pub/side_effects_test.exs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/pleroma/web/activity_pub/side_effects_test.exs b/test/pleroma/web/activity_pub/side_effects_test.exs index e3f45ecdb..13167f50a 100644 --- a/test/pleroma/web/activity_pub/side_effects_test.exs +++ b/test/pleroma/web/activity_pub/side_effects_test.exs @@ -165,14 +165,6 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do {:ok, delete: delete_user, user: user} end - test "when activation is not required", %{delete: delete, user: user} do - clear_config([:instance, :account_activation_required], false) - {:ok, _, _} = SideEffects.handle(delete) - ObanHelpers.perform_all() - - assert User.get_cached_by_id(user.id).deactivated - end - test "when activation is required", %{delete: delete, user: user} do clear_config([:instance, :account_activation_required], true) {:ok, _, _} = SideEffects.handle(delete)