From 57d492f8ec6bd90bc17e0ce446c2248656abbd44 Mon Sep 17 00:00:00 2001 From: Stephanie Collett Date: Wed, 27 Oct 2010 11:37:44 -0700 Subject: [PATCH 170/170] Add port option to mail handler. Fixes issue with port forwarding. --- extra/mail_handler/rdm-mailhandler.rb | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) mode change 100644 => 100755 extra/mail_handler/rdm-mailhandler.rb diff --git a/extra/mail_handler/rdm-mailhandler.rb b/extra/mail_handler/rdm-mailhandler.rb old mode 100644 new mode 100755 index fe9460a..1299482 --- a/extra/mail_handler/rdm-mailhandler.rb +++ b/extra/mail_handler/rdm-mailhandler.rb @@ -1,4 +1,4 @@ -#!/usr/bin/env ruby +#!/usr/bin/env /app/redmine/redmine-1.0/local/bin/ruby # == Synopsis # @@ -71,7 +71,7 @@ end class RedmineMailHandler VERSION = '0.1' - attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key + attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :port def initialize self.issue_attributes = {} @@ -89,7 +89,8 @@ class RedmineMailHandler [ '--priority', GetoptLong::REQUIRED_ARGUMENT], [ '--allow-override', '-o', GetoptLong::REQUIRED_ARGUMENT], [ '--unknown-user', GetoptLong::REQUIRED_ARGUMENT], - [ '--no-permission-check', GetoptLong::NO_ARGUMENT] + [ '--no-permission-check', GetoptLong::NO_ARGUMENT], + [ '--port', GetoptLong::REQUIRED_ARGUMENT] ) opts.each do |opt, arg| @@ -112,6 +113,8 @@ class RedmineMailHandler self.unknown_user = arg.dup when '--no-permission-check' self.no_permission_check = '1' + when '--port' + self.port = arg.dup end end @@ -119,16 +122,17 @@ class RedmineMailHandler end def submit(email) - uri = url.gsub(%r{/*$}, '') + '/mail_handler' - + uri = URI.parse(url.gsub(%r{/*$}, '') + '/mail_handler') + uri.port = self.port unless self.port.nil? + data = { 'key' => key, 'email' => email, 'allow_override' => allow_override, 'unknown_user' => unknown_user, 'no_permission_check' => no_permission_check} issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } - debug "Posting to #{uri}..." - response = Net::HTTPS.post_form(URI.parse(uri), data) + debug "Posting to #{uri.to_s}..." + response = Net::HTTPS.post_form(uri, data) debug "Response received: #{response.code}" case response.code.to_i -- 1.7.3.1