peers_controller.rb 672 B

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