summaryrefslogtreecommitdiff
path: root/app/services/issues/update_service.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /app/services/issues/update_service.rb
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/services/issues/update_service.rb')
-rw-r--r--app/services/issues/update_service.rb26
1 files changed, 20 insertions, 6 deletions
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index cf2892bf413..9ede5ef728b 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -4,12 +4,17 @@ module Issues
class UpdateService < Issues::BaseService
extend ::Gitlab::Utils::Override
+ # NOTE: For Issues::UpdateService, we default the spam_params to nil, because spam_checking is not
+ # necessary in many cases, and we don't want to require every caller to explicitly pass it as nil
+ # to disable spam checking.
+ def initialize(project:, current_user: nil, params: {}, spam_params: nil)
+ super(project: project, current_user: current_user, params: params)
+ @spam_params = spam_params
+ end
+
def execute(issue)
handle_move_between_ids(issue)
- @request = params.delete(:request)
- @spam_params = Spam::SpamActionService.filter_spam_params!(params, @request)
-
change_issue_duplicate(issue)
move_issue_to_new_project(issue) || clone_issue(issue) || update_task_event(issue) || update(issue)
end
@@ -25,10 +30,10 @@ module Issues
Spam::SpamActionService.new(
spammable: issue,
- request: request,
+ spam_params: spam_params,
user: current_user,
action: :update
- ).execute(spam_params: spam_params)
+ ).execute
end
def handle_changes(issue, options)
@@ -37,6 +42,7 @@ module Issues
old_labels = old_associations.fetch(:labels, [])
old_mentioned_users = old_associations.fetch(:mentioned_users, [])
old_assignees = old_associations.fetch(:assignees, [])
+ old_severity = old_associations[:severity]
if has_changes?(issue, old_labels: old_labels, old_assignees: old_assignees)
todo_service.resolve_todos_for_target(issue, current_user)
@@ -69,6 +75,8 @@ module Issues
if added_mentions.present?
notification_service.async.new_mentions_in_issue(issue, added_mentions, current_user)
end
+
+ handle_severity_change(issue, old_severity)
end
def handle_assignee_changes(issue, old_assignees)
@@ -127,7 +135,7 @@ module Issues
private
- attr_reader :request, :spam_params
+ attr_reader :spam_params
def clone_issue(issue)
target_project = params.delete(:target_clone_project)
@@ -176,6 +184,12 @@ module Issues
end
end
+ def handle_severity_change(issue, old_severity)
+ return unless old_severity && issue.severity != old_severity
+
+ ::IncidentManagement::AddSeveritySystemNoteWorker.perform_async(issue.id, current_user.id)
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
def issuable_for_positioning(id, board_group_id = nil)
return unless id