openstreetmap-website/app/models/spam_observer.rb
Tom Hughes f07819d81a Rework application configuration
Use a preinitializer to load the settings from application.yml so
that they are available as early as possible. All settings can also
be overridden using environment variables.

The ad-hoc settins in environment.rb are then moved to this new
system so we have one consistent location for settings.
2010-08-04 22:06:05 +01:00

15 lines
421 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 > SPAM_THRESHOLD
user.update_attributes(:status => "suspended")
end
end
end