2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
# SpamCheckMethods
|
2017-08-17 22:00:37 +05:30
|
|
|
#
|
|
|
|
# Provide helper methods for checking if a given spammable object has
|
|
|
|
# potential spam data.
|
|
|
|
#
|
|
|
|
# Dependencies:
|
|
|
|
# - params with :request
|
2020-03-09 13:42:32 +05:30
|
|
|
|
|
|
|
module SpamCheckMethods
|
2018-03-17 18:26:18 +05:30
|
|
|
# rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-08-17 22:00:37 +05:30
|
|
|
def filter_spam_check_params
|
|
|
|
@request = params.delete(:request)
|
|
|
|
@api = params.delete(:api)
|
|
|
|
@recaptcha_verified = params.delete(:recaptcha_verified)
|
|
|
|
@spam_log_id = params.delete(:spam_log_id)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
# rubocop:enable Gitlab/ModuleWithInstanceVariables
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
# In order to be proceed to the spam check process, @spammable has to be
|
|
|
|
# a dirty instance, which means it should be already assigned with the new
|
|
|
|
# attribute values.
|
2018-03-17 18:26:18 +05:30
|
|
|
# rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-08-17 22:00:37 +05:30
|
|
|
def spam_check(spammable, user)
|
2020-03-09 13:42:32 +05:30
|
|
|
Spam::SpamCheckService.new(
|
|
|
|
spammable: spammable,
|
|
|
|
request: @request
|
|
|
|
).execute(
|
|
|
|
api: @api,
|
|
|
|
recaptcha_verified: @recaptcha_verified,
|
|
|
|
spam_log_id: @spam_log_id,
|
|
|
|
user_id: user.id)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
# rubocop:enable Gitlab/ModuleWithInstanceVariables
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|