about summary refs log tree commit diff
path: root/app/services/block_domain_service.rb
blob: 93987af29b7c4ff0a26540cc6fcfdf6f45ef157f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
class BlockDomainService < BaseService
  def call(domain)
    DomainBlock.find_or_create_by!(domain: domain)

    Account.where(domain: domain).find_each do |account|
      if account.subscribed?
        account.subscription(api_subscription_url(account.id)).unsubscribe
      end

      account.destroy!
    end
  end
end