Patch #4071 » mailpatch-trunk.patch
| app/models/mail_handler.rb (working copy) | ||
|---|---|---|
|
|
||
|
# Adds a note to an existing issue
|
||
|
def receive_issue_reply(issue_id)
|
||
|
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
||
|
|
||
|
# Get issue
|
||
|
issue = Issue.find_by_id(issue_id)
|
||
|
return unless issue
|
||
|
# Get project
|
||
|
project = Project.find_by_identifier(get_keyword(:project))
|
||
|
project = issue.project if project.nil?
|
||
|
|
||
|
# Get other properties
|
||
|
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
|
||
|
priority = (get_keyword(:priority) && Enumeration.find_by_opt_and_name('IPRI', get_keyword(:priority)))
|
||
|
category = (get_keyword(:category) && project.issue_categories.find_by_name(get_keyword(:category)))
|
||
|
tracker = (get_keyword(:tracker) && project.trackers.find_by_name(get_keyword(:tracker)))
|
||
|
target = (get_keyword(:target) && project.versions.find_by_name(get_keyword(:target)))
|
||
|
doneratio = (get_keyword(:done))
|
||
|
# check permission
|
||
|
raise UnauthorizedAction unless user.allowed_to?(:add_issue_notes, issue.project) || user.allowed_to?(:edit_issues, issue.project)
|
||
|
raise UnauthorizedAction unless status.nil? || user.allowed_to?(:edit_issues, issue.project)
|
||
| ... | ... | |
|
# add the note
|
||
|
journal = issue.init_journal(user, plain_text_body)
|
||
|
add_attachments(issue)
|
||
|
# status
|
||
|
# check workflow
|
||
|
if status && issue.new_statuses_allowed_to(user).include?(status)
|
||
|
issue.status = status
|
||
|
end
|
||
|
# priority, category, tracker, project, target version and done ratio
|
||
|
issue.priority = priority if priority
|
||
|
issue.category = category if category
|
||
|
issue.tracker = tracker if tracker
|
||
|
issue.project = project
|
||
|
issue.done_ratio = doneratio if doneratio
|
||
|
# target version
|
||
|
if target.nil? && get_keyword(:target) == 'none'
|
||
|
issue.fixed_version = nil
|
||
|
elsif !target.nil?
|
||
|
issue.fixed_version = target
|
||
|
end
|
||
|
# custom fields
|
||
|
issue.custom_field_values = issue.available_custom_fields.inject({}) do |h, c|
|
||
|
if value = get_keyword(c.name, :override => true)
|
||
|
h[c.id] = value
|
||
|
end
|
||
|
h
|
||
|
end
|
||
|
# save issue
|
||
|
issue.save!
|
||
|
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
|
||
|
journal
|
||
- « Previous
- 1
- 2
- Next »