MailHandler: ignore assignee if invalid.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4404 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-11-14 13:48:01 +00:00
parent 97a9210483
commit d7cdd58db6
3 changed files with 7 additions and 1 deletions

View File

@ -253,12 +253,15 @@ class MailHandler < ActionMailer::Base
# Returns a Hash of issue attributes extracted from keywords in the email body
def issue_attributes_from_keywords(issue)
assigned_to = (k = get_keyword(:assigned_to, :override => true)) && find_user_from_keyword(k)
assigned_to = nil if assigned_to && !issue.assignable_users.include?(assigned_to)
{
'tracker_id' => ((k = get_keyword(:tracker)) && issue.project.trackers.find_by_name(k).try(:id)) || issue.project.trackers.find(:first).try(:id),
'status_id' => (k = get_keyword(:status)) && IssueStatus.find_by_name(k).try(:id),
'priority_id' => (k = get_keyword(:priority)) && IssuePriority.find_by_name(k).try(:id),
'category_id' => (k = get_keyword(:category)) && issue.project.issue_categories.find_by_name(k).try(:id),
'assigned_to_id' => (k = get_keyword(:assigned_to, :override => true)) && find_user_from_keyword(k).try(:id),
'assigned_to_id' => assigned_to.try(:id),
'fixed_version_id' => (k = get_keyword(:fixed_version, :override => true)) && issue.project.shared_versions.find_by_name(k).try(:id),
'start_date' => get_keyword(:start_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),
'due_date' => get_keyword(:due_date, :override => true, :format => '\d{4}-\d{2}-\d{2}'),

View File

@ -40,6 +40,7 @@ pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
Project: onlinestore
Tracker: Feature request
category: Stock management
assigned to: miscuser9@foo.bar
priority: foo
done ratio: x
start date: some day

View File

@ -25,6 +25,7 @@ class MailHandlerTest < ActiveSupport::TestCase
:roles,
:members,
:member_roles,
:users,
:issues,
:issue_statuses,
:workflows,
@ -234,6 +235,7 @@ class MailHandlerTest < ActiveSupport::TestCase
assert issue.is_a?(Issue)
assert !issue.new_record?
issue.reload
assert_nil issue.assigned_to
assert_nil issue.start_date
assert_nil issue.due_date
assert_equal 0, issue.done_ratio