diff options
Diffstat (limited to 'app/models/concerns/spammable.rb')
-rw-r--r-- | app/models/concerns/spammable.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/concerns/spammable.rb b/app/models/concerns/spammable.rb index 9cd1a22b203..2daea388939 100644 --- a/app/models/concerns/spammable.rb +++ b/app/models/concerns/spammable.rb @@ -45,6 +45,17 @@ module Spammable self.needs_recaptcha = true end + ## + # Indicates if a recaptcha should be rendered before allowing this model to be saved. + # + def render_recaptcha? + return false unless Gitlab::Recaptcha.enabled? + + return false if self.errors.count > 1 # captcha should not be rendered if are still other errors + + self.needs_recaptcha? + end + def spam! self.spam = true end |