logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

reblogs_controller.rb (957B)


  1. # frozen_string_literal: true
  2. class Api::V1::Statuses::ReblogsController < Api::BaseController
  3. include Authorization
  4. before_action -> { doorkeeper_authorize! :write }
  5. before_action :require_user!
  6. respond_to :json
  7. def create
  8. @status = ReblogService.new.call(current_user.account, status_for_reblog)
  9. render json: @status, serializer: REST::StatusSerializer
  10. end
  11. def destroy
  12. @status = status_for_destroy.reblog
  13. @reblogs_map = { @status.id => false }
  14. authorize status_for_destroy, :unreblog?
  15. RemovalWorker.perform_async(status_for_destroy.id)
  16. render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, reblogs_map: @reblogs_map)
  17. end
  18. private
  19. def status_for_reblog
  20. Status.find params[:status_id]
  21. end
  22. def status_for_destroy
  23. current_user.account.statuses.where(reblog_of_id: params[:status_id]).first!
  24. end
  25. end