Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
active_collab: go through http_post
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Van Wiggeren committed Aug 17, 2017
1 parent 01cf794 commit 9dac33d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
7 changes: 4 additions & 3 deletions lib/service.rb
Expand Up @@ -598,9 +598,9 @@ def http_get(url = nil, params = nil, headers = nil)
#
# Yields a Faraday::Request instance.
# Returns a Faraday::Response instance.
def http_post(url = nil, body = nil, headers = nil)
def http_post(url = nil, body = nil, headers = nil, params = nil)
block = Proc.new if block_given?
http_method :post, url, body, headers, &block
http_method :post, url, body, headers, params, &block
end

# Public: Makes an HTTP call.
Expand Down Expand Up @@ -630,7 +630,7 @@ def http_post(url = nil, body = nil, headers = nil)
#
# Yields a Faraday::Request instance.
# Returns a Faraday::Response instance.
def http_method(method, url = nil, body = nil, headers = nil)
def http_method(method, url = nil, body = nil, headers = nil, params = nil)
block = Proc.new if block_given?

raise_config_error("Invalid scheme") unless permitted_transport?(url)
Expand All @@ -640,6 +640,7 @@ def http_method(method, url = nil, body = nil, headers = nil)
req.url(url) if url
req.headers.update(headers) if headers
req.body = body if body
req.params = params if params
block.call req if block
end
end
Expand Down
15 changes: 8 additions & 7 deletions lib/services/active_collab.rb
Expand Up @@ -36,14 +36,15 @@ def receive_push

build_message = statuses * "\n"

http.url_prefix = data['url']
http.headers['Accept'] = 'application/xml'
url = data['url']
body = params(push_message, build_message)
headers = {:Accept => 'application/xml'}
params = {
:path_info => "projects/#{data['project_id']}/discussions/add",
:token => data['token']
}

http.post do |req|
req.params['path_info'] = "projects/#{data['project_id']}/discussions/add"
req.params['token'] = data['token']
req.body = params(push_message, build_message)
end
http_post url, body, headers, params
end

def params(name, message)
Expand Down
3 changes: 0 additions & 3 deletions test/active_collab_test.rb
Expand Up @@ -38,6 +38,3 @@ def service(*args)
super Service::ActiveCollab, *args
end
end



0 comments on commit 9dac33d

Please sign in to comment.