Adding domain blocks

This commit is contained in:
Eugen Rochko
2016-10-09 14:48:43 +02:00
parent 52d7f862d3
commit 22a8801dbc
13 changed files with 92 additions and 10 deletions

View 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

View File

@ -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)

View File

@ -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