Fix extremely rare race condition when deleting a toot or account (#17994)
This commit is contained in:
		
							parent
							
								
									8e20e16cf0
								
							
						
					
					
						commit
						3906dd67ed
					
				| 
						 | 
					@ -65,8 +65,9 @@ class Api::V1::Admin::AccountsController < Api::BaseController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def destroy
 | 
					  def destroy
 | 
				
			||||||
    authorize @account, :destroy?
 | 
					    authorize @account, :destroy?
 | 
				
			||||||
 | 
					    json = render_to_body json: @account, serializer: REST::Admin::AccountSerializer
 | 
				
			||||||
    Admin::AccountDeletionWorker.perform_async(@account.id)
 | 
					    Admin::AccountDeletionWorker.perform_async(@account.id)
 | 
				
			||||||
    render json: @account, serializer: REST::Admin::AccountSerializer
 | 
					    render json: json
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def unsensitive
 | 
					  def unsensitive
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,10 +77,12 @@ class Api::V1::StatusesController < Api::BaseController
 | 
				
			||||||
    authorize @status, :destroy?
 | 
					    authorize @status, :destroy?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @status.discard
 | 
					    @status.discard
 | 
				
			||||||
    RemovalWorker.perform_async(@status.id, { 'redraft' => true })
 | 
					 | 
				
			||||||
    @status.account.statuses_count = @status.account.statuses_count - 1
 | 
					    @status.account.statuses_count = @status.account.statuses_count - 1
 | 
				
			||||||
 | 
					    json = render_to_body json: @status, serializer: REST::StatusSerializer, source_requested: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    render json: @status, serializer: REST::StatusSerializer, source_requested: true
 | 
					    RemovalWorker.perform_async(@status.id, { 'redraft' => true })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    render json: json
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private
 | 
					  private
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue