2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-04-30 08:12:30 -04:00
|
|
|
# Worker cannot be idempotent: https://gitlab.com/gitlab-org/gitlab/-/issues/218559
|
|
|
|
# rubocop:disable Scalability/IdempotentWorker
|
|
|
|
class WebHookWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2013-01-24 15:15:24 -05:00
|
|
|
|
2019-10-18 07:11:44 -04:00
|
|
|
feature_category :integrations
|
2022-01-28 10:14:45 -05:00
|
|
|
loggable_arguments 2, 3
|
2021-06-16 14:10:35 -04:00
|
|
|
data_consistency :delayed
|
2017-07-17 11:38:02 -04:00
|
|
|
sidekiq_options retry: 4, dead: false
|
2021-07-26 14:09:51 -04:00
|
|
|
urgency :low
|
|
|
|
|
|
|
|
worker_has_external_dependencies!
|
2013-01-24 15:15:24 -05:00
|
|
|
|
2022-01-11 01:10:58 -05:00
|
|
|
def perform(hook_id, data, hook_name, params = {})
|
2021-08-10 05:10:08 -04:00
|
|
|
hook = WebHook.find_by_id(hook_id)
|
|
|
|
return unless hook
|
2017-04-27 06:08:57 -04:00
|
|
|
|
2021-08-10 05:10:08 -04:00
|
|
|
data = data.with_indifferent_access
|
2022-01-28 10:14:45 -05:00
|
|
|
params.symbolize_keys!
|
2022-01-11 01:10:58 -05:00
|
|
|
|
2022-01-28 10:14:45 -05: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 01:10:58 -05:00
|
|
|
|
2021-06-09 05:10:18 -04:00
|
|
|
WebHookService.new(hook, data, hook_name, jid).execute
|
2013-01-24 15:15:24 -05:00
|
|
|
end
|
|
|
|
end
|
2021-04-30 08:12:30 -04:00
|
|
|
# rubocop:enable Scalability/IdempotentWorker
|