lib/webhook_system/subscription.rb in webhook_system-2.2.0 vs lib/webhook_system/subscription.rb in webhook_system-2.3.0

- old
+ new

@@ -4,11 +4,12 @@ class Subscription < ActiveRecord::Base self.table_name = 'webhook_subscriptions' belongs_to :account if defined?(Account) - validates :url, presence: true, url: { no_local: true } + INLINE_JOB_REGEXP=/^inline:(.*)/ + validates :url, presence: true, url: { no_local: true }, if: Proc.new { |a| !a.url.match?(INLINE_JOB_REGEXP) } validates :secret, presence: true has_many :topics, class_name: 'WebhookSystem::SubscriptionTopic', dependent: :destroy has_many :event_logs, class_name: 'WebhookSystem::EventLog', dependent: :delete_all @@ -31,10 +32,14 @@ end end # Just a helper to get a nice representation of the subscription def url_domain - URI.parse(url).host + if data = url.match(INLINE_JOB_REGEXP) + data[1] + else + URI.parse(url).host + end end # Abstraction around the topics relation, returns an array of the subscribed topic names def topic_names topics.map(&:name)