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,
}
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;
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;
}
}
+# 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;
[%- IF attachment %] :
[Attachment [% attachment.id %]] [% attachment.description %][% END %]
X-Bugzilla-Type: request
+[%+ threadingmarker %]
[%+ USE wrap -%]
[%- FILTER bullet = wrap(80) -%]