]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mbox: avoid extracting Message-ID for linkification
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 29 Mar 2018 09:57:55 +0000 (09:57 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Thu, 29 Mar 2018 10:00:07 +0000 (10:00 +0000)
We can avoid a small amount of overhead and use the "preferred"
Message-ID based on what is in the SearchMsg object.

lib/PublicInbox/Mbox.pm

index 381bcadad85893bb5b034911a62f374dcadbf6ec..1b68f027157fc0d6b87f97724cdb0eece696fcea 100644 (file)
@@ -92,7 +92,7 @@ sub emit_raw {
 }
 
 sub msg_str {
-       my ($ctx, $simple) = @_; # Email::Simple object
+       my ($ctx, $simple, $mid) = @_; # Email::Simple object
        my $header_obj = $simple->header_obj;
 
        # drop potentially confusing headers, ssoma already should've dropped
@@ -102,7 +102,7 @@ sub msg_str {
        }
        my $ibx = $ctx->{-inbox};
        my $base = $ibx->base_url($ctx->{env});
-       my $mid = mid_clean($header_obj->header('Message-ID'));
+       $mid = $ctx->{mid} unless defined $mid;
        $mid = mid_escape($mid);
        my @append = (
                'Archived-At', "<$base$mid/>",
@@ -225,7 +225,8 @@ sub getline {
                while (defined(my $smsg = shift @{$self->{msgs}})) {
                        my $msg = eval { $ibx->msg_by_smsg($smsg) } or next;
                        $msg = Email::Simple->new($msg);
-                       $gz->write(PublicInbox::Mbox::msg_str($ctx, $msg));
+                       $gz->write(PublicInbox::Mbox::msg_str($ctx, $msg,
+                                                               $smsg->mid));
 
                        # use subject of first message as subject
                        if (my $hdr = delete $self->{hdr}) {