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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/incident_management/issuable_escalation_statuses/after_update_service.rb')
-rw-r--r--app/services/incident_management/issuable_escalation_statuses/after_update_service.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/app/services/incident_management/issuable_escalation_statuses/after_update_service.rb b/app/services/incident_management/issuable_escalation_statuses/after_update_service.rb
new file mode 100644
index 00000000000..a7a99f88b32
--- /dev/null
+++ b/app/services/incident_management/issuable_escalation_statuses/after_update_service.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+module IncidentManagement
+ module IssuableEscalationStatuses
+ class AfterUpdateService < ::BaseProjectService
+ def initialize(issuable, current_user)
+ @issuable = issuable
+ @escalation_status = issuable.escalation_status
+ @alert = issuable.alert_management_alert
+
+ super(project: issuable.project, current_user: current_user)
+ end
+
+ def execute
+ after_update
+
+ ServiceResponse.success(payload: { escalation_status: escalation_status })
+ end
+
+ private
+
+ attr_reader :issuable, :escalation_status, :alert
+
+ def after_update
+ sync_to_alert
+ end
+
+ def sync_to_alert
+ return unless alert
+ return if alert.status == escalation_status.status
+
+ ::AlertManagement::Alerts::UpdateService.new(
+ alert,
+ current_user,
+ status: escalation_status.status_name
+ ).execute
+ end
+ end
+ end
+end
+
+::IncidentManagement::IssuableEscalationStatuses::AfterUpdateService.prepend_mod