]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 449791 รข\80\93 Allow flag notification emails to be threaded similar to normal bug...
authordkl%redhat.com <>
Thu, 28 Aug 2008 01:50:23 +0000 (01:50 +0000)
committerdkl%redhat.com <>
Thu, 28 Aug 2008 01:50:23 +0000 (01:50 +0000)
Patch by Dave Lawrence <dkl@redhat.com> - r/a=LpSolit

Bugzilla/BugMail.pm
Bugzilla/Flag.pm
Bugzilla/Mailer.pm
template/en/default/request/email.txt.tmpl

index dc48e83ded379a6ede7cc0ac545bf8108cfa7b55..9aa373dc547c9eb31efb02e387f933db42d5c710 100644 (file)
@@ -640,21 +640,7 @@ sub sendMail {
     push(@watchingrel, 'None') unless @watchingrel;
     push @watchingrel, map { user_id_to_login($_) } @$watchingRef;
 
-    my $sitespec = '@' . Bugzilla->params->{'urlbase'};
-    $sitespec =~ s/:\/\//\./; # Make the protocol look like part of the domain
-    $sitespec =~ s/^([^:\/]+):(\d+)/$1/; # Remove a port number, to relocate
-    if ($2) {
-        $sitespec = "-$2$sitespec"; # Put the port number back in, before the '@'
-    }
-    my $threadingmarker;
-    if ($isnew) {
-        $threadingmarker = "Message-ID: <bug-$id-" . $user->id . "$sitespec>";
-    }
-    else {
-        $threadingmarker = "In-Reply-To: <bug-$id-" . $user->id . "$sitespec>" .
-                            "\nReferences: <bug-$id-" . $user->id . "$sitespec>";
-    }
-    
+    my $threadingmarker = build_thread_marker($id, $user->id, $isnew);
 
     my $vars = {
         isnew => $isnew,
index 73266ce9f286d8d3c3c1dc28e7302c2b7ae21c4e..a0c9567a2865cf6b46af23770417cbc47f8e9231 100644 (file)
@@ -1104,10 +1104,16 @@ sub notify {
     }
 
     foreach my $to (keys %recipients) {
-        my $vars = { 'flag'       => $flag,
-                     'to'         => $to,
-                     'bug'        => $bug,
-                     'attachment' => $attachment};
+        # Add threadingmarker to allow flag notification emails to be the
+        # threaded similar to normal bug change emails.
+        my $user_id = $recipients{$to} ? $recipients{$to}->id : 0;
+        my $threadingmarker = build_thread_marker($bug->id, $user_id);
+    
+        my $vars = { 'flag'            => $flag,
+                     'to'              => $to,
+                     'bug'             => $bug,
+                     'attachment'      => $attachment,
+                     'threadingmarker' => $threadingmarker };
 
         my $lang = $recipients{$to} ?
           $recipients{$to}->settings->{'lang'}->{'value'} : $default_lang;
index 5c7a754502d992bfdcdd86423a6d8ee989528f61..c790d179fd2e2805a0a71130a04d5c321947ebf1 100644 (file)
@@ -35,7 +35,7 @@ package Bugzilla::Mailer;
 use strict;
 
 use base qw(Exporter);
-@Bugzilla::Mailer::EXPORT = qw(MessageToMTA);
+@Bugzilla::Mailer::EXPORT = qw(MessageToMTA build_thread_marker);
 
 use Bugzilla::Constants;
 use Bugzilla::Error;
@@ -154,4 +154,31 @@ sub MessageToMTA {
     }
 }
 
+# Builds header suitable for use as a threading marker in email notifications
+sub build_thread_marker {
+    my ($bug_id, $user_id, $is_new) = @_;
+
+    if (!defined $user_id) {
+        $user_id = Bugzilla->user->id;
+    }
+
+    my $sitespec = '@' . Bugzilla->params->{'urlbase'};
+    $sitespec =~ s/:\/\//\./; # Make the protocol look like part of the domain
+    $sitespec =~ s/^([^:\/]+):(\d+)/$1/; # Remove a port number, to relocate
+    if ($2) {
+        $sitespec = "-$2$sitespec"; # Put the port number back in, before the '@'
+    }
+
+    my $threadingmarker;
+    if ($is_new) {
+        $threadingmarker = "Message-ID: <bug-$bug_id-$user_id$sitespec>";
+    }
+    else {
+        $threadingmarker = "In-Reply-To: <bug-$bug_id-$user_id$sitespec>" .
+                           "\nReferences: <bug-$bug_id-$user_id$sitespec>";
+    }
+
+    return $threadingmarker;
+}
+
 1;
index cb18c0f4fdd608f922d65a2d8b9862697fefd13e..81948c42c50519dd196f8f5a9282d8a73403ba84 100644 (file)
@@ -49,6 +49,7 @@ Subject: [% flag.type.name %] [%+ subject_status %]: [[% terms.Bug %] [%+ bug.bu
 [%- IF attachment %] :
   [Attachment [% attachment.id %]] [% attachment.description %][% END %]
 X-Bugzilla-Type: request
+[%+ threadingmarker %]
 
 [%+ USE wrap -%]
 [%- FILTER bullet = wrap(80) -%]