Accept replies to forum messages by subject recognition (#1616).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2294 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b80caf762a
commit
dfab202cde
|
@ -55,6 +55,7 @@ class MailHandler < ActionMailer::Base
|
||||||
|
|
||||||
MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
|
MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
|
||||||
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]+#(\d+)\]}
|
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]+#(\d+)\]}
|
||||||
|
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]+msg(\d+)\]}
|
||||||
|
|
||||||
def dispatch
|
def dispatch
|
||||||
headers = [email.in_reply_to, email.references].flatten.compact
|
headers = [email.in_reply_to, email.references].flatten.compact
|
||||||
|
@ -67,8 +68,9 @@ class MailHandler < ActionMailer::Base
|
||||||
# ignoring it
|
# ignoring it
|
||||||
end
|
end
|
||||||
elsif m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
|
elsif m = email.subject.match(ISSUE_REPLY_SUBJECT_RE)
|
||||||
# for compatibility
|
|
||||||
receive_issue_reply(m[1].to_i)
|
receive_issue_reply(m[1].to_i)
|
||||||
|
elsif m = email.subject.match(MESSAGE_REPLY_SUBJECT_RE)
|
||||||
|
receive_message_reply(m[1].to_i)
|
||||||
else
|
else
|
||||||
receive_issue
|
receive_issue
|
||||||
end
|
end
|
||||||
|
@ -164,7 +166,8 @@ class MailHandler < ActionMailer::Base
|
||||||
if message
|
if message
|
||||||
message = message.root
|
message = message.root
|
||||||
if user.allowed_to?(:add_messages, message.project) && !message.locked?
|
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.author = user
|
||||||
reply.board = message.board
|
reply.board = message.board
|
||||||
message.children << reply
|
message.children << reply
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Mailer < ActionMailer::Base
|
||||||
message_id message
|
message_id message
|
||||||
references message.parent unless message.parent.nil?
|
references message.parent unless message.parent.nil?
|
||||||
recipients(recipients)
|
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,
|
body :message => message,
|
||||||
:message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root)
|
:message_url => url_for(:controller => 'messages', :action => 'show', :board_id => message.board_id, :id => message.root)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,15 @@ class MailHandlerTest < Test::Unit::TestCase
|
||||||
assert_equal Message.find(1), m.parent
|
assert_equal Message.find(1), m.parent
|
||||||
end
|
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
|
def test_should_strip_tags_of_html_only_emails
|
||||||
issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
|
issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
|
||||||
assert issue.is_a?(Issue)
|
assert issue.is_a?(Issue)
|
||||||
|
|
Loading…
Reference in New Issue