Project

General

Profile

Defect #31946 » 0001-Output-log-entry-when-MailHandler-ignored-a-reply-to.patch

Go MAEDA, 2019-08-25 10:18

View differences:

app/models/mail_handler.rb
# Adds a note to an existing issue
def receive_issue_reply(issue_id, from_journal=nil)
issue = Issue.find_by_id(issue_id)
return unless issue
unless (issue = Issue.find_by(:id => issue_id))
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent issue"
return nil
end
# check permission
unless handler_options[:no_permission_check]
unless user.allowed_to?(:add_issue_notes, issue.project) ||
......
handler_options[:issue] = {}
journal = issue.init_journal(user)
if from_journal && from_journal.private_notes?
if from_journal&.private_notes?
# If the received email was a reply to a private note, make the added note private
issue.private_notes = true
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
unless (message = Message.find_by(:id => message_id))
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a nonexistent message"
return
end
unless handler_options[:no_permission_check]
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
end
message = message.root
if !message.locked?
reply = Message.new(:subject => cleaned_up_subject.gsub(%r{^.*msg\d+\]}, '').strip,
:content => cleaned_up_text_body)
reply.author = user
reply.board = message.board
message.children << reply
add_attachments(reply)
reply
else
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a locked topic"
end
unless handler_options[:no_permission_check]
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
end
if !message.locked?
reply = Message.new(:subject => cleaned_up_subject.gsub(/^.*msg\d+\]/, '').strip,
:content => cleaned_up_text_body)
reply.author = user
reply.board = message.board
message.children << reply
add_attachments(reply)
reply
else
logger&.info "MailHandler: ignoring reply from [#{email.from.first}] to a locked topic"
end
end
test/unit/mail_handler_test.rb
end
end
def test_reply_to_a_nonexistent_issue
Issue.find(2).destroy
assert_no_difference 'Issue.count' do
assert_no_difference 'Journal.count' do
journal = submit_email('ticket_reply_with_status.eml')
assert_nil journal
end
end
end
def test_reply_to_a_message
m = submit_email('message_reply.eml')
assert m.is_a?(Message)
......
end
end
def test_reply_to_a_nonexistent_topic
Message.find(2).destroy
assert_no_difference('Message.count') do
m = submit_email('message_reply_by_subject.eml')
assert_nil m
end
end
def test_should_convert_tags_of_html_only_emails
with_settings :text_formatting => 'textile' do
issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
(1-1/2)