blob: 54c6c7ea71bcd07bf0eb7e988faa1fee2d9e8055 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# frozen_string_literal: true
module WebHooks
class DestroyService
attr_accessor :current_user
def initialize(current_user)
@current_user = current_user
end
# Destroy the hook immediately, schedule the logs for deletion
def execute(web_hook)
hook_id = web_hook.id
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}")
ServiceResponse.success(payload: { async: false })
else
ServiceResponse.error(message: "Unable to destroy #{web_hook.model_name.human}")
end
end
end
end
|