2011-12-14 11:38:52 -05:00
|
|
|
class WebHook < ActiveRecord::Base
|
2015-02-05 17:20:55 -05:00
|
|
|
include Sortable
|
2011-12-14 11:38:52 -05:00
|
|
|
|
2014-02-27 08:56:35 -05:00
|
|
|
default_value_for :push_events, true
|
|
|
|
default_value_for :issues_events, false
|
2016-08-30 16:56:26 -04:00
|
|
|
default_value_for :confidential_issues_events, false
|
2015-05-16 02:33:31 -04:00
|
|
|
default_value_for :note_events, false
|
2014-02-27 08:56:35 -05:00
|
|
|
default_value_for :merge_requests_events, false
|
2014-09-19 04:23:18 -04:00
|
|
|
default_value_for :tag_push_events, false
|
2017-05-15 11:11:45 -04:00
|
|
|
default_value_for :job_events, false
|
2016-08-02 06:06:31 -04:00
|
|
|
default_value_for :pipeline_events, false
|
2017-05-02 22:36:13 -04:00
|
|
|
default_value_for :repository_update_events, false
|
2015-09-15 09:19:32 -04:00
|
|
|
default_value_for :enable_ssl_verification, true
|
2014-02-27 08:56:35 -05:00
|
|
|
|
2017-04-27 06:08:57 -04:00
|
|
|
has_many :web_hook_logs, dependent: :destroy
|
|
|
|
|
2016-04-18 20:53:41 -04:00
|
|
|
scope :push_hooks, -> { where(push_events: true) }
|
|
|
|
scope :tag_push_hooks, -> { where(tag_push_events: true) }
|
|
|
|
|
2015-12-01 18:45:36 -05:00
|
|
|
validates :url, presence: true, url: true
|
2011-12-14 11:38:52 -05:00
|
|
|
|
2015-01-23 19:10:43 -05:00
|
|
|
def execute(data, hook_name)
|
2017-04-27 06:08:57 -04:00
|
|
|
WebHookService.new(self, data, hook_name).execute
|
2011-12-14 11:38:52 -05:00
|
|
|
end
|
2013-01-24 15:15:24 -05:00
|
|
|
|
2015-01-23 19:10:43 -05:00
|
|
|
def async_execute(data, hook_name)
|
2017-04-27 06:08:57 -04:00
|
|
|
WebHookService.new(self, data, hook_name).async_execute
|
2016-04-27 03:24:49 -04:00
|
|
|
end
|
2011-12-14 11:38:52 -05:00
|
|
|
end
|