diff options
author | Starfall <root@starfall.blue> | 2020-03-01 14:49:21 -0600 |
---|---|---|
committer | Starfall <root@starfall.blue> | 2020-03-01 14:49:21 -0600 |
commit | 12d35783db1bb302d7540d8d3690ab6eed3dac3b (patch) | |
tree | 66f1db08a2f6f9ae2254ba7a81b71835039d671e /app/controllers/api/v1/statuses/reblogs_controller.rb | |
parent | 22a55edc158352003a3953964c9d332a60c86428 (diff) |
Revert "Merge branch 'glitch'"
Login is broken This reverts commit 22a55edc158352003a3953964c9d332a60c86428, reversing changes made to 5902299384d15249fe4b84b8761d4a49f3c7f6fd.
Diffstat (limited to 'app/controllers/api/v1/statuses/reblogs_controller.rb')
-rw-r--r-- | app/controllers/api/v1/statuses/reblogs_controller.rb | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/app/controllers/api/v1/statuses/reblogs_controller.rb b/app/controllers/api/v1/statuses/reblogs_controller.rb index 67106ccbe..42381a37f 100644 --- a/app/controllers/api/v1/statuses/reblogs_controller.rb +++ b/app/controllers/api/v1/statuses/reblogs_controller.rb @@ -5,34 +5,33 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController before_action -> { doorkeeper_authorize! :write, :'write:statuses' } before_action :require_user! - before_action :set_reblog respond_to :json def create - @status = ReblogService.new.call(current_account, @reblog, reblog_params) + @status = ReblogService.new.call(current_user.account, status_for_reblog, reblog_params) render json: @status, serializer: REST::StatusSerializer end def destroy - @status = current_account.statuses.find_by(reblog_of_id: @reblog.id) + @status = status_for_destroy.reblog + @reblogs_map = { @status.id => false } - if @status - authorize @status, :unreblog? - @status.discard - RemovalWorker.perform_async(@status.id) - end + authorize status_for_destroy, :unreblog? + status_for_destroy.discard + RemovalWorker.perform_async(status_for_destroy.id) - render json: @reblog, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, reblogs_map: { @reblog.id => false }) + render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, reblogs_map: @reblogs_map) end private - def set_reblog - @reblog = Status.find(params[:status_id]) - authorize @reblog, :show? - rescue Mastodon::NotPermittedError - not_found + def status_for_reblog + Status.find params[:status_id] + end + + def status_for_destroy + @status_for_destroy ||= current_user.account.statuses.where(reblog_of_id: params[:status_id]).first! end def reblog_params |