Mail handler: more control over issue attributes (#1110).

Tracker, category and priority attributes can be specified in command line arguments and/or individually specified as overridable by email body keywords.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1643 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-07-06 16:26:25 +00:00
parent bfba84d526
commit 40efaae6d5
6 changed files with 214 additions and 49 deletions
+56 -20
View File
@@ -21,16 +21,31 @@ namespace :redmine do
desc <<-END_DESC
Read an email from standard input.
Available options:
* project => identifier of the project the issue should be added to
Example:
rake redmine:email:receive project=foo RAILS_ENV="production"
Issue attributes control options:
project=PROJECT identifier of the target project
tracker=TRACKER name of the target tracker
category=CATEGORY name of the target category
priority=PRIORITY name of the target priority
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:
rake redmine:email:read RAILS_ENV="production" < raw_email
# Fixed project and default tracker specified, but emails can override
# both tracker and priority attributes:
rake redmine:email:read RAILS_ENV="production" \\
project=foo \\
tracker=bug \\
allow_override=tracker,priority < raw_email
END_DESC
task :receive => :environment do
options = {}
options[:project] = ENV['project'] if ENV['project']
task :read => :environment do
options = { :issue => {} }
%w(project tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
MailHandler.receive(STDIN.read, options)
end
@@ -39,17 +54,37 @@ END_DESC
Read emails from an IMAP server.
Available IMAP options:
* host => IMAP server host (default: 127.0.0.1)
* port => IMAP server port (default: 143)
* ssl => Use SSL? (default: false)
* username => IMAP account
* password => IMAP password
* folder => IMAP folder to read (default: INBOX)
Other options:
* project => identifier of the project the issue should be added to
host=HOST IMAP server host (default: 127.0.0.1)
port=PORT IMAP server port (default: 143)
ssl=SSL Use SSL? (default: false)
username=USERNAME IMAP account
password=PASSWORD IMAP password
folder=FOLDER IMAP folder to read (default: INBOX)
Issue attributes control options:
project=PROJECT identifier of the target project
tracker=TRACKER name of the target tracker
category=CATEGORY name of the target category
priority=PRIORITY name of the target priority
allow_override=ATTRS allow email content to override attributes
specified by previous options
ATTRS is a comma separated list of attributes
Example:
rake redmine:email:receive_iamp host=imap.foo.bar username=redmine@somenet.foo password=xxx project=foo RAILS_ENV="production"
Examples:
# No project specified. Emails MUST contain the 'Project' keyword:
rake redmine:email:receive_iamp RAILS_ENV="production" \\
host=imap.foo.bar username=redmine@somenet.foo password=xxx
# Fixed project and default tracker specified, but emails can override
# both tracker and priority attributes:
rake redmine:email:receive_iamp RAILS_ENV="production" \\
host=imap.foo.bar username=redmine@somenet.foo password=xxx ssl=1 \\
project=foo \\
tracker=bug \\
allow_override=tracker,priority
END_DESC
task :receive_imap => :environment do
@@ -60,8 +95,9 @@ END_DESC
:password => ENV['password'],
:folder => ENV['folder']}
options = {}
options[:project] = ENV['project'] if ENV['project']
options = { :issue => {} }
%w(project tracker category priority).each { |a| options[:issue][a.to_sym] = ENV[a] if ENV[a] }
options[:allow_override] = ENV['allow_override'] if ENV['allow_override']
Redmine::IMAP.check(imap_options, options)
end