This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/services/spam_rules_enforcer.rb

26 lines
583 B
Ruby

# The SpamRulesEnforcer class takes action against users based on flags that their posts
# receive, their trust level, etc.
class SpamRulesEnforcer
# The exclamation point means that this method may make big changes to posts and users.
def self.enforce!(arg)
SpamRulesEnforcer.new(arg).enforce!
end
def initialize(arg)
@user = arg if arg.is_a?(User)
@post = arg if arg.is_a?(Post)
end
def enforce!
if @user
SpamRule::AutoBlock.new(@user).perform
end
if @post
SpamRule::FlagSockpuppets.new(@post).perform
end
true
end
end