private
+ MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]+#(\d+)\]}
def dispatch
- if m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
- receive_issue_update(m[1].to_i)
+ headers = [email.in_reply_to, email.references].flatten.compact
+ if 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.include?(method_name)
+ send method_name, object_id
+ else
+ # ignoring it
+ end
+ elsif m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
+ # for compatibility
+ receive_issue_reply(m[1].to_i)
else
receive_issue
end
end
# Adds a note to an existing issue
- def receive_issue_update(issue_id)
+ def receive_issue_reply(issue_id)
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
issue = Issue.find_by_id(issue_id)
journal
end
+ # Reply will be added to the issue
+ def receive_journal_reply(journal_id)
+ journal = Journal.find_by_id(journal_id)
+ if journal && journal.journalized_type == 'Issue'
+ receive_issue_reply(journal.journalized_id)
+ end
+ end
+
def add_attachments(obj)
if email.has_attachments?
email.attachments.each do |attachment|
by OSIRIS\r
with hMailServer ; Sat, 21 Jun 2008 18:41:39 +0200\r
Message-ID: <006a01c8d3bd$ad9baec0$0a00a8c0@osiris>\r
+In-Reply-To: <redmine.issue-2.20060719210421@osiris>\r
From: "John Smith" <jsmith@somenet.foo>\r
To: <redmine@somenet.foo>\r
References: <485d0ad366c88_d7014663a025f@osiris.tmail>\r
-Subject: Re: [Cookbook - Feature #2] (New) Add ingredients categories\r
+Subject: Re: Add ingredients categories\r
Date: Sat, 21 Jun 2008 18:41:39 +0200\r
MIME-Version: 1.0\r
Content-Type: multipart/alternative;\r