openstreetmap-website/app/models/spam_observer.rb
Tom Hughes 980c2fa301 Suspend users if their spam score gets too high
Use an observer to watch all diary and user updates and, if the user
is not confirmed, chek their spam score and suspend then if it has got
too high.
2010-05-06 17:18:34 +01:00

15 lines
435 B
Ruby

class SpamObserver < ActiveRecord::Observer
observe User, DiaryEntry, DiaryComment
def after_save(record)
case
when record.is_a?(User): user = record
when record.is_a?(DiaryEntry): user = record.user
when record.is_a?(DiaryComment): user = record.user
end
if user.status == "active" and user.spam_score > APP_CONFIG['spam_threshold']
user.update_attributes(:status => "suspended")
end
end
end