about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-06-23 19:41:51 +0000
committerEric Wong <e@80x24.org>2017-06-23 19:43:57 +0000
commitbde2d8c8de65a4d6b06e8d7365f504f2d8db90a6 (patch)
tree34593736c5126cb978a2d82679ad8541c73af12a
parenteb9db159012d8302695500fc2af675c68d5ed9e6 (diff)
downloadpublic-inbox-bde2d8c8de65a4d6b06e8d7365f504f2d8db90a6.tar.gz
This should simplify the rest of our code for handling
the do-not-obfuscate list.
-rw-r--r--lib/PublicInbox/Config.pm11
-rw-r--r--t/config.t2
2 files changed, 4 insertions, 9 deletions
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',