user/dev discussion of public-inbox itself
 help / color / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH] nntp: fix STAT command
Date: Sat,  1 Aug 2020 20:16:58 +0000
Message-ID: <20200801201658.16500-1-e@yhbt.net> (raw)

The return value of art_lookup changed but this command wasn't
updated since it wasn't tested.

Fixes: 0e6ceff37fc38f28 ("nntp: support slow blob retrievals")
---
 lib/PublicInbox/NNTP.pm | 8 ++++----
 t/nntpd.t               | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 87ddf7a4..595a4046 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -581,11 +581,11 @@ sub cmd_body ($;$) {
 
 sub cmd_stat ($;$) {
 	my ($self, $art) = @_;
-	my $r = art_lookup($self, $art);
-	return $r unless ref $r;
-	my ($n, $mid) = @$r;
+	my $smsg = art_lookup($self, $art); # art may be msgid
+	return $smsg unless ref $smsg;
+	$art = $smsg->{num};
 	set_art($self, $art);
-	"223 $n <$mid> article retrieved - request text separately";
+	"223 $art <$smsg->{mid}> article retrieved - request text separately";
 }
 
 sub cmd_ihave ($) { '435 article not wanted - do not send it' }
diff --git a/t/nntpd.t b/t/nntpd.t
index aaf6661d..0b4a2636 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -206,6 +206,7 @@ EOF
 
 	is_deeply($n->head(1), $n->head('<nntp@example.com>'), 'HEAD OK');
 	is_deeply($n->body(1), $n->body('<nntp@example.com>'), 'BODY OK');
+	is_deeply($n->nntpstat(1), '<nntp@example.com>', 'STAT');
 	is($n->body(1)->[0], "This is a test message for El\xc3\xa9anor\n",
 		'body really matches');
 	my $art = $n->article(1);

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200801201658.16500-1-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git