logo

mastofe

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

mutes_controller.rb (1036B)


  1. # frozen_string_literal: true
  2. class Api::V1::Statuses::MutesController < Api::BaseController
  3. include Authorization
  4. before_action -> { doorkeeper_authorize! :write }
  5. before_action :require_user!
  6. before_action :set_status
  7. before_action :set_conversation
  8. respond_to :json
  9. def create
  10. current_account.mute_conversation!(@conversation)
  11. @mutes_map = { @conversation.id => true }
  12. render json: @status, serializer: REST::StatusSerializer
  13. end
  14. def destroy
  15. current_account.unmute_conversation!(@conversation)
  16. @mutes_map = { @conversation.id => false }
  17. render json: @status, serializer: REST::StatusSerializer
  18. end
  19. private
  20. def set_status
  21. @status = Status.find(params[:status_id])
  22. authorize @status, :show?
  23. rescue Mastodon::NotPermittedError
  24. # Reraise in order to get a 404 instead of a 403 error code
  25. raise ActiveRecord::RecordNotFound
  26. end
  27. def set_conversation
  28. @conversation = @status.conversation
  29. raise Mastodon::ValidationError if @conversation.nil?
  30. end
  31. end