about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-16 00:26:51 +0000
committerEric Wong <e@80x24.org>2021-09-16 04:29:11 +0000
commitb4bc9aeed78078feae58d150970fe224f10098e3 (patch)
tree023713e3d70c48f253b129d72e57363aece7c171 /lib/PublicInbox
parentadd90b9504f4217af5e35b3be7e326b8c6419647 (diff)
downloadpublic-inbox-b4bc9aeed78078feae58d150970fe224f10098e3.tar.gz
inbox: streamline ->nntp_url
We no longer waste a precious hash slot for a per-Inbox
{nntpserver} if it's only configured globally for all inboxes.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/Config.pm4
-rw-r--r--lib/PublicInbox/Inbox.pm9
-rw-r--r--lib/PublicInbox/WwwText.pm4
3 files changed, 7 insertions, 10 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index ee5322fe..5e7a9f2b 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -424,7 +424,7 @@ sub _fill_ibx {
         my ($self, $name) = @_;
         my $pfx = "publicinbox.$name";
         my $ibx = {};
-        for my $k (qw(watch nntpserver)) {
+        for my $k (qw(watch)) {
                 my $v = $self->{"$pfx.$k"};
                 $ibx->{$k} = $v if defined $v;
         }
@@ -451,7 +451,7 @@ sub _fill_ibx {
         # TODO: more arrays, we should support multi-value for
         # more things to encourage decentralization
         for my $k (qw(address altid nntpmirror coderepo hide listid url
-                        infourl watchheader)) {
+                        infourl watchheader nntpserver)) {
                 my $v = $self->{"$pfx.$k"} // next;
                 $ibx->{$k} = _array($v);
         }
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index b0bb9dcc..f234b96f 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -109,8 +109,6 @@ sub new {
         } else {
                 delete $opts->{feedmax};
         }
-        $opts->{nntpserver} ||= $pi_cfg->{'publicinbox.nntpserver'};
-
         # allow any combination of multi-line or comma-delimited hide entries
         my $hide = {};
         if (defined(my $h = $opts->{hide})) {
@@ -261,22 +259,21 @@ sub base_url {
 }
 
 sub nntp_url {
-        my ($self) = @_;
+        my ($self, $ctx) = @_;
         $self->{-nntp_url} ||= do {
                 # no checking for nntp_usable here, we can point entirely
                 # to non-local servers or users run by a different user
-                my $ns = $self->{nntpserver};
+                my $ns = $self->{nntpserver} //
+                       $ctx->{www}->{pi_cfg}->get_all('publicinbox.nntpserver');
                 my $group = $self->{newsgroup};
                 my @urls;
                 if ($ns && $group) {
-                        $ns = [ $ns ] if ref($ns) ne 'ARRAY';
                         @urls = map {
                                 my $u = m!\Anntps?://! ? $_ : "nntp://$_";
                                 $u .= '/' if $u !~ m!/\z!;
                                 $u.$group;
                         } @$ns;
                 }
-
                 my $mirrors = $self->{nntpmirror};
                 if ($mirrors) {
                         my @m;
diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm
index fabe39f6..177d55e4 100644
--- a/lib/PublicInbox/WwwText.pm
+++ b/lib/PublicInbox/WwwText.pm
@@ -210,7 +210,7 @@ EOF
                 defined(my $v = $ibx->{$k}) or next;
                 $$txt .= "\t$k = $v\n";
         }
-        $$txt .= "\tnntpmirror = $_\n" for (@{$ibx->nntp_url});
+        $$txt .= "\tnntpmirror = $_\n" for (@{$ibx->nntp_url($ctx)});
         _coderepo_config($ctx, $txt);
         1;
 }
@@ -343,7 +343,7 @@ EOM
 Example config snippet for mirrors: $cfg_link
 EOF
         if ($ibx->can('nntp_url')) {
-                my $nntp = $ibx->nntp_url;
+                my $nntp = $ibx->nntp_url($ctx);
                 if (scalar @$nntp) {
                         $$txt .= "\n";
                         $$txt .= @$nntp == 1 ? 'Newsgroup' : 'Newsgroups are';