2013-05-31 11:41:40 -04:00
|
|
|
# The SpamRulesEnforcer class takes action against users based on flags that their posts
|
|
|
|
# receive, their trust level, etc.
|
|
|
|
class SpamRulesEnforcer
|
|
|
|
|
2013-10-11 13:33:23 -04:00
|
|
|
# The exclamation point means that this method may make big changes to posts and users.
|
|
|
|
def self.enforce!(arg)
|
|
|
|
SpamRulesEnforcer.new(arg).enforce!
|
2013-05-31 11:41:40 -04:00
|
|
|
end
|
|
|
|
|
2013-10-11 13:33:23 -04:00
|
|
|
def initialize(arg)
|
|
|
|
@user = arg if arg.is_a?(User)
|
|
|
|
@post = arg if arg.is_a?(Post)
|
2013-05-31 11:41:40 -04:00
|
|
|
end
|
|
|
|
|
2013-10-11 13:33:23 -04:00
|
|
|
def enforce!
|
|
|
|
if @user
|
2013-10-25 13:25:02 -04:00
|
|
|
SpamRule::AutoBlock.new(@user).perform
|
2013-10-11 13:33:23 -04:00
|
|
|
end
|
|
|
|
if @post
|
2013-10-25 13:25:02 -04:00
|
|
|
SpamRule::FlagSockpuppets.new(@post).perform
|
2013-10-11 13:33:23 -04:00
|
|
|
end
|
|
|
|
true
|
2013-05-31 11:41:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|