From 1804e2961f3a28045b601a982f44ff61ea33a2fe Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 10 Jun 2020 07:04:18 +0000 Subject: [PATCH] imap: support the CLOSE command It seems worthless to support CLOSE for read-only inboxes, but mutt sends it, so don't return a BAD error with proper use. --- lib/PublicInbox/IMAP.pm | 6 ++++++ t/imapd.t | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index 54c616ee..0852ffab 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -121,6 +121,12 @@ sub cmd_login ($$$$) { login_success($self, $tag); } +sub cmd_close ($$) { + my ($self, $tag) = @_; + delete $self->{ibx} ? "$tag OK Close done\r\n" + : "$tag BAD No mailbox\r\n"; +} + sub cmd_logout ($$) { my ($self, $tag) = @_; delete $self->{logged_in}; diff --git a/t/imapd.t b/t/imapd.t index 1ec0d5c3..8172a919 100644 --- a/t/imapd.t +++ b/t/imapd.t @@ -327,7 +327,8 @@ $r2 = $mic->fetch_hash(2, 'BODY.PEEK[HEADER.FIELDS (message-id)]') is($r2->{2}->{'BODY[HEADER.FIELDS (MESSAGE-ID)]'}, 'Message-ID: <20200418222508.GA13918@dcvr>'."\r\n\r\n", 'BODY.PEEK[HEADER.FIELDS ...] drops .PEEK'); - +ok($mic->close, 'CLOSE works'); +ok(!$mic->close, 'CLOSE not idempotent'); ok($mic->logout, 'logged out'); $td->kill; -- 2.44.0