]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NNTPD.pm
www_stream: fix search for new.html endpoint
[public-inbox.git] / lib / PublicInbox / NNTPD.pm
index 85109ea7ed57b722d8822c51339635c4b8ca6649..50d022be4ae2142ca3bcb39c378c70c8ab349f04 100644 (file)
@@ -6,7 +6,6 @@
 package PublicInbox::NNTPD;
 use strict;
 use warnings;
-require PublicInbox::NewsGroup;
 require PublicInbox::Config;
 
 sub new {
@@ -26,31 +25,20 @@ sub refresh_groups () {
        my @list;
        foreach my $k (keys %$pi_config) {
                $k =~ /\Apublicinbox\.([^\.]+)\.mainrepo\z/ or next;
-               my $g = $1;
+               my $name = $1;
                my $git_dir = $pi_config->{$k};
-               my $addr = $pi_config->{"publicinbox.$g.address"};
-               my $ngname = $pi_config->{"publicinbox.$g.newsgroup"};
-               if (defined $ngname) {
-                       next if ($ngname eq ''); # disabled
-                       $g = $ngname;
-               }
-               my $ng = PublicInbox::NewsGroup->new($g, $git_dir, $addr);
-               my $old_ng = $self->{groups}->{$g};
-
-               # Reuse the old one if possible since it can hold
-               # references to valid mm and gcf objects
-               if ($old_ng) {
-                       $old_ng->update($ng);
-                       $ng = $old_ng;
-               }
+               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->usable) {
-                       $new->{$g} = $ng;
+               if ($ng->nntp_usable) {
+                       $new->{$ngname} = $ng;
                        push @list, $ng;
                }
        }
-       @list = sort { $a->{name} cmp $b->{name} } @list;
+       @list = sort { $a->{newsgroup} cmp $b->{newsgroup} } @list;
        $self->{grouplist} = \@list;
        # this will destroy old groups that got deleted
        %{$self->{groups}} = %$new;