debian-mirror-gitlab/app/models/hooks/project_hook.rb

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

65 lines
1.4 KiB
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
class ProjectHook < WebHook
2018-03-17 18:26:18 +05:30
include TriggerableHooks
2020-01-01 13:55:28 +05:30
include Presentable
2020-05-24 23:13:21 +05:30
include Limitable
2021-06-08 01:23:25 +05:30
extend ::Gitlab::Utils::Override
2020-05-24 23:13:21 +05:30
self.limit_scope = :project
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
triggerable_hooks [
:push_hooks,
:tag_push_hooks,
:issue_hooks,
:confidential_issue_hooks,
:note_hooks,
2018-04-05 14:03:07 +05:30
:confidential_note_hooks,
2018-03-17 18:26:18 +05:30
:merge_request_hooks,
:job_hooks,
:pipeline_hooks,
2020-10-24 23:57:45 +05:30
:wiki_page_hooks,
2021-01-29 00:20:46 +05:30
:deployment_hooks,
:feature_flag_hooks,
:release_hooks
2018-03-17 18:26:18 +05:30
]
2014-09-02 18:07:02 +05:30
2017-09-10 17:25:29 +05:30
belongs_to :project
validates :project, presence: true
2020-01-01 13:55:28 +05:30
2022-08-13 15:12:31 +05:30
scope :for_projects, ->(project) { where(project: project) }
2020-01-01 13:55:28 +05:30
def pluralized_name
2020-04-08 14:13:33 +05:30
_('Webhooks')
2020-01-01 13:55:28 +05:30
end
2021-06-08 01:23:25 +05:30
2021-09-04 01:27:46 +05:30
override :application_context
def application_context
super.merge(project: project)
end
2022-01-26 12:08:38 +05:30
2022-03-02 08:16:31 +05:30
override :parent
def parent
project
end
2022-08-13 15:12:31 +05:30
override :update_last_failure
def update_last_failure
2023-04-23 21:23:45 +05:30
if executable?
project.cache_web_hook_failure if project.get_web_hook_failure # may need update
else
project.cache_web_hook_failure(true) # definitely failing, no need to check
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
Gitlab::Redis::SharedState.with do |redis|
last_failure_key = project.last_failure_redis_key
time = Time.current.utc.iso8601
prev = redis.get(last_failure_key)
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
redis.set(last_failure_key, time) if !prev || prev < time
end
2022-08-13 15:12:31 +05:30
end
end
2014-09-02 18:07:02 +05:30
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
ProjectHook.prepend_mod_with('ProjectHook')