diff options
author | Eric Wong <e@80x24.org> | 2016-07-02 21:50:28 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-07-02 21:52:28 +0000 |
commit | 33cef7f24d3ddedc4cd79ee88b0bba6ed1aab4c9 (patch) | |
tree | 007d880f75e3d9ad06e732e098c2fa7d8b6fb72b /lib/PublicInbox/NNTPD.pm | |
parent | db07ffcc3243a19ff5b6edf7f3bfc19cb7460df0 (diff) | |
download | public-inbox-33cef7f24d3ddedc4cd79ee88b0bba6ed1aab4c9.tar.gz |
This fills in the internal lookup hashes and simplifies callers.
Diffstat (limited to 'lib/PublicInbox/NNTPD.pm')
-rw-r--r-- | lib/PublicInbox/NNTPD.pm | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/PublicInbox/NNTPD.pm b/lib/PublicInbox/NNTPD.pm index 50d022be..a67811bc 100644 --- a/lib/PublicInbox/NNTPD.pm +++ b/lib/PublicInbox/NNTPD.pm @@ -23,21 +23,18 @@ sub refresh_groups () { my $pi_config = PublicInbox::Config->new; my $new = {}; my @list; - foreach my $k (keys %$pi_config) { - $k =~ /\Apublicinbox\.([^\.]+)\.mainrepo\z/ or next; - my $name = $1; - my $git_dir = $pi_config->{$k}; - my $ngname = $pi_config->{"publicinbox.$name.newsgroup"}; - next unless defined $ngname; - next if ($ngname eq ''); # disabled - my $ng = $pi_config->lookup_newsgroup($ngname) or next; - - # Only valid if msgmap and search works - if ($ng->nntp_usable) { + $pi_config->each_inbox(sub { + my ($ng) = @_; + my $ngname = $ng->{newsgroup} or next; + if (ref $ngname) { + warn 'multiple newsgroups not supported: '. + join(', ', @$ngname). "\n"; + } elsif ($ng->nntp_usable) { + # Only valid if msgmap and search works $new->{$ngname} = $ng; push @list, $ng; } - } + }); @list = sort { $a->{newsgroup} cmp $b->{newsgroup} } @list; $self->{grouplist} = \@list; # this will destroy old groups that got deleted |