diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 09:09:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 09:09:13 +0000 |
commit | 41cb558299b483b44b45351730ee4c0e9fe4ca2c (patch) | |
tree | 00688a9e40021c66195ad826ceddd9c19385cdcf /app/models | |
parent | 3d064c737e8448880e6180aeddc59000a01aa6a8 (diff) | |
download | gitlab-ce-41cb558299b483b44b45351730ee4c0e9fe4ca2c.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/spammable.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/app/models/concerns/spammable.rb b/app/models/concerns/spammable.rb index 7c12fe29ade..4fbb5dcb649 100644 --- a/app/models/concerns/spammable.rb +++ b/app/models/concerns/spammable.rb @@ -37,15 +37,23 @@ module Spammable end end + def needs_recaptcha! + self.errors.add(:base, "Your #{spammable_entity_type} has been recognized as spam. "\ + "Please, change the content or solve the reCAPTCHA to proceed.") + end + + def unrecoverable_spam_error! + self.errors.add(:base, "Your #{spammable_entity_type} has been recognized as spam and has been discarded.") + end + def invalidate_if_spam - error_msg = if Gitlab::Recaptcha.enabled? - "Your #{spammable_entity_type} has been recognized as spam. "\ - "Please, change the content or solve the reCAPTCHA to proceed." - else - "Your #{spammable_entity_type} has been recognized as spam and has been discarded." - end - - self.errors.add(:base, error_msg) if spam? + return unless spam? + + if Gitlab::Recaptcha.enabled? + needs_recaptcha! + else + unrecoverable_spam_error! + end end def spammable_entity_type |