You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
943 B

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