mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add ScreenedUrl. Rename BlockedEmail to ScreenedEmail.
This commit is contained in:
31
lib/screening_model.rb
Normal file
31
lib/screening_model.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
module ScreeningModel
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
def actions
|
||||
@actions ||= Enum.new(:block, :do_nothing)
|
||||
end
|
||||
|
||||
def default_action(action_key)
|
||||
@default_action = action_key
|
||||
end
|
||||
|
||||
def df_action
|
||||
@default_action || :do_nothing
|
||||
end
|
||||
end
|
||||
|
||||
included do
|
||||
before_validation :set_default_action
|
||||
end
|
||||
|
||||
def set_default_action
|
||||
self.action_type ||= self.class.actions[self.class.df_action]
|
||||
end
|
||||
|
||||
def record_match!
|
||||
self.match_count += 1
|
||||
self.last_match_at = Time.zone.now
|
||||
save
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user