MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]+#(\d+)\]}
+ MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]+msg(\d+)\]}
def dispatch
headers = [email.in_reply_to, email.references].flatten.compact
# ignoring it
end
elsif m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
- # for compatibility
receive_issue_reply(m[1].to_i)
+ elsif m = email.subject.match(MESSAGE_REPLY_SUBJECT_RE)
+ receive_message_reply(m[1].to_i)
else
receive_issue
end
if message
message = message.root
if user.allowed_to?(:add_messages, message.project) && !message.locked?
- reply = Message.new(:subject => email.subject, :content => plain_text_body)
+ reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
+ :content => plain_text_body)
reply.author = user
reply.board = message.board
message.children << reply
message_id message
references message.parent unless message.parent.nil?
recipients(recipients)
- subject "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
+ subject "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
body :message => message,
:message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root)
end
--- /dev/null
+Message-ID: <4974C93E.3070005@somenet.foo>
+Date: Mon, 19 Jan 2009 19:41:02 +0100
+From: "John Smith" <jsmith@somenet.foo>
+User-Agent: Thunderbird 2.0.0.19 (Windows/20081209)
+MIME-Version: 1.0
+To: redmine@somenet.foo
+Subject: Re: [eCookbook - Help board - msg2] Reply to the first post
+Content-Type: text/plain; charset=UTF-8; format=flowed
+Content-Transfer-Encoding: 7bit
+
+This is a reply to a forum message.
+
+
assert_equal Message.find(1), m.parent
end
+ def test_reply_to_a_message_by_subject
+ m = submit_email('message_reply_by_subject.eml')
+ assert m.is_a?(Message)
+ assert !m.new_record?
+ m.reload
+ assert_equal 'Reply to the first post', m.subject
+ assert_equal Message.find(1), m.parent
+ end
+
def test_should_strip_tags_of_html_only_emails
issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
assert issue.is_a?(Issue)