From 029e18f9b80eea9cd9bea8c6e5b852921cfa8aed Mon Sep 17 00:00:00 2001 From: Jeremy Kescher Date: Thu, 11 May 2023 13:40:24 +0200 Subject: [PATCH] ReactionsController: Don't check for status reaction existence in destroy UnreactService checks for its existence in the background anyway, so remove redundant checks. --- .../api/v1/statuses/reactions_controller.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v1/statuses/reactions_controller.rb b/app/controllers/api/v1/statuses/reactions_controller.rb index e90e46c507..2d7e4f5984 100644 --- a/app/controllers/api/v1/statuses/reactions_controller.rb +++ b/app/controllers/api/v1/statuses/reactions_controller.rb @@ -5,7 +5,7 @@ class Api::V1::Statuses::ReactionsController < Api::BaseController before_action -> { doorkeeper_authorize! :write, :'write:favourites' } before_action :require_user! - before_action :set_status, only: [:create] + before_action :set_status def create ReactService.new.call(current_account, @status, params[:id]) @@ -13,15 +13,7 @@ class Api::V1::Statuses::ReactionsController < Api::BaseController end def destroy - react = current_account.status_reactions.find_by(status_id: params[:status_id], name: params[:id]) - - if react - @status = react.status - UnreactWorker.perform_async(current_account.id, @status.id, params[:id]) - else - @status = Status.find(params[:status_id]) - authorize @status, :show? - end + UnreactWorker.perform_async(current_account.id, @status.id, params[:id]) render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, reactions_map: { @status.id => false }) rescue Mastodon::NotPermittedError