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.

23 lines
769 B

  1. # frozen_string_literal: true
  2. class Api::V1::Instances::DomainBlocksController < Api::BaseController
  3. skip_before_action :require_authenticated_user!
  4. before_action :require_enabled_api!
  5. before_action :set_domain_blocks
  6. def index
  7. expires_in 3.minutes, public: true
  8. render json: @domain_blocks, each_serializer: REST::DomainBlockSerializer, with_comment: (Setting.show_domain_blocks_rationale == 'all' || (Setting.show_domain_blocks_rationale == 'users' && user_signed_in?))
  9. end
  10. private
  11. def require_enabled_api!
  12. head 404 unless Setting.show_domain_blocks == 'all' || (Setting.show_domain_blocks == 'users' && user_signed_in?)
  13. end
  14. def set_domain_blocks
  15. @domain_blocks = DomainBlock.with_user_facing_limitations.by_severity
  16. end
  17. end