]> Sergey Matveev's repositories - public-inbox.git/commitdiff
config: assume lists have multiple addresses
authorEric Wong <e@80x24.org>
Fri, 23 Jun 2017 19:41:51 +0000 (19:41 +0000)
committerEric Wong <e@80x24.org>
Fri, 23 Jun 2017 19:43:57 +0000 (19:43 +0000)
This should simplify the rest of our code for handling
the do-not-obfuscate list.

lib/PublicInbox/Config.pm
t/config.t

index 0597a527baf7b0aa0a58d61d1187d09da9d69252..2be485e5efd68d038d877a39733466f6ce5a68bb 100644 (file)
@@ -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;
        }
index 3ba61119728fbad52c80c036d23007aae5359027..437f1d145b868d35854ae54e2e3ef021590d2e79 100644 (file)
@@ -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',