summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/all_queues.yml9
-rw-r--r--app/workers/jira_connect/forward_event_worker.rb25
2 files changed, 34 insertions, 0 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 61edd4b91e3..aaa6edcd0cf 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -1078,6 +1078,15 @@
:weight: 2
:idempotent: true
:tags: []
+- :name: jira_connect:jira_connect_forward_event
+ :worker_name: JiraConnect::ForwardEventWorker
+ :feature_category: :integrations
+ :has_external_dependencies: true
+ :urgency: :low
+ :resource_boundary: :unknown
+ :weight: 1
+ :idempotent:
+ :tags: []
- :name: jira_connect:jira_connect_sync_branch
:worker_name: JiraConnect::SyncBranchWorker
:feature_category: :integrations
diff --git a/app/workers/jira_connect/forward_event_worker.rb b/app/workers/jira_connect/forward_event_worker.rb
new file mode 100644
index 00000000000..877ab46cfe5
--- /dev/null
+++ b/app/workers/jira_connect/forward_event_worker.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module JiraConnect
+ class ForwardEventWorker # rubocop:disable Scalability/IdempotentWorker
+ include ApplicationWorker
+
+ queue_namespace :jira_connect
+ feature_category :integrations
+ worker_has_external_dependencies!
+
+ def perform(installation_id, base_path, event_path)
+ installation = JiraConnectInstallation.find_by_id(installation_id)
+
+ return if installation&.instance_url.nil?
+
+ proxy_url = installation.instance_url + event_path
+ qsh = Atlassian::Jwt.create_query_string_hash(proxy_url, 'POST', installation.instance_url + base_path)
+ jwt = Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret)
+
+ Gitlab::HTTP.post(proxy_url, headers: { 'Authorization' => "JWT #{jwt}" })
+ ensure
+ installation.destroy if installation
+ end
+ end
+end