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

create.rb « todo « alerts « alert_management « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 999c0bec5af2c7f2c7f827eeab3cb89ae1b403e1 (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
31
32
# frozen_string_literal: true

module Mutations
  module AlertManagement
    module Alerts
      module Todo
        class Create < Base
          graphql_name 'AlertTodoCreate'

          def resolve(args)
            alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
            result = ::AlertManagement::Alerts::Todo::CreateService.new(alert, current_user).execute

            track_alert_events('incident_management_alert_todo', alert)

            prepare_response(result)
          end

          private

          def prepare_response(result)
            {
              alert: result.payload[:alert],
              todo: result.payload[:todo],
              errors: result.error? ? [result.message] : []
            }
          end
        end
      end
    end
  end
end