Bug 625437 - Use 'Importance' / 'X-Priority' headers in incoming mail to influence bug's initial priority

[r=LpSolit a=LpSolit]


git-svn-id: svn://10.0.0.236/trunk@264100 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkanat%bugzilla.org 2012-08-01 00:45:45 +00:00
parent ec28ded977
commit 0c60bd4ef4
2 changed files with 26 additions and 1 deletions

View File

@ -1 +1 @@
8319
8320

View File

@ -30,6 +30,7 @@ use HTML::FormatText::WithLinks;
use Pod::Usage;
use Encode;
use Scalar::Util qw(blessed);
use List::MoreUtils qw(firstidx);
use Bugzilla;
use Bugzilla::Attachment;
@ -37,6 +38,7 @@ use Bugzilla::Bug;
use Bugzilla::BugMail;
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Field;
use Bugzilla::Mailer;
use Bugzilla::Token;
use Bugzilla::User;
@ -133,6 +135,29 @@ sub parse_mail {
$fields{'short_desc'} = $summary;
}
# The Importance/X-Priority field is only used when creating a new bug.
# 1) If somebody specifies a priority, use it.
# 2) If there is an Importance or X-Priority header, use it as
# something that is relative to the default priority.
# If the value is High or 1, increase the priority by 1.
# If the value is Low or 5, decrease the priority by 1.
# 3) Otherwise, use the default priority.
# Note: this will only work if the 'letsubmitterchoosepriority'
# parameter is enabled.
my $importance = $input_email->header('Importance')
|| $input_email->header('X-Priority');
if (!$fields{'bug_id'} && !$fields{'priority'} && $importance) {
my @legal_priorities = @{get_legal_field_values('priority')};
my $i = firstidx { $_ eq Bugzilla->params->{'defaultpriority'} } @legal_priorities;
if ($importance =~ /(high|[12])/i) {
$i-- unless $i == 0;
}
elsif ($importance =~ /(low|[45])/i) {
$i++ unless $i == $#legal_priorities;
}
$fields{'priority'} = $legal_priorities[$i];
}
my $comment = '';
# Get the description, except the signature.
foreach my $line (@body_lines) {