about summary refs log tree commit diff
path: root/app/services/block_domain_service.rb
blob: ac658a050e16e977094326f7e5e41bf14e9b928a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
class BlockDomainService < BaseService
  def call(domain)
    block = 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