cosmetical cleanup of models
This commit is contained in:
parent
2a4359a572
commit
841e4fbd08
18 changed files with 108 additions and 226 deletions
|
@ -6,26 +6,23 @@ class WebHook < ActiveRecord::Base
|
|||
# HTTParty timeout
|
||||
default_timeout 10
|
||||
|
||||
validates :url,
|
||||
presence: true,
|
||||
format: {
|
||||
with: URI::regexp(%w(http https)),
|
||||
message: "should be a valid url" }
|
||||
validates :url, presence: true,
|
||||
format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }
|
||||
|
||||
def execute(data)
|
||||
parsed_url = URI.parse(url)
|
||||
if parsed_url.userinfo.blank?
|
||||
WebHook.post(url, body: data.to_json, headers: { "Content-Type" => "application/json" })
|
||||
else
|
||||
post_url = url.gsub(parsed_url.userinfo+"@", "")
|
||||
post_url = url.gsub("#{parsed_url.userinfo}@", "")
|
||||
WebHook.post(post_url,
|
||||
body: data.to_json,
|
||||
headers: { "Content-Type" => "application/json" },
|
||||
headers: {"Content-Type" => "application/json"},
|
||||
basic_auth: {username: parsed_url.user, password: parsed_url.password})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: web_hooks
|
||||
|
@ -37,4 +34,3 @@ end
|
|||
# updated_at :datetime not null
|
||||
# type :string(255) default("ProjectHook")
|
||||
#
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue