mirror of
https://github.com/meineerde/redmine.git
synced 2025-10-17 17:01:01 +00:00
Add watchers from To and Cc fields in issue replies (#7017).
git-svn-id: http://svn.redmine.org/redmine/trunk@15092 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
9110b543b5
commit
91da86a688
@ -240,6 +240,9 @@ class MailHandler < ActionMailer::Base
|
||||
issue.safe_attributes = issue_attributes_from_keywords(issue)
|
||||
issue.safe_attributes = {'custom_field_values' => custom_field_values_from_keywords(issue)}
|
||||
journal.notes = cleaned_up_text_body
|
||||
|
||||
# add To and Cc as watchers before saving so the watchers can reply to Redmine
|
||||
add_watchers(issue)
|
||||
add_attachments(issue)
|
||||
issue.save!
|
||||
if logger
|
||||
@ -314,8 +317,10 @@ class MailHandler < ActionMailer::Base
|
||||
if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project)
|
||||
addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase}
|
||||
unless addresses.empty?
|
||||
User.active.having_mail(addresses).each do |w|
|
||||
obj.add_watcher(w)
|
||||
users = User.active.having_mail(addresses).to_a
|
||||
users -= obj.watcher_users
|
||||
users.each do |u|
|
||||
obj.add_watcher(u)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
19
test/fixtures/mail_handler/issue_update_with_cc.eml
vendored
Normal file
19
test/fixtures/mail_handler/issue_update_with_cc.eml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Return-Path: <JSmith@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
In-Reply-To: <redmine.issue-2.20060719210421@osiris>
|
||||
From: "John Smith" <JSmith@somenet.foo>
|
||||
To: <redmine@somenet.foo>
|
||||
Cc: <dlopper@somenet.foo>
|
||||
Subject: Re: update to issue 2
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
An update to the issue by the sender.
|
||||
@ -265,7 +265,7 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_add_issue_with_cc
|
||||
def test_add_issue_should_add_cc_as_watchers
|
||||
issue = submit_email('ticket_with_cc.eml', :issue => {:project => 'ecookbook'})
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
@ -813,6 +813,28 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||
assert_equal 'Normal', journal.issue.priority.name
|
||||
end
|
||||
|
||||
def test_update_issue_should_add_cc_as_watchers
|
||||
Watcher.delete_all
|
||||
issue = Issue.find(2)
|
||||
|
||||
assert_difference 'Watcher.count' do
|
||||
assert submit_email('issue_update_with_cc.eml')
|
||||
end
|
||||
issue.reload
|
||||
assert_equal 1, issue.watcher_user_ids.size
|
||||
assert issue.watched_by?(User.find_by_mail('dlopper@somenet.foo'))
|
||||
end
|
||||
|
||||
def test_update_issue_should_not_add_cc_as_watchers_if_already_watching
|
||||
Watcher.delete_all
|
||||
issue = Issue.find(2)
|
||||
Watcher.create!(:watchable => issue, :user => User.find_by_mail('dlopper@somenet.foo'))
|
||||
|
||||
assert_no_difference 'Watcher.count' do
|
||||
assert submit_email('issue_update_with_cc.eml')
|
||||
end
|
||||
end
|
||||
|
||||
def test_replying_to_a_private_note_should_add_reply_as_private
|
||||
private_journal = Journal.create!(:notes => 'Private notes', :journalized => Issue.find(1), :private_notes => true, :user_id => 2)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user