Welcome to mirror list, hosted at ThFree Co, Russian Federation.

spam_check_service.rb « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6768047aa63d5656318ed9209c00d14c7a3d5cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class SpamCheckService
  include Gitlab::AkismetHelper

  attr_accessor :subject, :current_user, :params

  def initialize(subject, user, params = {})
    @subject, @current_user, @params = subject, user, params.dup
  end

  def spam_detected?
    request = params[:request]
    return false unless request || check_for_spam?(subject)

    text = [params[:title], params[:description]].reject(&:blank?).join("\n")

    return false unless is_spam?(request.env, current_user, text)

    attrs = {
      user_id: current_user.id,
      project_id: subject.id,
      title: params[:title],
      description: params[:description]
    }
    create_spam_log(subject, current_user, attrs, request.env, api: false)

    true
  end
end