diff --git a/src/parse.rs b/src/parse.rs index b2dc002f..eae2a1f3 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -331,6 +331,17 @@ fn handle_unilateral<'a>( Response::Expunge(n) => { unsolicited.send(UnsolicitedResponse::Expunge(n)).unwrap(); } + Response::Data { + status, + code, + information, + } if imap_proto::Status::Ok == status && code.is_none() => { + unsolicited + .send(UnsolicitedResponse::Uncategorised( + information.unwrap_or("").to_string(), + )) + .unwrap(); + } res => { return Some(res); } @@ -439,6 +450,20 @@ mod tests { assert_eq!(fetches[0].uid, Some(74)); } + #[test] + fn parse_uncategorised_ok() { + let lines = b"\ + * OK Searched 91% of the mailbox, ETA 0:01\r\n"; + let (mut send, recv) = mpsc::channel(); + parse_fetches(lines.to_vec(), &mut send).unwrap(); + assert_eq!( + recv.try_recv(), + Ok(UnsolicitedResponse::Uncategorised( + "Searched 91% of the mailbox, ETA 0:01".to_string() + )) + ); + } + #[test] fn parse_names_w_unilateral() { let lines = b"\ diff --git a/src/types/mod.rs b/src/types/mod.rs index fb57e4e8..4689b7cf 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -277,6 +277,10 @@ pub enum UnsolicitedResponse { /// sequence numbers 9, 8, 7, 6, and 5. // TODO: the spec doesn't seem to say anything about when these may be received as unsolicited? Expunge(Seq), + /// An uncategorised response - one which has no code associated with it, just a text + /// Dovecot is known to send a status message with an ETA for a long running fetch which + /// has no [] enclosed code. + Uncategorised(String), } /// This type wraps an input stream and a type that was constructed by parsing that input stream,