Commit bd1739c5 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'cablett-spam-refactor' into 'master'

Refactor spammable object

See merge request gitlab-org/gitlab!28528
parents a0230b4c c929587b
...@@ -37,15 +37,23 @@ module Spammable ...@@ -37,15 +37,23 @@ module Spammable
end end
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 def invalidate_if_spam
error_msg = if Gitlab::Recaptcha.enabled? return unless spam?
"Your #{spammable_entity_type} has been recognized as spam. "\
"Please, change the content or solve the reCAPTCHA to proceed." if Gitlab::Recaptcha.enabled?
else needs_recaptcha!
"Your #{spammable_entity_type} has been recognized as spam and has been discarded." else
end unrecoverable_spam_error!
end
self.errors.add(:base, error_msg) if spam?
end end
def spammable_entity_type def spammable_entity_type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment