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
This commit is contained in:
parent
0c4e40b89c
commit
b9e3fbcd83
@ -158,6 +158,24 @@ class MailHandler < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
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)
|
def add_attachments(obj)
|
||||||
if email.has_attachments?
|
if email.has_attachments?
|
||||||
email.attachments.each do |attachment|
|
email.attachments.each do |attachment|
|
||||||
|
15
test/fixtures/mail_handler/message_reply.eml
vendored
Normal file
15
test/fixtures/mail_handler/message_reply.eml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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,
|
:enumerations,
|
||||||
:issue_categories,
|
:issue_categories,
|
||||||
:custom_fields,
|
:custom_fields,
|
||||||
:custom_fields_trackers
|
:custom_fields_trackers,
|
||||||
|
:boards,
|
||||||
|
:messages
|
||||||
|
|
||||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
|
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
|
assert_equal IssueStatus.find_by_name("Resolved"), issue.status
|
||||||
end
|
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
|
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…
x
Reference in New Issue
Block a user