Class: SpamCheck
- Inherits:
-
BaseService
- Object
- BaseService
- SpamCheck
- Defined in:
- app/services/spam_check.rb
Overview
Service class for checking if a submission is from a known fraudulent customer
Uses contact point validation to detect repeat fraud attempts.
Note: Akismet integration was removed - Cloudflare Turnstile now handles bot protection.
This service focuses on detecting submissions from previously-flagged fraudulent customers.
Instance Attribute Summary collapse
-
#spam_results ⇒ Object
readonly
Returns the value of attribute spam_results.
Attributes inherited from BaseService
Instance Method Summary collapse
- #process(author_email: nil, phone_number: nil, current_user: nil, request_id: nil, request: nil, **_ignored) ⇒ Object
- #spam_results_to_s ⇒ Object
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Attribute Details
#spam_results ⇒ Object (readonly)
Returns the value of attribute spam_results.
8 9 10 |
# File 'app/services/spam_check.rb', line 8 def spam_results @spam_results end |
Instance Method Details
#process(author_email: nil, phone_number: nil, current_user: nil, request_id: nil, request: nil, **_ignored) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/services/spam_check.rb', line 10 def process(author_email: nil, phone_number: nil, current_user: nil, request_id: nil, request: nil, **_ignored) # Accept but ignore legacy params (remote_ip, user_agent, text, etc.) current_user ||= CurrentScope.user request_id ||= request&.request_id is_spam = false decision_reason = nil existing_customer = current_user&.customer&.customer? phone_number = PhoneNumber.parse_and_format(phone_number) if phone_number.present? = nil unless .present? && Truemail.valid?() # Known spam email domain if &.ends_with?('@storebotmail.joonix.net') is_spam = true decision_reason = 'Known spam email domain' end # Check if contact points match a known fraudulent customer _existing_customer, is_spam, decision_reason = check_contact_points(phone_number, ) unless existing_customer || is_spam @spam_results = { is_spam: is_spam, author_email: , phone_number: phone_number, current_user_id: current_user&.id, request_id: request_id, decision_reason: decision_reason } log_spam_result(is_spam, request_id) is_spam end |
#spam_results_to_s ⇒ Object
49 50 51 |
# File 'app/services/spam_check.rb', line 49 def spam_results_to_s (@spam_results || {}).map { |k, v| "#{k}: #{v}" }.join("\n") end |