2021-09-30 23:02:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module JiraConnect
|
|
|
|
class ForwardEventWorker # rubocop:disable Scalability/IdempotentWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
data_consistency :always
|
2021-09-30 23:02:18 +05:30
|
|
|
queue_namespace :jira_connect
|
|
|
|
feature_category :integrations
|
2021-10-27 15:23:28 +05:30
|
|
|
urgency :low
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
worker_has_external_dependencies!
|
|
|
|
|
|
|
|
def perform(installation_id, base_path, event_path)
|
|
|
|
installation = JiraConnectInstallation.find_by_id(installation_id)
|
2021-10-27 15:23:28 +05:30
|
|
|
instance_url = installation&.instance_url
|
|
|
|
|
|
|
|
installation.destroy if installation
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
return if instance_url.nil?
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
proxy_url = instance_url + event_path
|
|
|
|
qsh = Atlassian::Jwt.create_query_string_hash(proxy_url, 'POST', instance_url + base_path)
|
2021-09-30 23:02:18 +05:30
|
|
|
jwt = Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret)
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
JiraConnect::RetryRequestWorker.perform_async(proxy_url, jwt)
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|