diff options
Diffstat (limited to 'app/workers/web_hooks/destroy_worker.rb')
-rw-r--r-- | app/workers/web_hooks/destroy_worker.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/workers/web_hooks/destroy_worker.rb b/app/workers/web_hooks/destroy_worker.rb new file mode 100644 index 00000000000..13a5a7bf1e6 --- /dev/null +++ b/app/workers/web_hooks/destroy_worker.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module WebHooks + class DestroyWorker + include ApplicationWorker + + feature_category :integrations + 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 |