Project

General

Profile

Actions

Patch #12338

open

Allow MailHandler to submit to a specific issue

Added by Chris Wilson about 12 years ago. Updated about 12 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Email receiving
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

We modified our mail server and Redmine so that we could send email to and it would be appended to that ticket number.

I'd like to see this feature rolled into Redmine so that it doesn't get broken by future upgrades. I think it's minor and easy and has no security implications.

On our mail server, we modified rdm_mailhandler.rb to add a --number option, that would be added to the issue_attributes:

chris@one-mail(exim)$ sudo diff -u /etc/exim/redmine/rdm-mailhandler.rb{.orig,}
--- /etc/exim/redmine/rdm-mailhandler.rb.orig    2012-11-09 18:09:58.000000000 +0000
+++ /etc/exim/redmine/rdm-mailhandler.rb    2012-11-09 17:33:51.000000000 +0000
@@ -87,6 +87,7 @@
       [ '--project',        '-p', GetoptLong::REQUIRED_ARGUMENT ],
       [ '--status',         '-s', GetoptLong::REQUIRED_ARGUMENT ],
       [ '--tracker',        '-t', GetoptLong::REQUIRED_ARGUMENT ],
+      [ '--number',         '-n', GetoptLong::REQUIRED_ARGUMENT ],
       [ '--category',             GetoptLong::REQUIRED_ARGUMENT ],
       [ '--priority',             GetoptLong::REQUIRED_ARGUMENT ],
       [ '--allow-override', '-o', GetoptLong::REQUIRED_ARGUMENT ],
@@ -106,7 +107,7 @@
         self.verbose = true
       when '--version'
         puts VERSION; exit
-      when '--project', '--status', '--tracker', '--category', '--priority'
+      when '--project', '--status', '--tracker', '--category', '--priority', '--number'
         self.issue_attributes[opt.gsub(%r{^\-\-}, '')] = arg.dup
       when '--allow-override'
         self.allow_override = arg.dup

And on the Redmine server, we added some code to allow this flag to set the issue number to append to, in preference to the headers of the message itself:

chris@lap-x201:~/Dropbox/patches$ cat redmine_mail_handler.patch
--- app/models/mail_handler.rb.orig    2012-11-09 18:11:43.000000000 +0000
+++ app/models/mail_handler.rb    2012-11-09 17:56:48.000000000 +0000
@@ -86,7 +86,9 @@

   def dispatch
     headers = [email.in_reply_to, email.references].flatten.compact
-    if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
+    if @@handler_options[:issue].has_key?(:number)
+      receive_issue_reply(@@handler_options[:issue][:number])
+    elsif headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
       klass, object_id = $1, $2.to_i
       method_name = "receive_#{klass}_reply" 
       if self.class.private_instance_methods.collect(&:to_s).include?(method_name)

Patches attached. I hope you will accept them.


Files

redmine_mail_handler.patch (638 Bytes) redmine_mail_handler.patch Patch for app/models/mail_handler.rb Chris Wilson, 2012-11-09 19:15
redmine_rdm_mailhandler.patch (1.03 KB) redmine_rdm_mailhandler.patch Patch for rdm_mailhandler.rb Chris Wilson, 2012-11-09 19:15
Actions

Also available in: Atom PDF