Commit a8d6757c authored by tmaruyama's avatar tmaruyama

remove trailing white-spaces from extra/mail_handler/rdm-mailhandler.rb

git-svn-id: https://svn.redmine.org/redmine/trunk@9292 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 41c91197
......@@ -10,10 +10,10 @@
# rdm-mailhandler [options] --url=<Redmine URL> --key=<API key>
#
# == Arguments
#
#
# -u, --url URL of the Redmine server
# -k, --key Redmine API key
#
#
# General options:
# --unknown-user=ACTION how to handle emails from an unknown user
# ACTION can be one of the following values:
......@@ -30,7 +30,7 @@
# -h, --help show this help
# -v, --verbose show extra information
# -V, --version show version information and exit
#
#
# Issue attributes control options:
# -p, --project=PROJECT identifier of the target project
# -s, --status=STATUS name of the target status
......@@ -40,15 +40,15 @@
# -o, --allow-override=ATTRS allow email content to override attributes
# specified by previous options
# ATTRS is a comma separated list of attributes
#
#
# == Examples
# No project specified. Emails MUST contain the 'Project' keyword:
#
#
# rdm-mailhandler --url http://redmine.domain.foo --key secret
#
#
# Fixed project and default tracker specified, but emails can override
# both tracker and priority attributes using keywords:
#
#
# rdm-mailhandler --url https://domain.foo/redmine --key secret \\
# --project foo \\
# --tracker bug \\
......@@ -79,12 +79,12 @@ end
class RedmineMailHandler
VERSION = '0.1'
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate
def initialize
self.issue_attributes = {}
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--version', '-V', GetoptLong::NO_ARGUMENT ],
......@@ -134,28 +134,28 @@ class RedmineMailHandler
self.no_check_certificate = true
end
end
RDoc.usage if url.nil?
end
def submit(email)
uri = url.gsub(%r{/*$}, '') + '/mail_handler'
headers = { 'User-Agent' => "Redmine mail handler/#{VERSION}" }
data = { 'key' => key, 'email' => email,
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, headers, :no_check_certificate => no_check_certificate)
debug "Response received: #{response.code}"
case response.code.to_i
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."
return 77
when 422
......@@ -175,9 +175,9 @@ class RedmineMailHandler
return 1
end
end
private
def debug(msg)
puts msg if verbose
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment