Switch from httpclient to net/http
This commit is contained in:
@@ -9,8 +9,9 @@ Changelog
|
||||
* Contact added/updated supported for notification (if redmine_contacts is installed)
|
||||
* Password added/updated supported for notification (if redmine_passwords is installed)
|
||||
* DB entry added/updated supported for notification (if redmine_db is installed)
|
||||
* SSL verify can be disabled
|
||||
* SSL verify can be disabled
|
||||
* Lots of refactoring and code cleanups
|
||||
* Swith from httpclient to net/http
|
||||
|
||||
## v0.6.1
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ Install ``redmine_messenger`` plugin for `Redmine`
|
||||
|
||||
cd $REDMINE_ROOT
|
||||
git clone git://github.com/alphanodes/redmine_messenger.git plugins/redmine_messenger
|
||||
bundle install --without development test
|
||||
|
||||
Restart Redmine, and you should see the plugin show up in the Plugins page.
|
||||
Under the configuration options, set the Messenger API URL to the URL for an
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Redmine Messenger plugin for Redmine
|
||||
require 'httpclient'
|
||||
require 'net/http'
|
||||
|
||||
class Messenger
|
||||
include Redmine::I18n
|
||||
@@ -30,16 +30,23 @@ class Messenger
|
||||
end
|
||||
|
||||
channels.each do |channel|
|
||||
uri = URI(url)
|
||||
params[:channel] = channel
|
||||
|
||||
http_options = { use_ssl: uri.scheme == 'https' }
|
||||
if RedmineMessenger.settings[:messenger_verify_ssl] != 1
|
||||
http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
|
||||
end
|
||||
|
||||
begin
|
||||
client = HTTPClient.new
|
||||
client.ssl_config.cert_store.set_default_paths
|
||||
client.ssl_config.ssl_version = :auto
|
||||
if RedmineMessenger.settings[:messenger_verify_ssl] != 1
|
||||
client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
req = Net::HTTP::Post.new(uri)
|
||||
req.set_form_data(payload: params.to_json)
|
||||
Net::HTTP.start(uri.hostname, uri.port, http_options) do |http|
|
||||
response = http.request(req)
|
||||
unless response == Net::HTTPSuccess || response == Net::HTTPRedirection
|
||||
Rails.logger.warn(response)
|
||||
end
|
||||
end
|
||||
client.post_async url, payload: params.to_json
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn("cannot connect to #{url}")
|
||||
Rails.logger.warn(e)
|
||||
|
||||
@@ -18,8 +18,10 @@ module RedmineMessenger
|
||||
|
||||
repository = changeset.repository
|
||||
|
||||
if Setting.host_name.to_s =~ /\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i
|
||||
host, port, prefix = $2, $4, $5
|
||||
if Setting.host_name.to_s =~ %r{/\A(https?\:\/\/)?(.+?)(\:(\d+))?(\/.+)?\z/i}
|
||||
host = Regexp.last_match(2)
|
||||
port = Regexp.last_match(4)
|
||||
prefix = Regexp.last_match(5)
|
||||
revision_url = Rails.application.routes.url_for(
|
||||
controller: 'repositories',
|
||||
action: 'revision',
|
||||
|
||||
Reference in New Issue
Block a user