summaryrefslogtreecommitdiff
path: root/app/controllers/projects/hook_logs_controller.rb
blob: 99ebe3335c00944e18938de5ed3cce39129ae543 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

class Projects::HookLogsController < Projects::ApplicationController
  include HooksExecution

  before_action :authorize_admin_project!

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

  respond_to :html

  layout 'project_settings'

  feature_category :integrations

  def show
  end

  def retry
    execute_hook
    redirect_to edit_project_hook_path(@project, @hook)
  end

  private

  def execute_hook
    result = hook.execute(hook_log.request_data, hook_log.trigger)
    set_hook_execution_notice(result)
  end

  def hook
    @hook ||= @project.hooks.find(params[:hook_id])
  end

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