2017-04-18 20:09:07 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Admin
|
|
|
|
class InstancesController < BaseController
|
|
|
|
def index
|
2017-11-11 19:23:33 +00:00
|
|
|
authorize :instance, :index?
|
2017-05-31 19:38:44 +01:00
|
|
|
@instances = ordered_instances
|
2017-04-18 20:09:07 +01:00
|
|
|
end
|
|
|
|
|
2017-07-20 22:07:13 +01:00
|
|
|
def resubscribe
|
2017-11-11 19:23:33 +00:00
|
|
|
authorize :instance, :resubscribe?
|
2017-07-20 22:07:13 +01:00
|
|
|
params.require(:by_domain)
|
|
|
|
Pubsubhubbub::SubscribeWorker.push_bulk(subscribeable_accounts.pluck(:id))
|
|
|
|
redirect_to admin_instances_path
|
|
|
|
end
|
|
|
|
|
2017-04-18 20:09:07 +01:00
|
|
|
private
|
|
|
|
|
2017-09-13 11:30:07 +01:00
|
|
|
def filtered_instances
|
|
|
|
InstanceFilter.new(filter_params).results
|
|
|
|
end
|
|
|
|
|
2017-05-31 19:38:44 +01:00
|
|
|
def paginated_instances
|
2017-09-13 11:30:07 +01:00
|
|
|
filtered_instances.page(params[:page])
|
2017-05-31 19:38:44 +01:00
|
|
|
end
|
2017-07-20 22:07:13 +01:00
|
|
|
|
2017-05-31 19:38:44 +01:00
|
|
|
helper_method :paginated_instances
|
|
|
|
|
2017-04-18 20:09:07 +01:00
|
|
|
def ordered_instances
|
2017-05-31 19:38:44 +01:00
|
|
|
paginated_instances.map { |account| Instance.new(account) }
|
2017-04-18 20:09:07 +01:00
|
|
|
end
|
2017-07-20 22:07:13 +01:00
|
|
|
|
|
|
|
def subscribeable_accounts
|
2018-11-18 23:43:52 +00:00
|
|
|
Account.remote.where(protocol: :ostatus).where(domain: params[:by_domain])
|
2017-07-20 22:07:13 +01:00
|
|
|
end
|
2017-09-13 11:30:07 +01:00
|
|
|
|
|
|
|
def filter_params
|
|
|
|
params.permit(
|
|
|
|
:domain_name
|
|
|
|
)
|
|
|
|
end
|
2017-04-18 20:09:07 +01:00
|
|
|
end
|
|
|
|
end
|