FIX: strip webhook payload_url

This commit is contained in:
Arpit Jalan
2017-12-11 13:45:50 +05:30
parent 4b53be81cf
commit 3c56c9b637
3 changed files with 12 additions and 2 deletions

View File

@ -71,7 +71,7 @@ module Jobs
end
def web_hook_request(args, web_hook)
uri = URI(web_hook.payload_url)
uri = URI(web_hook.payload_url.strip)
conn = Excon.new(
uri.to_s,

View File

@ -13,6 +13,8 @@ class WebHook < ActiveRecord::Base
validates_presence_of :last_delivery_status
validates_presence_of :web_hook_event_types, unless: :wildcard_web_hook?
before_save :strip_url
def self.content_types
@content_types ||= Enum.new('application/json' => 1,
'application/x-www-form-urlencoded' => 2)
@ -47,6 +49,10 @@ class WebHook < ActiveRecord::Base
def self.enqueue_post_hooks(event, post, user = nil)
WebHook.enqueue_hooks(:post, post_id: post.id, category_id: post&.topic&.category_id, event_name: event.to_s)
end
def strip_url
self.payload_url = (payload_url || "").strip.presence
end
end
# == Schema Information