about summary refs log tree commit diff
path: root/app/services/block_domain_service.rb
blob: 6c131bd3410c35b05990ff2297476e89424e0a9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

class BlockDomainService < BaseService
  def call(domain_block)
    if domain_block.silence?
      Account.where(domain: domain_block.domain).update_all(silenced: true)
    else
      Account.where(domain: domain_block.domain).find_each do |account|
        account.subscription(api_subscription_url(account.id)).unsubscribe if account.subscribed?
        SuspendAccountService.new.call(account)
      end
    end
  end
end