forked from mirrors/akkoma
Fully delete users with status :approval_pending
This commit is contained in:
parent
5e74556703
commit
5756843736
|
@ -1525,12 +1525,13 @@ defp delete_or_deactivate(%User{local: false} = user), do: delete_and_invalidate
|
||||||
defp delete_or_deactivate(%User{local: true} = user) do
|
defp delete_or_deactivate(%User{local: true} = user) do
|
||||||
status = account_status(user)
|
status = account_status(user)
|
||||||
|
|
||||||
if status == :confirmation_pending do
|
case status do
|
||||||
delete_and_invalidate_cache(user)
|
:confirmation_pending -> delete_and_invalidate_cache(user)
|
||||||
else
|
:approval_pending -> delete_and_invalidate_cache(user)
|
||||||
user
|
_ ->
|
||||||
|> change(%{deactivated: true, email: nil})
|
user
|
||||||
|> update_and_set_cache()
|
|> change(%{deactivated: true, email: nil})
|
||||||
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1314,6 +1314,17 @@ test "deactivates user when activation is not required", %{user: user} do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "delete/1 when approval is pending deletes the user" do
|
||||||
|
user = insert(:user, approval_pending: true)
|
||||||
|
{:ok, user: user}
|
||||||
|
|
||||||
|
{: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 "get_public_key_for_ap_id fetches a user that's not in the db" do
|
test "get_public_key_for_ap_id fetches a user that's not in the db" do
|
||||||
assert {:ok, _key} = User.get_public_key_for_ap_id("http://mastodon.example.org/users/admin")
|
assert {:ok, _key} = User.get_public_key_for_ap_id("http://mastodon.example.org/users/admin")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue