1 # Copyright (C) 2016 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;
9 require PublicInbox::NewsGroup;
10 require PublicInbox::Config;
22 sub refresh_groups () {
24 my $pi_config = PublicInbox::Config->new;
27 foreach my $k (keys %$pi_config) {
28 $k =~ /\Apublicinbox\.([^\.]+)\.mainrepo\z/ or next;
30 my $git_dir = $pi_config->{$k};
31 my $addr = $pi_config->{"publicinbox.$g.address"};
32 my $ngname = $pi_config->{"publicinbox.$g.newsgroup"};
33 my $url = $pi_config->{"publicinbox.$g.url"};
34 if (defined $ngname) {
35 next if ($ngname eq ''); # disabled
38 my $ng = PublicInbox::NewsGroup->new($g, $git_dir, $addr, $url);
39 my $old_ng = $self->{groups}->{$g};
41 # Reuse the old one if possible since it can hold
42 # references to valid mm and gcf objects
48 # Only valid if msgmap and search works
54 @list = sort { $a->{newsgroup} cmp $b->{newsgroup} } @list;
55 $self->{grouplist} = \@list;
56 # this will destroy old groups that got deleted
57 %{$self->{groups}} = %$new;