Browse Source

Fix extremely rare race condition when deleting a toot or account (#17994)

closed-social-glitch-2
Claire 2 years ago
committed by GitHub
parent
commit
3906dd67ed
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions
  1. +2
    -1
      app/controllers/api/v1/admin/accounts_controller.rb
  2. +4
    -2
      app/controllers/api/v1/statuses_controller.rb

+ 2
- 1
app/controllers/api/v1/admin/accounts_controller.rb View File

@ -65,8 +65,9 @@ class Api::V1::Admin::AccountsController < Api::BaseController
def destroy
authorize @account, :destroy?
json = render_to_body json: @account, serializer: REST::Admin::AccountSerializer
Admin::AccountDeletionWorker.perform_async(@account.id)
render json: @account, serializer: REST::Admin::AccountSerializer
render json: json
end
def unsensitive

+ 4
- 2
app/controllers/api/v1/statuses_controller.rb View File

@ -77,10 +77,12 @@ class Api::V1::StatusesController < Api::BaseController
authorize @status, :destroy?
@status.discard
RemovalWorker.perform_async(@status.id, { 'redraft' => true })
@status.account.statuses_count = @status.account.statuses_count - 1
json = render_to_body json: @status, serializer: REST::StatusSerializer, source_requested: true
RemovalWorker.perform_async(@status.id, { 'redraft' => true })
render json: @status, serializer: REST::StatusSerializer, source_requested: true
render json: json
end
private

Loading…
Cancel
Save