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

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