1 # Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # represents an NNTPD (currently a singleton),
5 # see script/public-inbox-nntpd for how it is used
6 package PublicInbox::NNTPD;
10 require PublicInbox::Config;
14 my $pi_config = PublicInbox::Config->new;
15 my $name = $pi_config->{'publicinbox.nntpserver'};
16 if (!defined($name) or $name eq '') {
18 } elsif (ref($name) eq 'ARRAY') {
31 sub refresh_groups () {
33 my $pi_config = PublicInbox::Config->new;
36 $pi_config->each_inbox(sub {
38 my $ngname = $ng->{newsgroup} or return;
40 warn 'multiple newsgroups not supported: '.
41 join(', ', @$ngname). "\n";
42 } elsif ($ng->nntp_usable) {
43 # Only valid if msgmap and search works
44 $new->{$ngname} = $ng;
48 @list = sort { $a->{newsgroup} cmp $b->{newsgroup} } @list;
49 $self->{grouplist} = \@list;
50 # this will destroy old groups that got deleted
51 %{$self->{groups}} = %$new;