From a141cefa8323bbdc2a5c83127cb9eec3f58dc005 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 22 Jun 2017 21:04:53 +0000 Subject: [PATCH] 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 --- lib/PublicInbox/Filter/RubyLang.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); } -- 2.44.0