]> Sergey Matveev's repositories - public-inbox.git/commitdiff
filter/rubylang: reuse altid entry from inbox object
authorEric Wong <e@80x24.org>
Thu, 22 Jun 2017 21:04:53 +0000 (21:04 +0000)
committerEric Wong <e@80x24.org>
Thu, 22 Jun 2017 21:04:53 +0000 (21:04 +0000)
This allows users to DRY up their config a bit and avoid
specifying altid twice when reusing the NNTP-centric msgmap
for [ruby-*:\d+] serial numbers.

My current work-in-progress ~/.public-inbox/config entry
for the ruby-core list is:

------8<-------
[publicinbox "ruby-core"]
address = ruby-core@ruby-lang.org
url = //public-inbox.org/ruby-core
mainrepo = /path/to/ruby-core.git
newsgroup = inbox.comp.lang.ruby.core
watchheader = List-Id:<ruby-core.ruby-lang.org>
altid = serial:ruby-core:file=msgmap.sqlite3
watch = maildir:/path/to/Maildir/.INBOX.ruby
filter = PublicInbox::Filter::RubyLang

lib/PublicInbox/Filter/RubyLang.pm

index ec4bc320e64192ae4bf195a6241d2473c6dd6763..5240e8df22ada380434cdb76a871fd27fd3dd79f 100644 (file)
@@ -15,10 +15,13 @@ sub new {
        my ($class, %opts) = @_;
        my $altid = delete $opts{-altid};
        my $self = $class->SUPER::new(%opts);
+       my $ibx = $self->{-inbox};
        # altid = serial:ruby-core:file=msgmap.sqlite3
+       if (!$altid && $ibx && $ibx->{altid}) {
+               $altid ||= $ibx->{altid}->[0];
+       }
        if ($altid) {
                require PublicInbox::MID; # mid_clean
-               my $ibx = $self->{-inbox};
                require PublicInbox::AltId;
                $self->{-altid} = PublicInbox::AltId->new($ibx, $altid, 1);
        }