peers_controller.rb 588 B

1234567891011121314151617181920212223
  1. # frozen_string_literal: true
  2. class Api::V1::Instances::PeersController < Api::V1::Instances::BaseController
  3. before_action :require_enabled_api!
  4. skip_around_action :set_locale
  5. # Override `current_user` to avoid reading session cookies unless in whitelist mode
  6. def current_user
  7. super if limited_federation_mode?
  8. end
  9. def index
  10. cache_even_if_authenticated!
  11. render_with_cache(expires_in: 1.day) { Instance.searchable.pluck(:domain) }
  12. end
  13. private
  14. def require_enabled_api!
  15. head 404 unless Setting.peers_api_enabled && !limited_federation_mode?
  16. end
  17. end