2020-10-07 05:09:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module WebHooks
|
|
|
|
class DestroyWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-04-30 14:10:09 -04:00
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2020-10-07 05:09:13 -04:00
|
|
|
feature_category :integrations
|
2021-05-03 05:10:02 -04:00
|
|
|
tags :exclude_from_kubernetes
|
2020-10-07 05:09:13 -04:00
|
|
|
urgency :low
|
|
|
|
idempotent!
|
|
|
|
|
|
|
|
def perform(user_id, web_hook_id)
|
|
|
|
user = User.find_by_id(user_id)
|
|
|
|
hook = WebHook.find_by_id(web_hook_id)
|
|
|
|
|
|
|
|
return unless user && hook
|
|
|
|
|
|
|
|
result = ::WebHooks::DestroyService.new(user).sync_destroy(hook)
|
|
|
|
|
|
|
|
return result if result[:status] == :success
|
|
|
|
|
|
|
|
e = ::WebHooks::DestroyService::DestroyError.new(result[:message])
|
|
|
|
Gitlab::ErrorTracking.track_exception(e, web_hook_id: hook.id)
|
|
|
|
|
|
|
|
raise e
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|