Verified Commit c6d41337 authored by Alex Gleason's avatar Alex Gleason
Browse files

Deletions: purge the user immediately

parent be2da95c
...@@ -1724,31 +1724,27 @@ def delete(users) when is_list(users) do ...@@ -1724,31 +1724,27 @@ def delete(users) when is_list(users) do
end end
def delete(%User{} = user) do def delete(%User{} = user) do
purge(user)
BackgroundWorker.enqueue("delete_user", %{"user_id" => user.id}) BackgroundWorker.enqueue("delete_user", %{"user_id" => user.id})
end end
defp delete_and_invalidate_cache(%User{} = user) do defp delete_from_db(%User{} = user) do
invalidate_cache(user) invalidate_cache(user)
Repo.delete(user) Repo.delete(user)
end end
defp delete_or_purge(%User{local: false} = user), do: purge(user) defp maybe_delete_from_db(%User{local: true} = user) do
defp delete_or_purge(%User{local: true} = user) do
status = account_status(user) status = account_status(user)
case status do if status in [:confirmation_pending, :approval_pending] do
:confirmation_pending -> delete_from_db(user)
delete_and_invalidate_cache(user) else
{:ok, user}
:approval_pending ->
delete_and_invalidate_cache(user)
_ ->
purge(user)
end end
end end
defp maybe_delete_from_db(user), do: {:ok, user}
def perform(:force_password_reset, user), do: force_password_reset(user) def perform(:force_password_reset, user), do: force_password_reset(user)
@spec perform(atom(), User.t()) :: {:ok, User.t()} @spec perform(atom(), User.t()) :: {:ok, User.t()}
...@@ -1770,10 +1766,9 @@ def perform(:delete, %User{} = user) do ...@@ -1770,10 +1766,9 @@ def perform(:delete, %User{} = user) do
delete_user_activities(user) delete_user_activities(user)
delete_notifications_from_user_activities(user) delete_notifications_from_user_activities(user)
delete_outgoing_pending_follow_requests(user) delete_outgoing_pending_follow_requests(user)
delete_or_purge(user) maybe_delete_from_db(user)
end end
def perform(:set_activation_async, user, status), do: set_activation(user, status) def perform(:set_activation_async, user, status), do: set_activation(user, status)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment