mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-25 01:24:02 -05:00
707ddf7808
* Change domain blocks to automatically support subdomains If a more authoritative domain is blocked (example.com), then the same block will be applied to a subdomain (foo.example.com) * Match subdomains of existing accounts when blocking/unblocking domains * Improve code style
34 lines
765 B
Ruby
34 lines
765 B
Ruby
# 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
|
|
blocked_accounts.in_batches.update_all(update_options) unless domain_block.noop?
|
|
end
|
|
|
|
def blocked_accounts
|
|
scope = Account.by_domain_and_subdomains(domain_block.domain)
|
|
|
|
if domain_block.silence?
|
|
scope.where(silenced_at: @domain_block.created_at)
|
|
else
|
|
scope.where(suspended_at: @domain_block.created_at)
|
|
end
|
|
end
|
|
|
|
def update_options
|
|
{ domain_block_impact => nil }
|
|
end
|
|
|
|
def domain_block_impact
|
|
domain_block.silence? ? :silenced_at : :suspended_at
|
|
end
|
|
end
|