Skip to content
Snippets Groups Projects
Commit 60eee739 authored by Stan Hu's avatar Stan Hu
Browse files

Hard delete users' associated records deleted from AbuseReports

In the case of spammers, we really want a hard delete to avoid retaining spam.

Closes #31021
parent 309bab43
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -16,7 +16,7 @@ class AbuseReport < ActiveRecord::Base
 
def remove_user(deleted_by:)
user.block
DeleteUserWorker.perform_async(deleted_by.id, user.id, delete_solo_owned_groups: true)
DeleteUserWorker.perform_async(deleted_by.id, user.id, delete_solo_owned_groups: true, hard_delete: true)
end
 
def notify
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ module Users
::Projects::DestroyService.new(project, current_user, skip_repo: true).execute
end
 
MigrateToGhostUserService.new(user).execute
MigrateToGhostUserService.new(user).execute unless options[:hard_delete]
 
# Destroy the namespace after destroying the user since certain methods may depend on the namespace existing
namespace = user.namespace
Loading
Loading
Loading
Loading
@@ -29,7 +29,8 @@ RSpec.describe AbuseReport, type: :model do
 
it 'lets a worker delete the user' do
expect(DeleteUserWorker).to receive(:perform_async).with(user.id, subject.user.id,
delete_solo_owned_groups: true)
delete_solo_owned_groups: true,
hard_delete: true)
 
subject.remove_user(deleted_by: user)
end
Loading
Loading
Loading
Loading
@@ -152,6 +152,12 @@ describe Users::DestroyService, services: true do
 
service.execute(user)
end
it 'does not run `MigrateToGhostUser` if hard_delete option is given' do
expect_any_instance_of(Users::MigrateToGhostUserService).not_to receive(:execute)
service.execute(user, hard_delete: true)
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment