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

class UnblockDomainService < BaseService
  attr_accessor :domain_block

  def call(domain_block)
    @domain_block = domain_block
    process_retroactive_updates
    domain_block.destroy
  end

  def process_retroactive_updates
    scope = Account.by_domain_and_subdomains(domain_block.domain)

    scope.where(silenced_at: domain_block.created_at).in_batches.update_all(silenced_at: nil) unless domain_block.noop?
    scope.where(suspended_at: domain_block.created_at).in_batches.update_all(suspended_at: nil) if domain_block.suspend?
  end
end