summaryrefslogtreecommitdiffstats
path: root/email_in.pl
diff options
context:
space:
mode:
authorReed Loden <reed@reedloden.com>2012-08-01 02:38:02 +0200
committerReed Loden <reed@reedloden.com>2012-08-01 02:38:02 +0200
commitbb12c359514198c79b91916506c97f350a2b4d36 (patch)
tree880632e9292d0365db92528868388de3f8226fb6 /email_in.pl
parentcd61d357d20a973e5ebdf3baeaecd9f38f9a6c7a (diff)
downloadbugzilla-bb12c359514198c79b91916506c97f350a2b4d36.tar.gz
bugzilla-bb12c359514198c79b91916506c97f350a2b4d36.tar.xz
Bug 625437 - Use 'Importance' / 'X-Priority' headers in incoming mail to influence bug's initial priority
[r=LpSolit a=LpSolit]
Diffstat (limited to 'email_in.pl')
-rwxr-xr-xemail_in.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/email_in.pl b/email_in.pl
index 53b5ac2a8..67a48e789 100755
--- a/email_in.pl
+++ b/email_in.pl
@@ -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) {