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.
15 lines
435 B
Ruby
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
|