2017-04-16 20:51:30 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UnblockDomainService < BaseService
|
2017-05-07 22:44:28 +10:00
|
|
|
attr_accessor :domain_block
|
|
|
|
|
2019-05-15 03:05:02 +10:00
|
|
|
def call(domain_block)
|
2017-05-07 22:44:28 +10:00
|
|
|
@domain_block = domain_block
|
2019-05-15 03:05:02 +10:00
|
|
|
process_retroactive_updates
|
2017-05-07 22:44:28 +10:00
|
|
|
domain_block.destroy
|
|
|
|
end
|
2017-05-07 01:03:34 +10:00
|
|
|
|
2017-05-07 22:44:28 +10:00
|
|
|
def process_retroactive_updates
|
2017-07-24 22:26:55 +10:00
|
|
|
blocked_accounts.in_batches.update_all(update_options) unless domain_block.noop?
|
2017-05-07 22:44:28 +10:00
|
|
|
end
|
2017-04-16 20:51:30 +10:00
|
|
|
|
2017-05-07 22:44:28 +10:00
|
|
|
def blocked_accounts
|
2019-06-22 08:13:10 +10:00
|
|
|
scope = Account.by_domain_and_subdomains(domain_block.domain)
|
|
|
|
|
2019-05-15 03:05:02 +10:00
|
|
|
if domain_block.silence?
|
|
|
|
scope.where(silenced_at: @domain_block.created_at)
|
|
|
|
else
|
|
|
|
scope.where(suspended_at: @domain_block.created_at)
|
|
|
|
end
|
2017-05-07 22:44:28 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
def update_options
|
2019-05-15 03:05:02 +10:00
|
|
|
{ domain_block_impact => nil }
|
2017-05-07 22:44:28 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
def domain_block_impact
|
2019-05-15 03:05:02 +10:00
|
|
|
domain_block.silence? ? :silenced_at : :suspended_at
|
2017-04-16 20:51:30 +10:00
|
|
|
end
|
|
|
|
end
|