about summary refs log tree commit diff
path: root/app/services/block_domain_service.rb
blob: 075460605ec533cc3f2849c103868e12564a224a (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('').unsubscribe
      end

      account.destroy!
    end
  end
end