]> Sergey Matveev's repositories - public-inbox.git/commitdiff
derive -primary_address in config
authorEric Wong <e@80x24.org>
Sat, 12 Apr 2014 09:59:41 +0000 (09:59 +0000)
committerEric Wong <e@80x24.org>
Mon, 14 Apr 2014 08:21:35 +0000 (08:21 +0000)
This may be useful for generating List-Id headers and HTML pages.

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

index c8f2a8d82721330fae86f36ab86980061c3050fa..d71bc52e203d7c79efc3f9a4c4aab14bfdb974bf 100644 (file)
@@ -64,6 +64,8 @@ sub lookup {
        my $listname = $pfx;
        $listname =~ s/\Apublicinbox\.//;
        $rv{listname} = $listname;
+       my $v = $rv{address};
+       $rv{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
        \%rv;
 }
 
index cd61fe091d2d607dfde12f2c286e4ef0b4becf75..cb5ccee2559554fd10865da07c77a6a63959ddd8 100644 (file)
@@ -28,6 +28,7 @@ my $tmpdir = tempdir(CLEANUP => 1);
        is_deeply($cfg->lookup('bugs@public-inbox.org'), {
                'mainrepo' => '/home/pi/bugs-main.git',
                'address' => 'bugs@public-inbox.org',
+               -primary_address => 'bugs@public-inbox.org',
                'description' => 'development discussion',
                'listname' => 'bugs',
        }, "lookup matches expected output");
@@ -40,6 +41,7 @@ my $tmpdir = tempdir(CLEANUP => 1);
                'address' => ['try@public-inbox.org',
                              'sandbox@public-inbox.org',
                              'test@public-inbox.org'],
+               -primary_address => 'try@public-inbox.org',
                'mainrepo' => '/home/pi/test-main.git',
                'description' => 'test/sandbox area, occasionally reset',
                'listname' => 'test',