From: Eric Wong Date: Thu, 22 Jun 2017 21:04:53 +0000 (+0000) Subject: filter/rubylang: reuse altid entry from inbox object X-Git-Tag: v1.0.0~51 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=a141cefa8323bbdc2a5c83127cb9eec3f58dc005 filter/rubylang: reuse altid entry from inbox object 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: altid = serial:ruby-core:file=msgmap.sqlite3 watch = maildir:/path/to/Maildir/.INBOX.ruby filter = PublicInbox::Filter::RubyLang --- diff --git a/lib/PublicInbox/Filter/RubyLang.pm b/lib/PublicInbox/Filter/RubyLang.pm index ec4bc320..5240e8df 100644 --- a/lib/PublicInbox/Filter/RubyLang.pm +++ b/lib/PublicInbox/Filter/RubyLang.pm @@ -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); }