summaryrefslogtreecommitdiffstats
path: root/lib/tasks/email.rake
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-06 16:26:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-06 16:26:25 +0000
commit40efaae6d5a2f48734caf4cdabd9537f923c0f47 (patch)
tree4335e4090d62269bea499623268ffa09bed40897 /lib/tasks/email.rake
parentbfba84d526f80e14d7c1422ac51a40803f828f9e (diff)
downloadredmine-40efaae6d5a2f48734caf4cdabd9537f923c0f47.tar.gz
redmine-40efaae6d5a2f48734caf4cdabd9537f923c0f47.zip
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
Diffstat (limited to 'lib/tasks/email.rake')
-rw-r--r--lib/tasks/email.rake76
1 files changed, 56 insertions, 20 deletions
diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake
index 01407c36d..daf0aa9bb 100644
--- a/lib/tasks/email.rake
+++ b/lib/tasks/email.rake
@@ -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
+
+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:
-Example:
- rake redmine:email:receive_iamp host=imap.foo.bar username=redmine@somenet.foo password=xxx project=foo RAILS_ENV="production"
+ 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