2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-04-30 12:12:30 +00:00
|
|
|
# Worker cannot be idempotent: https://gitlab.com/gitlab-org/gitlab/-/issues/218559
|
|
|
|
# rubocop:disable Scalability/IdempotentWorker
|
|
|
|
class WebHookWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2013-01-24 20:15:24 +00:00
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category :integrations
|
2022-01-28 15:14:45 +00:00
|
|
|
loggable_arguments 2, 3
|
2021-06-16 18:10:35 +00:00
|
|
|
data_consistency :delayed
|
2017-07-17 15:38:02 +00:00
|
|
|
sidekiq_options retry: 4, dead: false
|
2021-07-26 18:09:51 +00:00
|
|
|
urgency :low
|
|
|
|
|
|
|
|
worker_has_external_dependencies!
|
2013-01-24 20:15:24 +00:00
|
|
|
|
2022-01-11 06:10:58 +00:00
|
|
|
def perform(hook_id, data, hook_name, params = {})
|
2021-08-10 09:10:08 +00:00
|
|
|
hook = WebHook.find_by_id(hook_id)
|
|
|
|
return unless hook
|
2017-04-27 10:08:57 +00:00
|
|
|
|
2021-08-10 09:10:08 +00:00
|
|
|
data = data.with_indifferent_access
|
2022-01-28 15:14:45 +00:00
|
|
|
params.symbolize_keys!
|
2022-01-11 06:10:58 +00:00
|
|
|
|
2022-01-28 15:14:45 +00:00
|
|
|
# Before executing the hook, reapply any recursion detection UUID that was initially
|
|
|
|
# present in the request header so the hook can pass this same header value in its request.
|
|
|
|
Gitlab::WebHooks::RecursionDetection.set_request_uuid(params[:recursion_detection_request_uuid])
|
2022-01-11 06:10:58 +00:00
|
|
|
|
2021-06-09 09:10:18 +00:00
|
|
|
WebHookService.new(hook, data, hook_name, jid).execute
|
2013-01-24 20:15:24 +00:00
|
|
|
end
|
|
|
|
end
|
2021-04-30 12:12:30 +00:00
|
|
|
# rubocop:enable Scalability/IdempotentWorker
|