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

destroy_service.rb « link_alerts « incident_management « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: baeedaf74b648d9e12c776a5a73537e1c791f64b (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
30
# frozen_string_literal: true

module IncidentManagement
  module LinkAlerts
    class DestroyService < BaseService
      # @param incident [Issue] an incident to unlink alert from
      # @param current_user [User]
      # @param alert [AlertManagement::Alert] an alert to unlink from the incident
      def initialize(incident, current_user, alert)
        @incident = incident
        @current_user = current_user
        @alert = alert

        super(project: incident.project, current_user: current_user)
      end

      def execute
        return error_no_permissions unless allowed?

        incident.alert_management_alerts.delete(alert)

        success
      end

      private

      attr_reader :alert
    end
  end
end