directories_controller.rb 778 B

1234567891011121314151617181920212223242526272829303132
  1. # frozen_string_literal: true
  2. class DirectoriesController < ApplicationController
  3. layout 'public'
  4. before_action :authenticate_user!, if: :whitelist_mode?
  5. before_action :require_enabled!
  6. before_action :set_instance_presenter
  7. before_action :set_accounts
  8. skip_before_action :require_functional!, unless: :whitelist_mode?
  9. def index
  10. render :index
  11. end
  12. private
  13. def require_enabled!
  14. return not_found unless Setting.profile_directory
  15. end
  16. def set_accounts
  17. @accounts = Account.local.discoverable.by_recent_status.page(params[:page]).per(20).tap do |query|
  18. query.merge!(Account.not_excluded_by_account(current_account)) if current_account
  19. end
  20. end
  21. def set_instance_presenter
  22. @instance_presenter = InstancePresenter.new
  23. end
  24. end