2011-12-14 16:38:52 +00:00
|
|
|
class WebHook < ActiveRecord::Base
|
2015-02-05 22:20:55 +00:00
|
|
|
include Sortable
|
2011-12-14 16:38:52 +00:00
|
|
|
|
2017-06-08 15:16:27 +00:00
|
|
|
has_many :web_hook_logs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
|
2017-04-27 10:08:57 +00:00
|
|
|
|
2015-12-01 23:45:36 +00:00
|
|
|
validates :url, presence: true, url: true
|
2018-01-05 21:36:18 +00:00
|
|
|
validates :token, format: { without: /\n/ }
|
2011-12-14 16:38:52 +00:00
|
|
|
|
2015-01-24 00:10:43 +00:00
|
|
|
def execute(data, hook_name)
|
2017-04-27 10:08:57 +00:00
|
|
|
WebHookService.new(self, data, hook_name).execute
|
2011-12-14 16:38:52 +00:00
|
|
|
end
|
2013-01-24 20:15:24 +00:00
|
|
|
|
2015-01-24 00:10:43 +00:00
|
|
|
def async_execute(data, hook_name)
|
2017-04-27 10:08:57 +00:00
|
|
|
WebHookService.new(self, data, hook_name).async_execute
|
2016-04-27 07:24:49 +00:00
|
|
|
end
|
2011-12-14 16:38:52 +00:00
|
|
|
end
|