follower_domains_controller.rb 752 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. class Settings::FollowerDomainsController < ApplicationController
  3. layout 'admin'
  4. before_action :authenticate_user!
  5. def show
  6. @account = current_account
  7. @domains = current_account.followers.reorder(Arel.sql('MIN(follows.id) DESC')).group('accounts.domain').select('accounts.domain, count(accounts.id) as accounts_from_domain').page(params[:page]).per(10)
  8. end
  9. def update
  10. domains = bulk_params[:select] || []
  11. AfterAccountDomainBlockWorker.push_bulk(domains) do |domain|
  12. [current_account.id, domain]
  13. end
  14. redirect_to settings_follower_domains_path, notice: I18n.t('followers.success', count: domains.size)
  15. end
  16. private
  17. def bulk_params
  18. params.permit(select: [])
  19. end
  20. end