debian-mirror-gitlab/app/controllers/projects/hooks_controller.rb

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

45 lines
1,000 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
class Projects::HooksController < Projects::ApplicationController
2021-12-11 22:18:48 +05:30
include ::Integrations::HooksExecution
2017-09-10 17:25:29 +05:30
2014-09-02 18:07:02 +05:30
# Authorize
2015-09-11 14:41:01 +05:30
before_action :authorize_admin_project!
2017-09-10 17:25:29 +05:30
before_action :hook_logs, only: :edit
2022-01-26 12:08:38 +05:30
before_action -> { check_rate_limit!(:project_testing_hook, scope: [@project, current_user]) }, only: :test
2014-09-02 18:07:02 +05:30
respond_to :html
layout "project_settings"
2021-01-03 14:25:43 +05:30
feature_category :integrations
2021-12-11 22:18:48 +05:30
urgency :low, [:test]
2021-01-03 14:25:43 +05:30
2014-09-02 18:07:02 +05:30
def test
2022-08-13 15:12:31 +05:30
trigger = params.fetch(:trigger, ::ProjectHook.triggers.each_value.first.to_s)
result = TestHooks::ProjectService.new(hook, current_user, trigger).execute
2017-09-10 17:25:29 +05:30
set_hook_execution_notice(result)
2014-09-02 18:07:02 +05:30
2020-04-08 14:13:33 +05:30
redirect_back_or_default(default: { action: :index })
2014-09-02 18:07:02 +05:30
end
2022-08-13 15:12:31 +05:30
private
2014-09-02 18:07:02 +05:30
2022-08-13 15:12:31 +05:30
def relation
@project.hooks
2014-09-02 18:07:02 +05:30
end
def hook
@hook ||= @project.hooks.find(params[:id])
end
2017-09-10 17:25:29 +05:30
def hook_logs
2018-11-08 19:23:39 +05:30
@hook_logs ||= hook.web_hook_logs.recent.page(params[:page])
2017-09-10 17:25:29 +05:30
end
2022-08-13 15:12:31 +05:30
def trigger_values
ProjectHook.triggers.values
2014-09-02 18:07:02 +05:30
end
end