Fix sending spurious Rejects when processing remote account deletion (#15104)

* Fix sending spurious Rejects when processing remote account deletion

* Make skip_side_effects imply skip_activitypub
master
ThibG 4 years ago committed by GitHub
parent df1653174b
commit 2f6831f318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/lib/activitypub/activity/delete.rb
  2. 5
      app/services/delete_account_service.rb
  3. 2
      app/services/resolve_account_service.rb
  4. 3
      app/workers/account_deletion_worker.rb

@ -13,7 +13,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
def delete_person def delete_person
lock_or_return("delete_in_progress:#{@account.id}") do lock_or_return("delete_in_progress:#{@account.id}") do
DeleteAccountService.new.call(@account, reserve_username: false) DeleteAccountService.new.call(@account, reserve_username: false, skip_activitypub: true)
end end
end end

@ -41,6 +41,7 @@ class DeleteAccountService < BaseService
# @option [Boolean] :reserve_email Keep user record. Only applicable for local accounts # @option [Boolean] :reserve_email Keep user record. Only applicable for local accounts
# @option [Boolean] :reserve_username Keep account record # @option [Boolean] :reserve_username Keep account record
# @option [Boolean] :skip_side_effects Side effects are ActivityPub and streaming API payloads # @option [Boolean] :skip_side_effects Side effects are ActivityPub and streaming API payloads
# @option [Boolean] :skip_activitypub Skip sending ActivityPub payloads. Implied by :skip_side_effects
# @option [Time] :suspended_at Only applicable when :reserve_username is true # @option [Time] :suspended_at Only applicable when :reserve_username is true
def call(account, **options) def call(account, **options)
@account = account @account = account
@ -52,6 +53,8 @@ class DeleteAccountService < BaseService
@options[:skip_side_effects] = true @options[:skip_side_effects] = true
end end
@options[:skip_activitypub] = true if @options[:skip_side_effects]
reject_follows! reject_follows!
purge_user! purge_user!
purge_profile! purge_profile!
@ -62,7 +65,7 @@ class DeleteAccountService < BaseService
private private
def reject_follows! def reject_follows!
return if @account.local? || !@account.activitypub? return if @account.local? || !@account.activitypub? || @options[:skip_activitypub]
# When deleting a remote account, the account obviously doesn't # When deleting a remote account, the account obviously doesn't
# actually become deleted on its origin server, i.e. unlike a # actually become deleted on its origin server, i.e. unlike a

@ -145,7 +145,7 @@ class ResolveAccountService < BaseService
end end
def queue_deletion! def queue_deletion!
AccountDeletionWorker.perform_async(@account.id, reserve_username: false) AccountDeletionWorker.perform_async(@account.id, reserve_username: false, skip_activitypub: true)
end end
def lock_options def lock_options

@ -7,7 +7,8 @@ class AccountDeletionWorker
def perform(account_id, options = {}) def perform(account_id, options = {})
reserve_username = options.with_indifferent_access.fetch(:reserve_username, true) reserve_username = options.with_indifferent_access.fetch(:reserve_username, true)
DeleteAccountService.new.call(Account.find(account_id), reserve_username: reserve_username, reserve_email: false) skip_activitypub = options.with_indifferent_access.fetch(:skip_activitypub, false)
DeleteAccountService.new.call(Account.find(account_id), reserve_username: reserve_username, skip_activitypub: skip_activitypub, reserve_email: false)
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
true true
end end

Loading…
Cancel
Save