]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Make the node controller return the modified time for deleted nodes
[rails.git] / app / models / user.rb
index 778afbf8a9c7ae26d76339905209a447ae9e92eb..6677d3b98372585e2a8ffacc1b5b6aa722fe17ca 100644 (file)
@@ -52,6 +52,7 @@ class User < ActiveRecord::Base
 
   after_initialize :set_defaults
   before_save :encrypt_password
+  after_save :spam_check
 
   has_attached_file :image,
     :default_url => "/assets/:class/:attachment/:style.png",
@@ -216,6 +217,14 @@ class User < ActiveRecord::Base
     return score.to_i
   end
 
+  ##
+  # perform a spam check on a user
+  def spam_check
+    if status == "active" and spam_score > SPAM_THRESHOLD
+      update_column(:status, "suspended")
+    end
+  end
+
   ##
   # return an oauth access token for a specified application
   def access_token(application_key)