about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-06-22 00:13:10 +0200
committermultiple creatures <dev@multiple-creature.party>2020-02-21 01:48:49 -0600
commit0a238f34b39b606d5f20e1ef1fbdd2a8c56951db (patch)
tree9192e83c420e085c16c8a65fe6077ca30046dd44 /app/models/account.rb
parente6e69f091e3414b29271040926cc1d2e7c5f0e41 (diff)
port tootsuite#11138 to monsterfork: Change domain blocks to automatically support subdomains
* 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
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 28ba35148..f50be9d4c 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -122,6 +122,7 @@ class Account < ApplicationRecord
   scope :popular, -> { order('account_stats.followers_count desc') }
   scope :without_hidden, -> { where(hidden: false) }
   scope :without_unlisted, -> { where(unlisted: false) }
+  scope :by_domain_and_subdomains, ->(domain) { where(domain: domain).or(where(arel_table[:domain].matches('%.' + domain))) }
 
   delegate :email,
            :unconfirmed_email,