diff --git a/lib/src/private/imap/status_parser.dart b/lib/src/private/imap/status_parser.dart index 2199404d..47eaa6b0 100644 --- a/lib/src/private/imap/status_parser.dart +++ b/lib/src/private/imap/status_parser.dart @@ -48,6 +48,9 @@ class StatusParser extends ResponseParser { case 'UNSEEN': box.messagesUnseen = value; break; + case 'HIGHESTMODSEQ': + box.highestModSequence = value; + break; default: print( 'unexpected STATUS: $entry=${listEntries[i + 1]}\nin $details', diff --git a/test/src/imap/status_parser_test.dart b/test/src/imap/status_parser_test.dart index 6244118e..89dc7ef2 100644 --- a/test/src/imap/status_parser_test.dart +++ b/test/src/imap/status_parser_test.dart @@ -3,6 +3,7 @@ import 'package:enough_mail/src/private/imap/all_parsers.dart'; import 'package:enough_mail/src/private/imap/imap_response.dart'; import 'package:enough_mail/src/private/imap/imap_response_line.dart'; import 'package:test/test.dart'; + // cSpell:disable void main() { @@ -58,4 +59,26 @@ void main() { expect(processed, true); expect(box.messagesExists, 2); }); + + test('Status with HIGHESTMODSEQ', () { + // A CONDSTORE server includes HIGHESTMODSEQ when asked for it (RFC 7162 + // section 3.1.6). It used to fall into the default branch and be printed + // as unexpected instead of being recorded on the mailbox. + const responseText = + 'STATUS "INBOX" (MESSAGES 231 UNSEEN 5 HIGHESTMODSEQ 7011231777)'; + final details = ImapResponse()..add(ImapResponseLine(responseText)); + final box = Mailbox( + encodedName: 'INBOX', + encodedPath: 'INBOX', + flags: [MailboxFlag.inbox], + pathSeparator: '/', + ); + final parser = StatusParser(box); + final response = Response()..status = ResponseStatus.ok; + final processed = parser.parseUntagged(details, response); + expect(processed, true); + expect(box.messagesExists, 231); + expect(box.messagesUnseen, 5); + expect(box.highestModSequence, 7011231777); + }); }