diff --git a/app/controllers/api/v1/statuses/reactions_controller.rb b/app/controllers/api/v1/statuses/reactions_controller.rb index db43346def..9542d491c8 100644 --- a/app/controllers/api/v1/statuses/reactions_controller.rb +++ b/app/controllers/api/v1/statuses/reactions_controller.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true class Api::V1::Statuses::ReactionsController < Api::BaseController + include Authorization + before_action -> { doorkeeper_authorize! :write, :'write:favourites' } before_action :require_user! - before_action :set_status - before_action :set_reaction, except: :update def update ReactService.new.call(current_account, @status, params[:id]) @@ -13,16 +13,12 @@ class Api::V1::Statuses::ReactionsController < Api::BaseController end def destroy - UnreactService.new.call(current_account, @status) + UnreactService.new.call(current_account, @status, params[:id]) render_empty end private - def set_reaction - @reaction = @status.status_reactions.where(account: current_account).find_by!(name: params[:id]) - end - def set_status @status = Status.find(params[:status_id]) end diff --git a/app/services/unreact_service.rb b/app/services/unreact_service.rb index ebc270383c..f4089f33b5 100644 --- a/app/services/unreact_service.rb +++ b/app/services/unreact_service.rb @@ -3,8 +3,8 @@ class UnreactService < BaseService include Payloadable - def call(account, status) - reaction = StatusReaction.find_by(account: account, status: status) + def call(account, status, name) + reaction = StatusReaction.find_by(account: account, status: status, name: name) return if reaction.nil? reaction.destroy!