summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/concerns/mutations/spam_protection.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/concerns/mutations/spam_protection.rb')
-rw-r--r--app/graphql/mutations/concerns/mutations/spam_protection.rb26
1 files changed, 6 insertions, 20 deletions
diff --git a/app/graphql/mutations/concerns/mutations/spam_protection.rb b/app/graphql/mutations/concerns/mutations/spam_protection.rb
index 341067710b2..e61f66c02a5 100644
--- a/app/graphql/mutations/concerns/mutations/spam_protection.rb
+++ b/app/graphql/mutations/concerns/mutations/spam_protection.rb
@@ -16,30 +16,16 @@ module Mutations
private
- def spam_action_response(object)
- fields = spam_action_response_fields(object)
-
- # If the SpamActionService detected something as spam,
- # this is non-recoverable and the needs_captcha_response
- # should not be considered
- kind = if fields[:spam]
- :spam
- elsif fields[:needs_captcha_response]
- :needs_captcha_response
- end
-
- [kind, fields]
- end
-
def check_spam_action_response!(object)
- kind, fields = spam_action_response(object)
+ fields = spam_action_response_fields(object)
- case kind
- when :needs_captcha_response
+ if fields[:spam]
+ # If the SpamActionService detected something as spam, this is non-recoverable and the
+ # needs_captcha_response and other CAPTCHA-related fields should not be returned
+ raise SpamDisallowedError.new(SPAM_DISALLOWED_MESSAGE, extensions: { spam: true })
+ elsif fields[:needs_captcha_response]
fields.delete :spam
raise NeedsCaptchaResponseError.new(NEEDS_CAPTCHA_RESPONSE_MESSAGE, extensions: fields)
- when :spam
- raise SpamDisallowedError.new(SPAM_DISALLOWED_MESSAGE, extensions: { spam: true })
else
nil
end