remove trailing white-spaces from extra/mail_handler/rdm-mailhandler.rb
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9292 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
0098c7b128
commit
be04f1dd62
1 file changed
+19
-19
@@ -10,10 +10,10 @@
|
|||||||
# rdm-mailhandler [options] --url=<Redmine URL> --key=<API key>
|
# rdm-mailhandler [options] --url=<Redmine URL> --key=<API key>
|
||||||
#
|
#
|
||||||
# == Arguments
|
# == Arguments
|
||||||
#
|
#
|
||||||
# -u, --url URL of the Redmine server
|
# -u, --url URL of the Redmine server
|
||||||
# -k, --key Redmine API key
|
# -k, --key Redmine API key
|
||||||
#
|
#
|
||||||
# General options:
|
# General options:
|
||||||
# --unknown-user=ACTION how to handle emails from an unknown user
|
# --unknown-user=ACTION how to handle emails from an unknown user
|
||||||
# ACTION can be one of the following values:
|
# ACTION can be one of the following values:
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
# -h, --help show this help
|
# -h, --help show this help
|
||||||
# -v, --verbose show extra information
|
# -v, --verbose show extra information
|
||||||
# -V, --version show version information and exit
|
# -V, --version show version information and exit
|
||||||
#
|
#
|
||||||
# Issue attributes control options:
|
# Issue attributes control options:
|
||||||
# -p, --project=PROJECT identifier of the target project
|
# -p, --project=PROJECT identifier of the target project
|
||||||
# -s, --status=STATUS name of the target status
|
# -s, --status=STATUS name of the target status
|
||||||
@@ -40,15 +40,15 @@
|
|||||||
# -o, --allow-override=ATTRS allow email content to override attributes
|
# -o, --allow-override=ATTRS allow email content to override attributes
|
||||||
# specified by previous options
|
# specified by previous options
|
||||||
# ATTRS is a comma separated list of attributes
|
# ATTRS is a comma separated list of attributes
|
||||||
#
|
#
|
||||||
# == Examples
|
# == Examples
|
||||||
# No project specified. Emails MUST contain the 'Project' keyword:
|
# No project specified. Emails MUST contain the 'Project' keyword:
|
||||||
#
|
#
|
||||||
# rdm-mailhandler --url http://redmine.domain.foo --key secret
|
# rdm-mailhandler --url http://redmine.domain.foo --key secret
|
||||||
#
|
#
|
||||||
# Fixed project and default tracker specified, but emails can override
|
# Fixed project and default tracker specified, but emails can override
|
||||||
# both tracker and priority attributes using keywords:
|
# both tracker and priority attributes using keywords:
|
||||||
#
|
#
|
||||||
# rdm-mailhandler --url https://domain.foo/redmine --key secret \\
|
# rdm-mailhandler --url https://domain.foo/redmine --key secret \\
|
||||||
# --project foo \\
|
# --project foo \\
|
||||||
# --tracker bug \\
|
# --tracker bug \\
|
||||||
@@ -79,12 +79,12 @@ end
|
|||||||
|
|
||||||
class RedmineMailHandler
|
class RedmineMailHandler
|
||||||
VERSION = '0.1'
|
VERSION = '0.1'
|
||||||
|
|
||||||
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate
|
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
self.issue_attributes = {}
|
self.issue_attributes = {}
|
||||||
|
|
||||||
opts = GetoptLong.new(
|
opts = GetoptLong.new(
|
||||||
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
||||||
[ '--version', '-V', GetoptLong::NO_ARGUMENT ],
|
[ '--version', '-V', GetoptLong::NO_ARGUMENT ],
|
||||||
@@ -134,28 +134,28 @@ class RedmineMailHandler
|
|||||||
self.no_check_certificate = true
|
self.no_check_certificate = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RDoc.usage if url.nil?
|
RDoc.usage if url.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def submit(email)
|
def submit(email)
|
||||||
uri = url.gsub(%r{/*$}, '') + '/mail_handler'
|
uri = url.gsub(%r{/*$}, '') + '/mail_handler'
|
||||||
|
|
||||||
headers = { 'User-Agent' => "Redmine mail handler/#{VERSION}" }
|
headers = { 'User-Agent' => "Redmine mail handler/#{VERSION}" }
|
||||||
|
|
||||||
data = { 'key' => key, 'email' => email,
|
data = { 'key' => key, 'email' => email,
|
||||||
'allow_override' => allow_override,
|
'allow_override' => allow_override,
|
||||||
'unknown_user' => unknown_user,
|
'unknown_user' => unknown_user,
|
||||||
'no_permission_check' => no_permission_check}
|
'no_permission_check' => no_permission_check}
|
||||||
issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
|
issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value }
|
||||||
|
|
||||||
debug "Posting to #{uri}..."
|
debug "Posting to #{uri}..."
|
||||||
response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate)
|
response = Net::HTTPS.post_form(URI.parse(uri), data, headers, :no_check_certificate => no_check_certificate)
|
||||||
debug "Response received: #{response.code}"
|
debug "Response received: #{response.code}"
|
||||||
|
|
||||||
case response.code.to_i
|
case response.code.to_i
|
||||||
when 403
|
when 403
|
||||||
warn "Request was denied by your Redmine server. " +
|
warn "Request was denied by your Redmine server. " +
|
||||||
"Make sure that 'WS for incoming emails' is enabled in application settings and that you provided the correct API key."
|
"Make sure that 'WS for incoming emails' is enabled in application settings and that you provided the correct API key."
|
||||||
return 77
|
return 77
|
||||||
when 422
|
when 422
|
||||||
@@ -175,9 +175,9 @@ class RedmineMailHandler
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def debug(msg)
|
def debug(msg)
|
||||||
puts msg if verbose
|
puts msg if verbose
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user