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.

44 lines
1.4 KiB

  1. # frozen_string_literal: true
  2. module Admin
  3. class InstancesController < BaseController
  4. def index
  5. authorize :instance, :index?
  6. @instances = ordered_instances
  7. end
  8. def show
  9. authorize :instance, :show?
  10. @instance = Instance.new(Account.by_domain_accounts.find_by(domain: params[:id]) || DomainBlock.find_by!(domain: params[:id]))
  11. @following_count = Follow.where(account: Account.where(domain: params[:id])).count
  12. @followers_count = Follow.where(target_account: Account.where(domain: params[:id])).count
  13. @reports_count = Report.where(target_account: Account.where(domain: params[:id])).count
  14. @blocks_count = Block.where(target_account: Account.where(domain: params[:id])).count
  15. @available = DeliveryFailureTracker.available?(Account.select(:shared_inbox_url).where(domain: params[:id]).first&.shared_inbox_url)
  16. @media_storage = MediaAttachment.where(account: Account.where(domain: params[:id])).sum(:file_file_size)
  17. @domain_block = DomainBlock.rule_for(params[:id])
  18. end
  19. private
  20. def filtered_instances
  21. InstanceFilter.new(filter_params).results
  22. end
  23. def paginated_instances
  24. filtered_instances.page(params[:page])
  25. end
  26. helper_method :paginated_instances
  27. def ordered_instances
  28. paginated_instances.map { |resource| Instance.new(resource) }
  29. end
  30. def filter_params
  31. params.permit(:limited, :by_domain)
  32. end
  33. end
  34. end