summaryrefslogtreecommitdiff
path: root/app/models/hooks/web_hook.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-08 12:20:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-08 12:20:17 +0000
commit6728ed6fe203d0613ee63c89a08a70fffb93405c (patch)
tree9eddfee7a854efd47d85899c1524fd4bd10ce8e4 /app/models/hooks/web_hook.rb
parent60028378dd5e5e7844810e4a2aa2934a58f738ca (diff)
downloadgitlab-ce-6728ed6fe203d0613ee63c89a08a70fffb93405c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/hooks/web_hook.rb')
-rw-r--r--app/models/hooks/web_hook.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index 7e538238cbd..88941df691c 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -37,14 +37,14 @@ class WebHook < ApplicationRecord
!temporarily_disabled? && !permanently_disabled?
end
- def temporarily_disabled?
- return false unless web_hooks_disable_failed?
+ def temporarily_disabled?(ignore_flag: false)
+ return false unless ignore_flag || web_hooks_disable_failed?
disabled_until.present? && disabled_until >= Time.current
end
- def permanently_disabled?
- return false unless web_hooks_disable_failed?
+ def permanently_disabled?(ignore_flag: false)
+ return false unless ignore_flag || web_hooks_disable_failed?
recent_failures > FAILURE_THRESHOLD
end
@@ -106,6 +106,13 @@ class WebHook < ApplicationRecord
save(validate: false)
end
+ def active_state(ignore_flag: false)
+ return :permanently_disabled if permanently_disabled?(ignore_flag: ignore_flag)
+ return :temporarily_disabled if temporarily_disabled?(ignore_flag: ignore_flag)
+
+ :enabled
+ end
+
# @return [Boolean] Whether or not the WebHook is currently throttled.
def rate_limited?
return false unless rate_limit