]> 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 <e@80x24.org>
Tue, 3 Apr 2018 10:08:57 +0000 (10:08 +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 267fe4b93067189661204d408a842ea8f89dfb19..23be7754445b01686a6df0e209ef539cd285553b 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 9ab5afe6d619860a1277314b5680350a109897b8..df02e0b567587a728cd1d2d71511d96c92bb1a74 100644 (file)
@@ -281,6 +281,19 @@ sub query_xover {
        _do_enquire($self, $query, {num => 1, limit => 200, offset => $offset});
 }
 
+sub query_ts {
+       my ($self, $ts, $opts) = @_;
+       my $qp = $self->{qp_ts} ||= eval {
+               my $q = Search::Xapian::QueryParser->new;
+               $q->set_database($self->{xdb});
+               $q->add_valuerangeprocessor(
+                       Search::Xapian::NumberValueRangeProcessor->new(TS));
+               $q
+       };
+       my $query = $qp->parse_query($ts, QP_FLAGS);
+       _do_enquire($self, $query, $opts);
+}
+
 sub lookup_message {
        my ($self, $mid) = @_;
        $mid = mid_clean($mid);
index 56b1d604518558e67284580f08076eef6820c4d9..2815d8d641694073b2a62ee852735303c77c15ea 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -204,6 +204,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;