summaryrefslogtreecommitdiffstats
path: root/app/models/mail_handler.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-05-29 00:05:24 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-05-29 00:05:24 +0000
commite94c45d5484138c500f040a917afaed13a47ddc8 (patch)
tree768d06b2ca4b878403aa3e92c18a21dfed466d25 /app/models/mail_handler.rb
parent080dc2212efdb7c91c43ff672ca91cc55b75d6a0 (diff)
downloadredmine-e94c45d5484138c500f040a917afaed13a47ddc8.tar.gz
redmine-e94c45d5484138c500f040a917afaed13a47ddc8.zip
Add an "Assigned To" keyword to receiving email. #5594
Will take a user's email address, login, or full name. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3764 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/mail_handler.rb')
-rw-r--r--app/models/mail_handler.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 1b30af637..ae204b4f7 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -120,6 +120,7 @@ class MailHandler < ActionMailer::Base
category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category)))
priority = (get_keyword(:priority) && IssuePriority.find_by_name(get_keyword(:priority)))
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
+ assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
due_date = get_keyword(:due_date, :override => true)
start_date = get_keyword(:start_date, :override => true)
@@ -128,7 +129,7 @@ class MailHandler < ActionMailer::Base
raise UnauthorizedAction unless user.allowed_to?(:add_issues, project)
end
- issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date)
+ issue = Issue.new(:author => user, :project => project, :tracker => tracker, :category => category, :priority => priority, :due_date => due_date, :start_date => start_date, :assigned_to => assigned_to)
# check workflow
if status && issue.new_statuses_allowed_to(user).include?(status)
issue.status = status
@@ -167,6 +168,7 @@ class MailHandler < ActionMailer::Base
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
due_date = get_keyword(:due_date, :override => true)
start_date = get_keyword(:start_date, :override => true)
+ assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
issue = Issue.find_by_id(issue_id)
return unless issue
@@ -185,6 +187,7 @@ class MailHandler < ActionMailer::Base
end
issue.start_date = start_date if start_date
issue.due_date = due_date if due_date
+ issue.assigned_to = assigned_to if assigned_to
issue.save!
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
@@ -320,4 +323,14 @@ class MailHandler < ActionMailer::Base
end
body.strip
end
+
+ def find_user_from_keyword(keyword)
+ user ||= User.find_by_mail(keyword)
+ user ||= User.find_by_login(keyword)
+ if user.nil? && keyword.match(/ /)
+ firstname, lastname = *(keyword.split) # "First Last Throwaway"
+ user ||= User.find_by_firstname_and_lastname(firstname, lastname)
+ end
+ user
+ end
end