From: Eric Wong Date: Fri, 23 Jun 2017 19:41:51 +0000 (+0000) Subject: config: assume lists have multiple addresses X-Git-Tag: v1.0.0~43 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=bde2d8c8de65a4d6b06e8d7365f504f2d8db90a6 config: assume lists have multiple addresses This should simplify the rest of our code for handling the do-not-obfuscate list. --- diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 0597a527..2be485e5 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -134,7 +134,7 @@ sub _fill { my ($self, $pfx) = @_; my $rv = {}; - foreach my $k (qw(mainrepo address filter url newsgroup + foreach my $k (qw(mainrepo filter url newsgroup infourl watch watchheader httpbackendmax replyto feedmax nntpserver)) { my $v = $self->{"$pfx.$k"}; @@ -154,7 +154,7 @@ sub _fill { # TODO: more arrays, we should support multi-value for # more things to encourage decentralization - foreach my $k (qw(altid nntpmirror)) { + foreach my $k (qw(address altid nntpmirror)) { if (defined(my $v = $self->{"$pfx.$k"})) { $rv->{$k} = ref($v) eq 'ARRAY' ? $v : [ $v ]; } @@ -166,12 +166,7 @@ sub _fill { $rv->{name} = $name; $rv->{-pi_config} = $self; $rv = PublicInbox::Inbox->new($rv); - my $v = $rv->{address}; - if (ref($v) eq 'ARRAY') { - $self->{-by_addr}->{lc($_)} = $rv foreach @$v; - } else { - $self->{-by_addr}->{lc($v)} = $rv; - } + $self->{-by_addr}->{lc($_)} = $rv foreach @{$rv->{address}}; if (my $ng = $rv->{newsgroup}) { $self->{-by_newsgroup}->{$ng} = $rv; } diff --git a/t/config.t b/t/config.t index 3ba61119..437f1d14 100644 --- a/t/config.t +++ b/t/config.t @@ -25,7 +25,7 @@ my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); my $cfg = PublicInbox::Config->new($f); is_deeply($cfg->lookup('meta@public-inbox.org'), { 'mainrepo' => '/home/pi/meta-main.git', - 'address' => 'meta@public-inbox.org', + 'address' => [ 'meta@public-inbox.org' ], 'domain' => 'public-inbox.org', 'url' => 'http://example.com/meta', -primary_address => 'meta@public-inbox.org',