diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 12:09:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-12 12:09:11 +0300 |
commit | 0388886f9439fa93efea29a159522aec5643f7c8 (patch) | |
tree | 9a4b2305088e62a9745ce598b45aa34e39e59642 /app | |
parent | 8c9dc985b90c353b33cb829caf51f8320171bc15 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/boards/mixins/sortable_default_options.js | 1 | ||||
-rw-r--r-- | app/controllers/concerns/spammable_actions.rb | 4 | ||||
-rw-r--r-- | app/graphql/mutations/snippets/mark_as_spam.rb | 2 | ||||
-rw-r--r-- | app/services/concerns/akismet_methods.rb | 10 | ||||
-rw-r--r-- | app/services/concerns/spam_check_methods.rb | 6 | ||||
-rw-r--r-- | app/services/spam/ham_service.rb | 16 | ||||
-rw-r--r-- | app/services/spam/mark_as_spam_service.rb | 14 | ||||
-rw-r--r-- | app/services/spam/spam_check_service.rb | 26 |
8 files changed, 39 insertions, 40 deletions
diff --git a/app/assets/javascripts/boards/mixins/sortable_default_options.js b/app/assets/javascripts/boards/mixins/sortable_default_options.js index 68ea28e68d9..f77f131c71a 100644 --- a/app/assets/javascripts/boards/mixins/sortable_default_options.js +++ b/app/assets/javascripts/boards/mixins/sortable_default_options.js @@ -26,6 +26,7 @@ export function getBoardSortableDefaultOptions(obj) { scrollSpeed: 20, onStart: sortableStart, onEnd: sortableEnd, + fallbackTolerance: 1, }); Object.keys(obj).forEach(key => { diff --git a/app/controllers/concerns/spammable_actions.rb b/app/controllers/concerns/spammable_actions.rb index 9ec8f930a78..e9bba904dab 100644 --- a/app/controllers/concerns/spammable_actions.rb +++ b/app/controllers/concerns/spammable_actions.rb @@ -11,7 +11,7 @@ module SpammableActions end def mark_as_spam - if Spam::MarkAsSpamService.new(spammable: spammable).execute + if Spam::MarkAsSpamService.new(target: spammable).execute redirect_to spammable_path, notice: _("%{spammable_titlecase} was submitted to Akismet successfully.") % { spammable_titlecase: spammable.spammable_entity_type.titlecase } else redirect_to spammable_path, alert: _('Error with Akismet. Please check the logs for more info.') @@ -42,7 +42,7 @@ module SpammableActions end format.json do - locals = { spammable: spammable, script: false, has_submit: false } + locals = { target: spammable, script: false, has_submit: false } recaptcha_html = render_to_string(partial: 'shared/recaptcha_form', formats: :html, locals: locals) render json: { recaptcha_html: recaptcha_html } diff --git a/app/graphql/mutations/snippets/mark_as_spam.rb b/app/graphql/mutations/snippets/mark_as_spam.rb index 8cfbbae7c08..3171f4645ca 100644 --- a/app/graphql/mutations/snippets/mark_as_spam.rb +++ b/app/graphql/mutations/snippets/mark_as_spam.rb @@ -24,7 +24,7 @@ module Mutations private def mark_as_spam(snippet) - Spam::MarkAsSpamService.new(spammable: snippet).execute + Spam::MarkAsSpamService.new(target: snippet).execute end def authorized_resource?(snippet) diff --git a/app/services/concerns/akismet_methods.rb b/app/services/concerns/akismet_methods.rb index 105b79785bd..4e554ddac4c 100644 --- a/app/services/concerns/akismet_methods.rb +++ b/app/services/concerns/akismet_methods.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true module AkismetMethods - def spammable_owner - @user ||= User.find(spammable.author_id) + def target_owner + @user ||= User.find(target.author_id) end def akismet @akismet ||= Spam::AkismetService.new( - spammable_owner.name, - spammable_owner.email, - spammable.try(:spammable_text) || spammable&.text, + target_owner.name, + target_owner.email, + target.try(:spammable_text) || target&.text, options ) end diff --git a/app/services/concerns/spam_check_methods.rb b/app/services/concerns/spam_check_methods.rb index 695bdf92b49..62836881099 100644 --- a/app/services/concerns/spam_check_methods.rb +++ b/app/services/concerns/spam_check_methods.rb @@ -2,7 +2,7 @@ # SpamCheckMethods # -# Provide helper methods for checking if a given spammable object has +# Provide helper methods for checking if a given target spammable object has # potential spam data. # # Dependencies: @@ -18,13 +18,13 @@ module SpamCheckMethods end # rubocop:enable Gitlab/ModuleWithInstanceVariables - # In order to be proceed to the spam check process, @spammable has to be + # In order to be proceed to the spam check process, @target has to be # a dirty instance, which means it should be already assigned with the new # attribute values. # rubocop:disable Gitlab/ModuleWithInstanceVariables def spam_check(spammable, user) Spam::SpamCheckService.new( - spammable: spammable, + target: spammable, request: @request ).execute( api: @api, diff --git a/app/services/spam/ham_service.rb b/app/services/spam/ham_service.rb index d0f53eea90c..cedb9f02f3d 100644 --- a/app/services/spam/ham_service.rb +++ b/app/services/spam/ham_service.rb @@ -4,25 +4,23 @@ module Spam class HamService include AkismetMethods - attr_accessor :spam_log, :options + attr_accessor :target, :options - def initialize(spam_log) - @spam_log = spam_log - @user = spam_log.user + def initialize(target) + @target = target + @user = target.user @options = { - ip_address: spam_log.source_ip, - user_agent: spam_log.user_agent + ip_address: target.source_ip, + user_agent: target.user_agent } end def execute if akismet.submit_ham - spam_log.update_attribute(:submitted_as_ham, true) + target.update_attribute(:submitted_as_ham, true) else false end end - - alias_method :spammable, :spam_log end end diff --git a/app/services/spam/mark_as_spam_service.rb b/app/services/spam/mark_as_spam_service.rb index 0ebcf17927a..ed5e674d8e9 100644 --- a/app/services/spam/mark_as_spam_service.rb +++ b/app/services/spam/mark_as_spam_service.rb @@ -4,21 +4,21 @@ module Spam class MarkAsSpamService include ::AkismetMethods - attr_accessor :spammable, :options + attr_accessor :target, :options - def initialize(spammable:) - @spammable = spammable + def initialize(target:) + @target = target @options = {} - @options[:ip_address] = @spammable.ip_address - @options[:user_agent] = @spammable.user_agent + @options[:ip_address] = @target.ip_address + @options[:user_agent] = @target.user_agent end def execute - return unless spammable.submittable_as_spam? + return unless target.submittable_as_spam? return unless akismet.submit_spam - spammable.user_agent_detail.update_attribute(:submitted, true) + target.user_agent_detail.update_attribute(:submitted, true) end end end diff --git a/app/services/spam/spam_check_service.rb b/app/services/spam/spam_check_service.rb index d19ef03976f..a922b0d96e7 100644 --- a/app/services/spam/spam_check_service.rb +++ b/app/services/spam/spam_check_service.rb @@ -4,11 +4,11 @@ module Spam class SpamCheckService include AkismetMethods - attr_accessor :spammable, :request, :options + attr_accessor :target, :request, :options attr_reader :spam_log - def initialize(spammable:, request:) - @spammable = spammable + def initialize(target:, request:) + @target = target @request = request @options = {} @@ -17,8 +17,8 @@ module Spam @options[:user_agent] = @request.env['HTTP_USER_AGENT'] @options[:referrer] = @request.env['HTTP_REFERRER'] else - @options[:ip_address] = @spammable.ip_address - @options[:user_agent] = @spammable.user_agent + @options[:ip_address] = @target.ip_address + @options[:user_agent] = @target.user_agent end end @@ -29,10 +29,10 @@ module Spam SpamLog.verify_recaptcha!(user_id: user_id, id: spam_log_id) else # Otherwise, it goes to Akismet for spam check. - # If so, it assigns spammable object as "spam" and creates a SpamLog record. + # If so, it assigns target spammable object as "spam" and creates a SpamLog record. possible_spam = check(api) - spammable.spam = possible_spam unless spammable.allow_possible_spam? - spammable.spam_log = spam_log + target.spam = possible_spam unless target.allow_possible_spam? + target.spam_log = spam_log end end @@ -48,18 +48,18 @@ module Spam end def check_for_spam? - spammable.check_for_spam? + target.check_for_spam? end def create_spam_log(api) @spam_log = SpamLog.create!( { - user_id: spammable.author_id, - title: spammable.spam_title, - description: spammable.spam_description, + user_id: target.author_id, + title: target.spam_title, + description: target.spam_description, source_ip: options[:ip_address], user_agent: options[:user_agent], - noteable_type: spammable.class.to_s, + noteable_type: target.class.to_s, via_api: api } ) |