]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdx.pm
update copyrights for 2018
[public-inbox.git] / lib / PublicInbox / SearchIdx.pm
index 69b7a6f6964bef876cfb5e41a62d02764b678b19..66faed312c3243f1a56789c898b7d5bd4dd6e4a3 100644 (file)
@@ -1,5 +1,5 @@
-# Copyright (C) 2015 all contributors <meta@public-inbox.org>
-# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+# Copyright (C) 2015-2018 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 # based on notmuch, but with no concept of folders, files or flags
 #
 # Indexes mail with Xapian and our (SQLite-based) ::Msgmap for use
@@ -414,9 +414,8 @@ sub link_message {
 
        # last References should be IRT, but some mail clients do things
        # out of order, so trust IRT over References iff IRT exists
-       my @refs = ($hdr->header_raw('References'),
-                       $hdr->header_raw('In-Reply-To'));
-       @refs = ((join(' ', @refs)) =~ /<([^>]+)>/g);
+       my @refs = (($hdr->header_raw('References') || '') =~ /<([^>]+)>/g);
+       push(@refs, (($hdr->header_raw('In-Reply-To') || '') =~ /<([^>]+)>/g));
 
        my $tid;
        if (@refs) {
@@ -478,7 +477,12 @@ sub unindex_blob {
 
 sub index_mm {
        my ($self, $mime) = @_;
-       $self->{mm}->mid_insert(mid_clean(mid_mime($mime)));
+       my $mid = mid_clean(mid_mime($mime));
+       my $mm = $self->{mm};
+       my $num = $mm->mid_insert($mid);
+
+       # fallback to num_for since filters like RubyLang set the number
+       defined $num ? $num : $mm->num_for($mid);
 }
 
 sub unindex_mm {