2013-05-31 10:41:40 -05:00
|
|
|
# The SpamRulesEnforcer class takes action against users based on flags that their posts
|
|
|
|
# receive, their trust level, etc.
|
|
|
|
class SpamRulesEnforcer
|
|
|
|
|
2013-10-11 12:33:23 -05: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 10:41:40 -05:00
|
|
|
end
|
|
|
|
|
2013-10-11 12:33:23 -05:00
|
|
|
def initialize(arg)
|
|
|
|
@user = arg if arg.is_a?(User)
|
|
|
|
@post = arg if arg.is_a?(Post)
|
2013-05-31 10:41:40 -05:00
|
|
|
end
|
|
|
|
|
2013-10-11 12:33:23 -05:00
|
|
|
def enforce!
|
|
|
|
if @user
|
2013-10-25 12:25:02 -05:00
|
|
|
SpamRule::AutoBlock.new(@user).perform
|
2013-10-11 12:33:23 -05:00
|
|
|
end
|
|
|
|
if @post
|
2013-10-25 12:25:02 -05:00
|
|
|
SpamRule::FlagSockpuppets.new(@post).perform
|
2013-10-11 12:33:23 -05:00
|
|
|
end
|
|
|
|
true
|
2013-05-31 10:41:40 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|