debian-mirror-gitlab/app/services/web_hooks/destroy_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
702 B
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
module WebHooks
class DestroyService
2022-07-23 23:45:48 +05:30
attr_accessor :current_user
2021-01-03 14:25:43 +05:30
def initialize(current_user)
@current_user = current_user
end
2022-07-23 23:45:48 +05:30
# Destroy the hook immediately, schedule the logs for deletion
2021-01-03 14:25:43 +05:30
def execute(web_hook)
2022-07-23 23:45:48 +05:30
hook_id = web_hook.id
2021-01-03 14:25:43 +05:30
2022-07-23 23:45:48 +05:30
if web_hook.destroy
WebHooks::LogDestroyWorker.perform_async({ 'hook_id' => hook_id })
Gitlab::AppLogger.info("User #{current_user&.id} scheduled a deletion of logs for hook ID #{hook_id}")
2021-01-03 14:25:43 +05:30
2022-07-23 23:45:48 +05:30
ServiceResponse.success(payload: { async: false })
2021-01-03 14:25:43 +05:30
else
2022-07-23 23:45:48 +05:30
ServiceResponse.error(message: "Unable to destroy #{web_hook.model_name.human}")
2021-01-03 14:25:43 +05:30
end
end
end
end