diff options
Diffstat (limited to 'src/imap/command/selected.rs')
-rw-r--r-- | src/imap/command/selected.rs | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs index cf0b71b..4e41561 100644 --- a/src/imap/command/selected.rs +++ b/src/imap/command/selected.rs @@ -1,4 +1,5 @@ use anyhow::{Error, Result}; +use boitalettres::proto::Request; use boitalettres::proto::Response; use imap_codec::types::command::CommandBody; use imap_codec::types::core::Tag; @@ -11,42 +12,38 @@ use crate::imap::flow; use crate::imap::session::InnerContext; use crate::mail::Mailbox; -pub async fn dispatch<'a>( - inner: InnerContext<'a>, - user: &'a flow::User, - mailbox: &'a Mailbox, -) -> Result<(Response, flow::Transition)> { - let ctx = StateContext { - inner, - user, - mailbox, - }; +pub struct SelectedContext<'a> { + pub req: &'a Request, + pub user: &'a flow::User, + pub mailbox: &'a mut Mailbox, +} - match &ctx.inner.req.command.body { +pub async fn dispatch<'a>(ctx: SelectedContext<'a>) -> Result<(Response, flow::Transition)> { + match &ctx.req.command.body { CommandBody::Fetch { sequence_set, attributes, uid, } => ctx.fetch(sequence_set, attributes, uid).await, - _ => authenticated::dispatch(ctx.inner, user).await, + _ => { + let ctx = authenticated::AuthenticatedContext { + req: ctx.req, + user: ctx.user, + }; + authenticated::dispatch(ctx).await + } } } // --- PRIVATE --- -struct StateContext<'a> { - inner: InnerContext<'a>, - user: &'a flow::User, - mailbox: &'a Mailbox, -} - -impl<'a> StateContext<'a> { +impl<'a> SelectedContext<'a> { pub async fn fetch( - &self, + self, sequence_set: &SequenceSet, attributes: &MacroOrFetchAttributes, uid: &bool, ) -> Result<(Response, flow::Transition)> { - Ok((Response::bad("Not implemented")?, flow::Transition::No)) + Ok((Response::bad("Not implemented")?, flow::Transition::None)) } } |