]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: fix NEWNEWS command
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sat, 3 Mar 2018 20:18:34 +0000 (20:18 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sat, 3 Mar 2018 20:18:34 +0000 (20:18 +0000)
I guess nobody uses this command (slrnpull does not), and
the breakage was not noticed until I started writing new
tests for multi-MID handling.

Fixes: 3fc411c772a21d8f ("search: drop pointless range processors for Unix timestamp")
lib/PublicInbox/NNTP.pm
lib/PublicInbox/Search.pm
t/nntpd.t

index 895e5023a50b702c17df31f82e86f1e203d97f9c..fb65ddc07dc060db7027bd86671d4f940776888a 100644 (file)
@@ -336,7 +336,7 @@ sub cmd_newnews ($$$$;$$) {
        long_response($self, 0, long_response_limit, sub {
                my ($i) = @_;
                my $srch = $srch[0];
-               my $res = $srch->query($ts, $opts);
+               my $res = $srch->query_ts($ts, $opts);
                my $msgs = $res->{msgs};
                if (my $nr = scalar @$msgs) {
                        more($self, '<' .
index 802984b0ab8b7109bc0ca6e6b7ce6f721dc5c884..4dc274723d6ca8e34ca19821256308d47ea7058d 100644 (file)
@@ -330,6 +330,20 @@ sub query_xover {
        _do_enquire($self, $query, $opts);
 }
 
+sub query_ts {
+       my ($self, $ts, $opts) = @_;
+       my $qp = $self->{qp_ts} ||= eval {
+               my $q = Search::Xapian::QueryParser->new;
+               $q->set_database($self->{skel} || $self->{xdb});
+               $q->add_valuerangeprocessor(
+                       Search::Xapian::NumberValueRangeProcessor->new(TS));
+               $q
+       };
+       my $query = $qp->parse_query($ts, QP_FLAGS);
+       $opts->{enquire} = enquire_skel($self);
+       _do_enquire($self, $query, $opts);
+}
+
 sub lookup_skeleton {
        my ($self, $mid) = @_;
        my $skel = $self->{skel} or return lookup_message($self, $mid);
index ea0d293947b9d42114d94144a98927ae1ff50c42..de781d74b3b85bc88ab193865200dc78ba3982a9 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -228,6 +228,8 @@ EOF
        is_deeply($n->xhdr(qw(list-id 1-)), {},
                 'XHDR on invalid header returns empty');
 
+       my $mids = $n->newnews(0, '*');
+       is_deeply($mids, ['<nntp@example.com>'], 'NEWNEWS works');
        {
                my $t0 = time;
                my $date = $n->date;