2017-04-16 11:51:30 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UnblockDomainService < BaseService
|
2017-05-07 13:44:28 +01:00
|
|
|
attr_accessor :domain_block
|
|
|
|
|
2017-04-16 11:51:30 +01:00
|
|
|
def call(domain_block, retroactive)
|
2017-05-07 13:44:28 +01:00
|
|
|
@domain_block = domain_block
|
|
|
|
process_retroactive_updates if retroactive
|
|
|
|
domain_block.destroy
|
|
|
|
end
|
2017-05-06 16:03:34 +01:00
|
|
|
|
2017-05-07 13:44:28 +01:00
|
|
|
def process_retroactive_updates
|
2017-07-24 13:26:55 +01:00
|
|
|
blocked_accounts.in_batches.update_all(update_options) unless domain_block.noop?
|
2017-05-07 13:44:28 +01:00
|
|
|
end
|
2017-04-16 11:51:30 +01:00
|
|
|
|
2017-05-07 13:44:28 +01:00
|
|
|
def blocked_accounts
|
|
|
|
Account.where(domain: domain_block.domain)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_options
|
|
|
|
{ domain_block_impact => false }
|
|
|
|
end
|
|
|
|
|
|
|
|
def domain_block_impact
|
|
|
|
domain_block.silence? ? :silenced : :suspended
|
2017-04-16 11:51:30 +01:00
|
|
|
end
|
|
|
|
end
|