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

forward_event_worker.rb « jira_connect « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 14922db5420844f62815e94a5d054ac3029a1d2a (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 JiraConnect
  class ForwardEventWorker # rubocop:disable Scalability/IdempotentWorker
    include ApplicationWorker

    data_consistency :always
    queue_namespace :jira_connect
    feature_category :integrations
    urgency :low

    worker_has_external_dependencies!

    def perform(installation_id, base_path, event_path)
      installation = JiraConnectInstallation.find_by_id(installation_id)
      instance_url = installation&.instance_url

      installation.destroy if installation

      return if instance_url.nil?

      proxy_url = instance_url + event_path
      qsh = Atlassian::Jwt.create_query_string_hash(proxy_url, 'POST', instance_url + base_path)
      jwt = Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret)

      JiraConnect::RetryRequestWorker.perform_async(proxy_url, jwt)
    end
  end
end