Add ability to disable login and mark accounts as memorial (#5615)

Fix #5597
This commit is contained in:
Eugen Rochko 2017-11-07 19:06:44 +01:00 committed by GitHub
parent cbbeec05be
commit 1032f3994f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 168 additions and 39 deletions

View file

@ -1,22 +1,27 @@
# frozen_string_literal: true
class SuspendAccountService < BaseService
def call(account, remove_user = false)
def call(account, options = {})
@account = account
@options = options
purge_user if remove_user
purge_profile
purge_content
unsubscribe_push_subscribers
purge_user!
purge_profile!
purge_content!
unsubscribe_push_subscribers!
end
private
def purge_user
@account.user.destroy
def purge_user!
if @options[:remove_user]
@account.user&.destroy
else
@account.user&.disable!
end
end
def purge_content
def purge_content!
@account.statuses.reorder(nil).find_in_batches do |statuses|
BatchedRemoveStatusService.new.call(statuses)
end
@ -33,7 +38,7 @@ class SuspendAccountService < BaseService
end
end
def purge_profile
def purge_profile!
@account.suspended = true
@account.display_name = ''
@account.note = ''
@ -42,7 +47,7 @@ class SuspendAccountService < BaseService
@account.save!
end
def unsubscribe_push_subscribers
def unsubscribe_push_subscribers!
destroy_all(@account.subscriptions)
end