File: hook_log_actions.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (48 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

module WebHooks
  module HookLogActions
    extend ActiveSupport::Concern
    include HookExecutionNotice

    included do
      before_action :hook, only: [:show, :retry]
      before_action :hook_log, only: [:show, :retry]

      respond_to :html

      feature_category :webhooks
      urgency :low, [:retry]
    end

    def show
      hide_search_settings
    end

    def retry
      result = execute_hook
      if result.success?
        redirect_to after_retry_redirect_path
      else
        flash[:warning] = result.message
        redirect_back(fallback_location: after_retry_redirect_path)
      end
    end

    private

    def hook_log
      @hook_log ||= hook.web_hook_logs.find(params[:id])
    end

    def execute_hook
      result = WebHooks::Events::ResendService.new(hook_log, current_user: current_user).execute
      set_hook_execution_notice(result)
      result
    end

    def hide_search_settings
      @hide_search_settings ||= true
    end
  end
end