Class: Spam::SpamActionService

Inherits:
Object
  • Object
show all
Includes:
SpamConstants
Defined in:
app/services/spam/spam_action_service.rb

Constant Summary

Constants included from SpamConstants

Spam::SpamConstants::ALLOW, Spam::SpamConstants::BLOCK_USER, Spam::SpamConstants::CONDITIONAL_ALLOW, Spam::SpamConstants::DISALLOW, Spam::SpamConstants::ERROR_TYPE, Spam::SpamConstants::NOOP, Spam::SpamConstants::OVERRIDE_VIA_ALLOW_POSSIBLE_SPAM, Spam::SpamConstants::SUPPORTED_VERDICTS

Instance Method Summary collapse

Constructor Details

#initialize(spammable:, user:, action:, extra_features: {}) ⇒ SpamActionService

Returns a new instance of SpamActionService.



7
8
9
10
11
12
# File 'app/services/spam/spam_action_service.rb', line 7

def initialize(spammable:, user:, action:, extra_features: {})
  @target = spammable
  @user = user
  @action = action
  @extra_features = extra_features
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
# File 'app/services/spam/spam_action_service.rb', line 14

def execute
  return ServiceResponse.success(message: 'Skipped spam check because user was not present') unless user

  if target.supports_recaptcha? && spam_params
    execute_with_captcha_support
  else
    execute_spam_check
  end
end