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

incident_service.rb « system_notes « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4628662f0e998c6b37ef4639ce55ad8e3aeb484c (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
29
# frozen_string_literal: true

module SystemNotes
  class IncidentService < ::SystemNotes::BaseService
    # Called when the severity of an Incident has changed
    #
    # Example Note text:
    #
    #   "changed the severity to Medium - S3"
    #
    # Returns the created Note object
    def change_incident_severity
      severity = noteable.severity

      if severity_label = IssuableSeverity::SEVERITY_LABELS[severity.to_sym]
        body = "changed the severity to **#{severity_label}**"

        create_note(NoteSummary.new(noteable, project, author, body, action: 'severity'))
      else
        Gitlab::AppLogger.error(
          message: 'Cannot create a system note for severity change',
          noteable_class: noteable.class.to_s,
          noteable_id: noteable.id,
          severity: severity
        )
      end
    end
  end
end