2017-04-18 22:09:07 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Admin
|
|
|
|
class InstancesController < BaseController
|
|
|
|
def index
|
2017-11-11 21:23:33 +02:00
|
|
|
authorize :instance, :index?
|
2019-01-08 14:39:49 +02:00
|
|
|
|
2017-05-31 21:38:44 +03:00
|
|
|
@instances = ordered_instances
|
2017-04-18 22:09:07 +03:00
|
|
|
end
|
|
|
|
|
2019-01-08 14:39:49 +02:00
|
|
|
def show
|
|
|
|
authorize :instance, :show?
|
|
|
|
|
|
|
|
@instance = Instance.new(Account.by_domain_accounts.find_by(domain: params[:id]) || DomainBlock.find_by!(domain: params[:id]))
|
|
|
|
@following_count = Follow.where(account: Account.where(domain: params[:id])).count
|
|
|
|
@followers_count = Follow.where(target_account: Account.where(domain: params[:id])).count
|
|
|
|
@reports_count = Report.where(target_account: Account.where(domain: params[:id])).count
|
|
|
|
@blocks_count = Block.where(target_account: Account.where(domain: params[:id])).count
|
|
|
|
@available = DeliveryFailureTracker.available?(Account.select(:shared_inbox_url).where(domain: params[:id]).first&.shared_inbox_url)
|
|
|
|
@media_storage = MediaAttachment.where(account: Account.where(domain: params[:id])).sum(:file_file_size)
|
2019-06-22 01:13:10 +03:00
|
|
|
@domain_block = DomainBlock.rule_for(params[:id])
|
2017-07-21 00:07:13 +03:00
|
|
|
end
|
|
|
|
|
2017-04-18 22:09:07 +03:00
|
|
|
private
|
|
|
|
|
2017-09-13 13:30:07 +03:00
|
|
|
def filtered_instances
|
|
|
|
InstanceFilter.new(filter_params).results
|
|
|
|
end
|
|
|
|
|
2017-05-31 21:38:44 +03:00
|
|
|
def paginated_instances
|
2017-09-13 13:30:07 +03:00
|
|
|
filtered_instances.page(params[:page])
|
2017-05-31 21:38:44 +03:00
|
|
|
end
|
2017-07-21 00:07:13 +03:00
|
|
|
|
2017-05-31 21:38:44 +03:00
|
|
|
helper_method :paginated_instances
|
|
|
|
|
2017-04-18 22:09:07 +03:00
|
|
|
def ordered_instances
|
2019-01-08 14:39:49 +02:00
|
|
|
paginated_instances.map { |resource| Instance.new(resource) }
|
2017-07-21 00:07:13 +03:00
|
|
|
end
|
2017-09-13 13:30:07 +03:00
|
|
|
|
|
|
|
def filter_params
|
2019-02-18 15:59:19 +02:00
|
|
|
params.permit(:limited, :by_domain)
|
2017-09-13 13:30:07 +03:00
|
|
|
end
|
2017-04-18 22:09:07 +03:00
|
|
|
end
|
|
|
|
end
|