about summary refs log blame commit diff
path: root/app/controllers/admin/instances_controller.rb
blob: 3296e08db89a25b91fe95f42545f65565f3afd1c (plain) (tree)
1
2
3
4
5
6
7
8



                                            
                                    
       




                                                                                
           

                                                           
 
                                      
                         
                                                                 
       


                                                                     
     
# frozen_string_literal: true

module Admin
  class InstancesController < BaseController
    def index
      @instances = ordered_instances
    end

    def resubscribe
      params.require(:by_domain)
      Pubsubhubbub::SubscribeWorker.push_bulk(subscribeable_accounts.pluck(:id))
      redirect_to admin_instances_path
    end

    private

    def paginated_instances
      Account.remote.by_domain_accounts.page(params[:page])
    end

    helper_method :paginated_instances

    def ordered_instances
      paginated_instances.map { |account| Instance.new(account) }
    end

    def subscribeable_accounts
      Account.with_followers.remote.where(domain: params[:by_domain])
    end
  end
end