about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-05 09:34:11 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-05 10:27:13 +0000
commit56489ee40e44255f2f9a00cd608bc366d2586306 (patch)
treef4275dea838b33d3ab2e968e589db5872eb510c1 /lib
parent3dcb03ef3ec06ad0f0335973df405ec8d041abee (diff)
downloadpublic-inbox-56489ee40e44255f2f9a00cd608bc366d2586306.tar.gz
There's enough gmane links out there in wild that it makes sense
to maintain support for these mappings.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/AltId.pm20
-rw-r--r--lib/PublicInbox/Filter/RubyLang.pm22
2 files changed, 32 insertions, 10 deletions
diff --git a/lib/PublicInbox/AltId.pm b/lib/PublicInbox/AltId.pm
index d1b2dc24..f8aa4cb8 100644
--- a/lib/PublicInbox/AltId.pm
+++ b/lib/PublicInbox/AltId.pm
@@ -22,17 +22,31 @@ sub new {
         } split(/[&;]/, $query);
         my $f = $params{file} or die "file: required for $type spec $spec\n";
         unless (index($f, '/') == 0) {
-                $f = "$inbox->{mainrepo}/public-inbox/$f";
+                if (($inbox->{version} || 1) == 1) {
+                        $f = "$inbox->{mainrepo}/public-inbox/$f";
+                } else {
+                        $f = "$inbox->{mainrepo}/$f";
+                }
         }
         bless {
-                mm_alt => PublicInbox::Msgmap->new_file($f, $writable),
+                filename => $f,
+                writable => $writable,
                 xprefix => 'X'.uc($prefix),
         }, $class;
 }
 
+sub mm_alt {
+        my ($self) = @_;
+        $self->{mm_alt} ||= eval {
+                my $f = $self->{filename};
+                my $writable = $self->{filename};
+                PublicInbox::Msgmap->new_file($f, $writable);
+        };
+}
+
 sub mid2alt {
         my ($self, $mid) = @_;
-        $self->{mm_alt}->num_for($mid);
+        $self->mm_alt->num_for($mid);
 }
 
 1;
diff --git a/lib/PublicInbox/Filter/RubyLang.pm b/lib/PublicInbox/Filter/RubyLang.pm
index 63e8d422..cb69e38a 100644
--- a/lib/PublicInbox/Filter/RubyLang.pm
+++ b/lib/PublicInbox/Filter/RubyLang.pm
@@ -6,6 +6,7 @@ package PublicInbox::Filter::RubyLang;
 use base qw(PublicInbox::Filter::Base);
 use strict;
 use warnings;
+use PublicInbox::MID qw(mids);
 
 my $l1 = qr/Unsubscribe:\s
         <mailto:ruby-\w+-request\@ruby-lang\.org\?subject=unsubscribe>/x;
@@ -44,16 +45,23 @@ sub scrub {
         my $altid = $self->{-altid};
         if ($altid) {
                 my $hdr = $mime->header_obj;
-                my $mid = $hdr->header_raw('Message-ID');
-                unless (defined $mid) {
-                        return $self->REJECT('Message-Id missing');
+                my $mids = mids($hdr);
+                return $self->REJECT('Message-ID missing') unless (@$mids);
+                my @v = $hdr->header_raw('X-Mail-Count');
+                my $n;
+                foreach (@v) {
+                        /\A\s*(\d+)\s*\z/ or next;
+                        $n = $1;
+                        last;
                 }
-                my $n = $hdr->header_raw('X-Mail-Count');
-                if (!defined($n) || $n !~ /\A\s*\d+\s*\z/) {
+                unless (defined $n) {
                         return $self->REJECT('X-Mail-Count not numeric');
                 }
-                $mid = PublicInbox::MID::mid_clean($mid);
-                $altid->{mm_alt}->mid_set($n, $mid);
+                foreach my $mid (@$mids) {
+                        my $r = $altid->mm_alt->mid_set($n, $mid);
+                        next if $r == 0;
+                        last;
+                }
         }
         $self->ACCEPT($mime);
 }