block_domain_service.rb 455 Bytes
Newer Older
1
2
# frozen_string_literal: true

Eugen Rochko's avatar
Eugen Rochko committed
3
class BlockDomainService < BaseService
4
5
6
  def call(domain_block)
    if domain_block.silence?
      Account.where(domain: domain_block.domain).update_all(silenced: true)
7
    else
8
      Account.where(domain: domain_block.domain).find_each do |account|
9
10
        account.subscription(api_subscription_url(account.id)).unsubscribe if account.subscribed?
        SuspendAccountService.new.call(account)
Eugen Rochko's avatar
Eugen Rochko committed
11
12
13
14
      end
    end
  end
end