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
|
|
|
|
|
2019-05-14 18:05:02 +01:00
|
|
|
def call(domain_block)
|
2017-05-07 13:44:28 +01:00
|
|
|
@domain_block = domain_block
|
2019-05-14 18:05:02 +01:00
|
|
|
process_retroactive_updates
|
2017-05-07 13:44:28 +01:00
|
|
|
domain_block.destroy
|
|
|
|
end
|
2017-05-06 16:03:34 +01:00
|
|
|
|
2017-05-07 13:44:28 +01:00
|
|
|
def process_retroactive_updates
|
2019-06-21 23:13:10 +01:00
|
|
|
scope = Account.by_domain_and_subdomains(domain_block.domain)
|
|
|
|
|
2019-08-07 19:20:23 +01:00
|
|
|
scope.where(silenced_at: domain_block.created_at).in_batches.update_all(silenced_at: nil) unless domain_block.noop?
|
2020-11-07 23:28:39 +00:00
|
|
|
scope.where(suspended_at: domain_block.created_at).in_batches.update_all(suspended_at: nil, suspension_origin: nil) if domain_block.suspend?
|
2017-04-16 11:51:30 +01:00
|
|
|
end
|
|
|
|
end
|