about summary refs log tree commit diff
path: root/app/lib/activitypub
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/lib/activitypub
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/lib/activitypub')
-rw-r--r--app/lib/activitypub/activity/create.rb5
-rw-r--r--app/lib/activitypub/activity/flag.rb2
2 files changed, 2 insertions, 5 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index 83330cb93..7b2d40ace 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -486,10 +486,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
 
   def skip_download?(remote_url = nil)
     return @skip_download if defined?(@skip_download)
-    domains = Set[@account.domain]
-    domains.add(remote_url.scan(/[\w\-]+\.[\w\-]+(?:\.[\w\-]+)*/).first) if remote_url.present?
-    blocks = DomainBlock.suspend.or(DomainBlock.where(reject_media: true))
-    @skip_download ||= domains.any? { |domain| blocks.where(domain: domain).or(blocks.where('domain LIKE ?', "%.#{domain}")).exists? }
+    @skip_download ||= DomainBlock.reject_media?(@account.domain)
   end
 
   def reply_to_local?
diff --git a/app/lib/activitypub/activity/flag.rb b/app/lib/activitypub/activity/flag.rb
index 7fb6e3422..1423cedef 100644
--- a/app/lib/activitypub/activity/flag.rb
+++ b/app/lib/activitypub/activity/flag.rb
@@ -24,7 +24,7 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity
   private
 
   def skip_reports?
-    DomainBlock.find_by(domain: @account.domain)&.reject_reports?
+    DomainBlock.reject_reports?(@account.domain)
   end
 
   def object_uris