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
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
......
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