ReactionsController: Don't check for status reaction existence in destroy

UnreactService checks for its existence in the background anyway, so remove redundant checks.
This commit is contained in:
Jeremy Kescher 2023-05-11 13:40:24 +02:00
parent 5d0a1a7b74
commit 0f96d0fbb7
No known key found for this signature in database
GPG key ID: 80A419A7A613DFA4

View file

@ -5,7 +5,7 @@ class Api::V1::Statuses::ReactionsController < Api::BaseController
before_action -> { doorkeeper_authorize! :write, :'write:favourites' } before_action -> { doorkeeper_authorize! :write, :'write:favourites' }
before_action :require_user! before_action :require_user!
before_action :set_status, only: [:create] before_action :set_status
def create def create
ReactService.new.call(current_account, @status, params[:id]) ReactService.new.call(current_account, @status, params[:id])
@ -13,15 +13,7 @@ class Api::V1::Statuses::ReactionsController < Api::BaseController
end end
def destroy def destroy
react = current_account.status_reactions.find_by(status_id: params[:status_id], name: params[:id]) UnreactWorker.perform_async(current_account.id, @status.id, 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
render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, reactions_map: { @status.id => false }) render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, reactions_map: { @status.id => false })
rescue Mastodon::NotPermittedError rescue Mastodon::NotPermittedError