]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imap: support the CLOSE command
authorEric Wong <e@yhbt.net>
Wed, 10 Jun 2020 07:04:18 +0000 (07:04 +0000)
committerEric Wong <e@yhbt.net>
Sat, 13 Jun 2020 07:55:45 +0000 (07:55 +0000)
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
t/imapd.t

index 54c616eee2fd307f39a102384be59dcd9416f99e..0852ffab868dc61bfba42d9ca8f1858911ddcfd0 100644 (file)
@@ -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};
index 1ec0d5c370fcd6220e2c95d5f527f605bf598d19..8172a91923d3777de714a989ed03d5716942f75d 100644 (file)
--- 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;