about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-08-30 22:03:46 -0500
committermultiple creatures <dev@multiple-creature.party>2019-08-30 22:03:46 -0500
commit3b276d268f8e49b897f16f490c78a5a5880c6216 (patch)
treebcb653e975ab223cf8d048778ab113489bf67b6d /app/services
parent60c449e1d77c6e11ced796a7e088038d80137de6 (diff)
use a scheduled task to batch domain policy changes + revert `29643fd6` to avoid accidentally dosing servers when multiple users block a domain
Diffstat (limited to 'app/services')
-rw-r--r--app/services/activitypub/process_account_service.rb6
-rw-r--r--app/services/after_block_domain_from_account_service.rb7
-rw-r--r--app/services/after_unblock_domain_from_account_service.rb18
-rw-r--r--app/services/block_domain_service.rb2
-rw-r--r--app/services/update_account_domain_blocks_service.rb19
5 files changed, 2 insertions, 50 deletions
diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb
index dd19db485..c1c643ff0 100644
--- a/app/services/activitypub/process_account_service.rb
+++ b/app/services/activitypub/process_account_service.rb
@@ -27,7 +27,6 @@ class ActivityPub::ProcessAccountService < BaseService
           create_account
         end
         update_account
-        update_account_domain_blocks if is_new_account
         process_tags
         process_attachments
       else
@@ -121,11 +120,6 @@ class ActivityPub::ProcessAccountService < BaseService
     VerifyAccountLinksWorker.perform_async(@account.id)
   end
 
-  def update_account_domain_blocks
-    return if @account.domain.nil? || @account.local?
-    UpdateAccountDomainBlocksWorker.perform_async(@account.id)
-  end
-
   def actor_type
     if @json['type'].is_a?(Array)
       @json['type'].find { |type| ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(type) }
diff --git a/app/services/after_block_domain_from_account_service.rb b/app/services/after_block_domain_from_account_service.rb
index 762a8baea..f12f18319 100644
--- a/app/services/after_block_domain_from_account_service.rb
+++ b/app/services/after_block_domain_from_account_service.rb
@@ -10,7 +10,6 @@ class AfterBlockDomainFromAccountService < BaseService
 
     reject_existing_followers!
     reject_pending_follow_requests!
-    block_accounts!
   end
 
   private
@@ -27,12 +26,6 @@ class AfterBlockDomainFromAccountService < BaseService
     end
   end
 
-  def block_accounts!
-    Account.where(domain: @domain).find_each do |blocked_account|
-      BlockService.new.call(@account, blocked_account)
-    end
-  end
-
   def reject_follow!(follow)
     follow.destroy
 
diff --git a/app/services/after_unblock_domain_from_account_service.rb b/app/services/after_unblock_domain_from_account_service.rb
deleted file mode 100644
index a2d10bcf0..000000000
--- a/app/services/after_unblock_domain_from_account_service.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-class AfterUnblockDomainFromAccountService < BaseService
-  def call(account, domain)
-    @account = account
-    @domain  = domain
-
-    unblock_accounts!
-  end
-
-  private
-
-  def unblock_accounts!
-    @account.blocking.where(domain: @domain).find_each do |blocked_account|
-      UnblockService.new.call(@account, blocked_account)
-    end
-  end
-end
diff --git a/app/services/block_domain_service.rb b/app/services/block_domain_service.rb
index 5a6f4a6ce..3fd55cf3b 100644
--- a/app/services/block_domain_service.rb
+++ b/app/services/block_domain_service.rb
@@ -10,6 +10,8 @@ class BlockDomainService < BaseService
     remove_existing_block!
     process_domain_block!
     invalidate_association_caches!
+
+    @domain_block.update(processing: false)
   end
 
   private
diff --git a/app/services/update_account_domain_blocks_service.rb b/app/services/update_account_domain_blocks_service.rb
deleted file mode 100644
index d14cdbdda..000000000
--- a/app/services/update_account_domain_blocks_service.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-class UpdateAccountDomainBlocksService < BaseService
-  def call(account)
-    @account = account
-    @domain  = account.domain
-
-    block_where_domain_blocked!
-  end
-
-  private
-
-  def block_where_domain_blocked!
-    account_ids = AccountDomainBlock.distinct.where(domain: @domain).pluck(:account_id)
-    Account.where(id: account_ids).find_each do |blocked_by|
-      BlockService.new.call(blocked_by, @account)
-    end
-  end
-end