summaryrefslogtreecommitdiff
path: root/app/services/spam/spam_params.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/spam/spam_params.rb')
-rw-r--r--app/services/spam/spam_params.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/services/spam/spam_params.rb b/app/services/spam/spam_params.rb
new file mode 100644
index 00000000000..fef5355c7f3
--- /dev/null
+++ b/app/services/spam/spam_params.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Spam
+ ##
+ # This class is a Parameter Object (https://refactoring.com/catalog/introduceParameterObject.html)
+ # which acts as an container abstraction for multiple parameter values related to spam and
+ # captcha processing for a request.
+ #
+ # Values contained are:
+ #
+ # api: A boolean flag indicating if the request was submitted via the REST or GraphQL API
+ # captcha_response: The response resulting from the user solving a captcha. Currently it is
+ # a scalar reCAPTCHA response string, but it can be expanded to an object in the future to
+ # support other captcha implementations such as FriendlyCaptcha.
+ # spam_log_id: The id of a SpamLog record.
+ class SpamParams
+ attr_reader :api, :captcha_response, :spam_log_id
+
+ def initialize(api:, captcha_response:, spam_log_id:)
+ @api = api.present?
+ @captcha_response = captcha_response
+ @spam_log_id = spam_log_id
+ end
+
+ def ==(other)
+ other.class == self.class &&
+ other.api == self.api &&
+ other.captcha_response == self.captcha_response &&
+ other.spam_log_id == self.spam_log_id
+ end
+ end
+end