From a8d0e4a994daca39f9619cddf2847c1a7820c040 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 29 Jun 2022 17:58:31 +0200 Subject: Implement IDLE in selected state --- src/imap/command/anonymous.rs | 5 +---- src/imap/command/selected.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/imap/command') diff --git a/src/imap/command/anonymous.rs b/src/imap/command/anonymous.rs index 84d0dca..b84b0da 100644 --- a/src/imap/command/anonymous.rs +++ b/src/imap/command/anonymous.rs @@ -21,10 +21,7 @@ pub async fn dispatch<'a>(ctx: AnonymousContext<'a>) -> Result<(Response, flow:: CommandBody::Capability => ctx.capability().await, CommandBody::Logout => ctx.logout().await, CommandBody::Login { username, password } => ctx.login(username, password).await, - _ => Ok(( - Response::no("This command is not available in the ANONYMOUS state.")?, - flow::Transition::None, - )), + _ => Ok((Response::no("Command unavailable")?, flow::Transition::None)), } } diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs index cfc40c3..3a44a3f 100644 --- a/src/imap/command/selected.rs +++ b/src/imap/command/selected.rs @@ -21,6 +21,7 @@ pub struct SelectedContext<'a> { pub async fn dispatch<'a>(ctx: SelectedContext<'a>) -> Result<(Response, flow::Transition)> { match &ctx.req.command.body { + CommandBody::Noop => ctx.noop().await, CommandBody::Fetch { sequence_set, attributes, @@ -47,4 +48,12 @@ impl<'a> SelectedContext<'a> { ) -> Result<(Response, flow::Transition)> { Ok((Response::bad("Not implemented")?, flow::Transition::None)) } + + pub async fn noop(self) -> Result<(Response, flow::Transition)> { + let updates = self.mailbox.update().await?; + Ok(( + Response::ok("Noop completed.")?.with_body(updates), + flow::Transition::None, + )) + } } -- cgit v1.2.3