From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/2] config: assume lists have multiple addresses
Date: Fri, 23 Jun 2017 22:34:51 +0000 [thread overview]
Message-ID: <20170623223452.835-2-e@80x24.org> (raw)
In-Reply-To: <20170623223452.835-1-e@80x24.org>
This should simplify the rest of our code for handling
the do-not-obfuscate list.
---
lib/PublicInbox/Config.pm | 11 +++--------
t/config.t | 2 +-
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 0597a52..2be485e 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 3ba6111..437f1d1 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',
--
EW
next prev parent reply other threads:[~2017-06-23 22:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-23 22:34 [PATCH 0/2] selective obfuscation Eric Wong
2017-06-23 22:34 ` Eric Wong [this message]
2017-06-23 22:34 ` [PATCH 2/2] allow admins to configure non-obfuscated addresses/domains Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170623223452.835-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).