about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-11-17 03:10:27 -0600
committermultiple creatures <dev@multiple-creature.party>2019-11-17 03:10:27 -0600
commit81c2b3e2400c67f638efdd15c1c4a060e65e3d23 (patch)
treea12ccbb1e17f649ffa48e39b5c011fe6b3ea63ff /app/models
parent5ab70ad962481a2169593b81d15f86d1ea99653d (diff)
When domain policies are created or updated, set the `processing` flag from the model instead of from the controller.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/domain_block.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb
index 478095cb0..f7a87b443 100644
--- a/app/models/domain_block.rb
+++ b/app/models/domain_block.rb
@@ -29,6 +29,8 @@ class DomainBlock < ApplicationRecord
   scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
   scope :unprocessed, -> { where(processing: true) }
 
+  before_create :set_processing
+
   def self.blocked?(domain)
     where(domain: domain, severity: :suspend).exists?
   end
@@ -63,4 +65,11 @@ class DomainBlock < ApplicationRecord
   def undo
     return false
   end
+
+  private
+
+  def set_processing
+    return if processing
+    self.processing = true
+  end
 end