Adding domain blocks
This commit is contained in:
13
app/services/block_domain_service.rb
Normal file
13
app/services/block_domain_service.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class BlockDomainService < BaseService
|
||||
def call(domain)
|
||||
block = DomainBlock.find_or_create_by!(domain: domain)
|
||||
|
||||
Account.where(domain: domain).find_each do |account|
|
||||
if account.subscribed?
|
||||
account.subscription('').unsubscribe
|
||||
end
|
||||
|
||||
account.destroy!
|
||||
end
|
||||
end
|
||||
end
|
@ -8,6 +8,7 @@ class FollowRemoteAccountService < BaseService
|
||||
username, domain = uri.split('@')
|
||||
|
||||
return Account.find_local(username) if TagManager.instance.local_domain?(domain)
|
||||
return nil if DomainBlock.blocked?(domain)
|
||||
|
||||
account = Account.find_remote(username, domain)
|
||||
|
||||
|
@ -13,6 +13,8 @@ class ProcessInteractionService < BaseService
|
||||
domain = Addressable::URI.parse(url).host
|
||||
account = Account.find_by(username: username, domain: domain)
|
||||
|
||||
return if DomainBlock.blocked?(domain)
|
||||
|
||||
if account.nil?
|
||||
account = follow_remote_account_service.call("#{username}@#{domain}")
|
||||
end
|
||||
|
Reference in New Issue
Block a user