@@ -53,11 +53,22 class MailHandler < ActionMailer::Base | |||
|
53 | 53 | |
|
54 | 54 | private |
|
55 | 55 | |
|
56 | MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@} | |
|
56 | 57 | ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]+#(\d+)\]} |
|
57 | 58 | |
|
58 | 59 | def dispatch |
|
59 | if m = email.subject.match(ISSUE_REPLY_SUBJECT_RE) | |
|
60 | receive_issue_update(m[1].to_i) | |
|
60 | headers = [email.in_reply_to, email.references].flatten.compact | |
|
61 | if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE} | |
|
62 | klass, object_id = $1, $2.to_i | |
|
63 | method_name = "receive_#{klass}_reply" | |
|
64 | if self.class.private_instance_methods.include?(method_name) | |
|
65 | send method_name, object_id | |
|
66 | else | |
|
67 | # ignoring it | |
|
68 | end | |
|
69 | elsif m = email.subject.match(ISSUE_REPLY_SUBJECT_RE) | |
|
70 | # for compatibility | |
|
71 | receive_issue_reply(m[1].to_i) | |
|
61 | 72 | else |
|
62 | 73 | receive_issue |
|
63 | 74 | end |
@@ -117,7 +128,7 class MailHandler < ActionMailer::Base | |||
|
117 | 128 | end |
|
118 | 129 | |
|
119 | 130 | # Adds a note to an existing issue |
|
120 |
def receive_issue_ |
|
|
131 | def receive_issue_reply(issue_id) | |
|
121 | 132 | status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) |
|
122 | 133 | |
|
123 | 134 | issue = Issue.find_by_id(issue_id) |
@@ -139,6 +150,14 class MailHandler < ActionMailer::Base | |||
|
139 | 150 | journal |
|
140 | 151 | end |
|
141 | 152 | |
|
153 | # Reply will be added to the issue | |
|
154 | def receive_journal_reply(journal_id) | |
|
155 | journal = Journal.find_by_id(journal_id) | |
|
156 | if journal && journal.journalized_type == 'Issue' | |
|
157 | receive_issue_reply(journal.journalized_id) | |
|
158 | end | |
|
159 | end | |
|
160 | ||
|
142 | 161 | def add_attachments(obj) |
|
143 | 162 | if email.has_attachments? |
|
144 | 163 | email.attachments.each do |attachment| |
@@ -3,10 +3,11 Received: from osiris ([127.0.0.1]) | |||
|
3 | 3 | by OSIRIS |
|
4 | 4 | with hMailServer ; Sat, 21 Jun 2008 18:41:39 +0200 |
|
5 | 5 | Message-ID: <006a01c8d3bd$ad9baec0$0a00a8c0@osiris> |
|
6 | In-Reply-To: <redmine.issue-2.20060719210421@osiris> | |
|
6 | 7 | From: "John Smith" <jsmith@somenet.foo> |
|
7 | 8 | To: <redmine@somenet.foo> |
|
8 | 9 | References: <485d0ad366c88_d7014663a025f@osiris.tmail> |
|
9 |
Subject: Re: |
|
|
10 | Subject: Re: Add ingredients categories | |
|
10 | 11 | Date: Sat, 21 Jun 2008 18:41:39 +0200 |
|
11 | 12 | MIME-Version: 1.0 |
|
12 | 13 | Content-Type: multipart/alternative; |
General Comments 0
You need to be logged in to leave comments.
Login now