Add button to re-subscribe to all accounts from a domain (#4285)

rebase/4.0.0rc2
Eugen Rochko 2017-07-20 23:07:13 +02:00 committed by GitHub
parent 1fcdaafa6f
commit 4b911fea03
3 changed files with 19 additions and 1 deletions

View File

@ -6,15 +6,26 @@ module Admin
@instances = ordered_instances @instances = ordered_instances
end end
def resubscribe
params.require(:by_domain)
Pubsubhubbub::SubscribeWorker.push_bulk(subscribeable_accounts.pluck(:id))
redirect_to admin_instances_path
end
private private
def paginated_instances def paginated_instances
Account.remote.by_domain_accounts.page(params[:page]) Account.remote.by_domain_accounts.page(params[:page])
end end
helper_method :paginated_instances helper_method :paginated_instances
def ordered_instances def ordered_instances
paginated_instances.map { |account| Instance.new(account) } paginated_instances.map { |account| Instance.new(account) }
end end
def subscribeable_accounts
Account.with_followers.remote.where(domain: params[:by_domain])
end
end end
end end

View File

@ -3,3 +3,5 @@
= instance.domain = instance.domain
%td.count %td.count
= instance.accounts_count = instance.accounts_count
%td
= table_link_to 'paper-plane-o', t('admin.accounts.resubscribe'), resubscribe_admin_instances_url(by_domain: instance.domain), method: :post, data: { confirm: t('admin.accounts.are_you_sure') }

View File

@ -88,7 +88,12 @@ Rails.application.routes.draw do
resources :subscriptions, only: [:index] resources :subscriptions, only: [:index]
resources :domain_blocks, only: [:index, :new, :create, :show, :destroy] resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
resource :settings, only: [:edit, :update] resource :settings, only: [:edit, :update]
resources :instances, only: [:index]
resources :instances, only: [:index] do
collection do
post :resubscribe
end
end
resources :reports, only: [:index, :show, :update] do resources :reports, only: [:index, :show, :update] do
resources :reported_statuses, only: [:create, :update, :destroy] resources :reported_statuses, only: [:create, :update, :destroy]