##// END OF EJS Templates
Allow email to reply to a forum message (#1616)....
Jean-Philippe Lang -
r2287:b9e3fbcd8376
parent child
Show More
@@ -0,0 +1,15
1 Message-ID: <4974C93E.3070005@somenet.foo>
2 Date: Mon, 19 Jan 2009 19:41:02 +0100
3 From: "John Smith" <jsmith@somenet.foo>
4 User-Agent: Thunderbird 2.0.0.19 (Windows/20081209)
5 MIME-Version: 1.0
6 To: redmine@somenet.foo
7 Subject: Reply via email
8 References: <redmine.message-2.20070512171800@somenet.foo>
9 In-Reply-To: <redmine.message-2.20070512171800@somenet.foo>
10 Content-Type: text/plain; charset=UTF-8; format=flowed
11 Content-Transfer-Encoding: 7bit
12
13 This is a reply to a forum message.
14
15
@@ -158,6 +158,24 class MailHandler < ActionMailer::Base
158 end
158 end
159 end
159 end
160
160
161 # Receives a reply to a forum message
162 def receive_message_reply(message_id)
163 message = Message.find_by_id(message_id)
164 if message
165 message = message.root
166 if user.allowed_to?(:add_messages, message.project) && !message.locked?
167 reply = Message.new(:subject => email.subject, :content => plain_text_body)
168 reply.author = user
169 reply.board = message.board
170 message.children << reply
171 add_attachments(reply)
172 reply
173 else
174 raise UnauthorizedAction
175 end
176 end
177 end
178
161 def add_attachments(obj)
179 def add_attachments(obj)
162 if email.has_attachments?
180 if email.has_attachments?
163 email.attachments.each do |attachment|
181 email.attachments.each do |attachment|
@@ -30,7 +30,9 class MailHandlerTest < Test::Unit::TestCase
30 :enumerations,
30 :enumerations,
31 :issue_categories,
31 :issue_categories,
32 :custom_fields,
32 :custom_fields,
33 :custom_fields_trackers
33 :custom_fields_trackers,
34 :boards,
35 :messages
34
36
35 FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
37 FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
36
38
@@ -141,6 +143,16 class MailHandlerTest < Test::Unit::TestCase
141 assert_equal IssueStatus.find_by_name("Resolved"), issue.status
143 assert_equal IssueStatus.find_by_name("Resolved"), issue.status
142 end
144 end
143
145
146 def test_reply_to_a_message
147 m = submit_email('message_reply.eml')
148 assert m.is_a?(Message)
149 assert !m.new_record?
150 m.reload
151 assert_equal 'Reply via email', m.subject
152 # The email replies to message #2 which is part of the thread of message #1
153 assert_equal Message.find(1), m.parent
154 end
155
144 def test_should_strip_tags_of_html_only_emails
156 def test_should_strip_tags_of_html_only_emails
145 issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
157 issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
146 assert issue.is_a?(Issue)
158 assert issue.is_a?(Issue)
General Comments 0
You need to be logged in to leave comments. Login now