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

class UpdateAccountDomainBlocksService < BaseService
  def call(account)
    @account = account
    @domain  = account.domain

    block_where_domain_blocked!
  end

  private

  def block_where_domain_blocked!
    account_ids = AccountDomainBlock.distinct.where(domain: @domain).pluck(:account_id)
    Account.where(id: account_ids).find_each do |blocked_by|
      BlockService.new.call(blocked_by, @account)
    end
  end
end