Commit b9e3fbcd authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Allow email to reply to a forum message (#1616).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2289 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 0c4e40b8
......@@ -158,6 +158,24 @@ class MailHandler < ActionMailer::Base
end
end
# Receives a reply to a forum message
def receive_message_reply(message_id)
message = Message.find_by_id(message_id)
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.author = user
reply.board = message.board
message.children << reply
add_attachments(reply)
reply
else
raise UnauthorizedAction
end
end
end
def add_attachments(obj)
if email.has_attachments?
email.attachments.each do |attachment|
......
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: Reply via email
References: <redmine.message-2.20070512171800@somenet.foo>
In-Reply-To: <redmine.message-2.20070512171800@somenet.foo>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
This is a reply to a forum message.
......@@ -30,7 +30,9 @@ class MailHandlerTest < Test::Unit::TestCase
:enumerations,
:issue_categories,
:custom_fields,
:custom_fields_trackers
:custom_fields_trackers,
:boards,
:messages
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
......@@ -141,6 +143,16 @@ class MailHandlerTest < Test::Unit::TestCase
assert_equal IssueStatus.find_by_name("Resolved"), issue.status
end
def test_reply_to_a_message
m = submit_email('message_reply.eml')
assert m.is_a?(Message)
assert !m.new_record?
m.reload
assert_equal 'Reply via email', m.subject
# The email replies to message #2 which is part of the thread of message #1
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment