2018-08-03 13:22:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-11-19 13:24:05 -05:00
|
|
|
class ProjectHook < WebHook
|
2017-12-04 05:18:54 -05:00
|
|
|
include TriggerableHooks
|
2019-12-17 10:08:15 -05:00
|
|
|
include Presentable
|
2020-04-22 11:09:27 -04:00
|
|
|
include Limitable
|
2021-05-14 05:10:24 -04:00
|
|
|
extend ::Gitlab::Utils::Override
|
2020-04-22 11:09:27 -04:00
|
|
|
|
|
|
|
self.limit_scope = :project
|
2017-07-20 11:12:06 -04:00
|
|
|
|
2017-12-04 09:45:47 -05:00
|
|
|
triggerable_hooks [
|
2017-12-04 05:18:54 -05:00
|
|
|
:push_hooks,
|
|
|
|
:tag_push_hooks,
|
|
|
|
:issue_hooks,
|
|
|
|
:confidential_issue_hooks,
|
|
|
|
:note_hooks,
|
2018-04-03 07:00:33 -04:00
|
|
|
:confidential_note_hooks,
|
2017-12-04 05:18:54 -05:00
|
|
|
:merge_request_hooks,
|
|
|
|
:job_hooks,
|
|
|
|
:pipeline_hooks,
|
2020-08-10 11:09:49 -04:00
|
|
|
:wiki_page_hooks,
|
2020-10-28 11:08:49 -04:00
|
|
|
:deployment_hooks,
|
2020-11-06 19:08:58 -05:00
|
|
|
:feature_flag_hooks,
|
|
|
|
:release_hooks
|
2017-12-04 05:18:54 -05:00
|
|
|
]
|
2013-12-02 14:38:32 -05:00
|
|
|
|
2017-07-20 11:12:06 -04:00
|
|
|
belongs_to :project
|
|
|
|
validates :project, presence: true
|
2019-12-16 04:08:10 -05:00
|
|
|
|
|
|
|
def pluralized_name
|
2020-02-24 13:09:05 -05:00
|
|
|
_('Webhooks')
|
2019-12-16 04:08:10 -05:00
|
|
|
end
|
2021-05-06 17:10:07 -04:00
|
|
|
|
2021-05-14 05:10:24 -04:00
|
|
|
override :rate_limit
|
|
|
|
def rate_limit
|
|
|
|
project.actual_limits.limit_for(:web_hook_calls)
|
|
|
|
end
|
2021-05-20 08:10:26 -04:00
|
|
|
|
|
|
|
override :application_context
|
|
|
|
def application_context
|
|
|
|
super.merge(project: project)
|
|
|
|
end
|
2021-12-14 07:13:33 -05:00
|
|
|
|
2022-01-11 01:10:58 -05:00
|
|
|
override :parent
|
|
|
|
def parent
|
|
|
|
project
|
|
|
|
end
|
|
|
|
|
2021-12-14 07:13:33 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
override :web_hooks_disable_failed?
|
|
|
|
def web_hooks_disable_failed?
|
|
|
|
Feature.enabled?(:web_hooks_disable_failed, project)
|
|
|
|
end
|
2012-11-19 13:24:05 -05:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
ProjectHook.prepend_mod_with('ProjectHook')
|