about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-04-08 19:17:37 +0200
committerGitHub <noreply@github.com>2022-04-08 19:17:37 +0200
commit3906dd67ed84f963238f9bdccef63fe3fd3a05aa (patch)
tree3c0f065f60a2e498c651218b31944ffcc0037814
parent8e20e16cf030fef48850df4764bbf13a317f6b0c (diff)
Fix extremely rare race condition when deleting a toot or account (#17994)
-rw-r--r--app/controllers/api/v1/admin/accounts_controller.rb3
-rw-r--r--app/controllers/api/v1/statuses_controller.rb6
2 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/api/v1/admin/accounts_controller.rb b/app/controllers/api/v1/admin/accounts_controller.rb
index dc9d3402f..65ed69f7b 100644
--- a/app/controllers/api/v1/admin/accounts_controller.rb
+++ b/app/controllers/api/v1/admin/accounts_controller.rb
@@ -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
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb
index 3fe137bfd..9270117da 100644
--- a/app/controllers/api/v1/statuses_controller.rb
+++ b/app/controllers/api/v1/statuses_controller.rb
@@ -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