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

pager_duty_incidents_controller.rb « incident_management « projects « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f1264ca4a45475dd6b8673863cc935ac7261ff3c (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
33
34
35
36
37
# frozen_string_literal: true

module Projects
  module IncidentManagement
    class PagerDutyIncidentsController < Projects::ApplicationController
      respond_to :json

      skip_before_action :verify_authenticity_token
      skip_before_action :project

      prepend_before_action :project_without_auth

      feature_category :incident_management

      def create
        result = webhook_processor.execute(params[:token])

        head result.http_status
      end

      private

      def project_without_auth
        @project ||= Project
          .find_by_full_path("#{params[:namespace_id]}/#{params[:project_id]}")
      end

      def webhook_processor
        ::IncidentManagement::PagerDuty::ProcessWebhookService.new(project, nil, payload)
      end

      def payload
        @payload ||= params.permit![:pager_duty_incident].to_h
      end
    end
  end
end