diff options
Diffstat (limited to 'src/imap')
-rw-r--r-- | src/imap/capability.rs | 11 | ||||
-rw-r--r-- | src/imap/command/authenticated.rs | 18 | ||||
-rw-r--r-- | src/imap/command/examined.rs | 6 | ||||
-rw-r--r-- | src/imap/command/selected.rs | 10 |
4 files changed, 23 insertions, 22 deletions
diff --git a/src/imap/capability.rs b/src/imap/capability.rs index 37f14df..53d7b7d 100644 --- a/src/imap/capability.rs +++ b/src/imap/capability.rs @@ -1,4 +1,5 @@ -use imap_codec::imap_types::core::{Atom, NonEmptyVec}; +use imap_codec::imap_types::command::SelectExamineModifier; +use imap_codec::imap_types::core::NonEmptyVec; use imap_codec::imap_types::extensions::enable::{CapabilityEnable, Utf8Kind}; use imap_codec::imap_types::response::Capability; use std::collections::HashSet; @@ -90,10 +91,10 @@ impl ClientCapability { self.condstore = self.condstore.enable(); } - pub fn select_enable(&mut self, atoms: &[Atom]) { - for at in atoms.iter() { - if at.as_ref().to_uppercase() == "CONDSTORE" { - self.enable_condstore(); + pub fn select_enable(&mut self, mods: &[SelectExamineModifier]) { + for m in mods.iter() { + match m { + SelectExamineModifier::Condstore => self.enable_condstore(), } } } diff --git a/src/imap/command/authenticated.rs b/src/imap/command/authenticated.rs index da41182..9b6bb24 100644 --- a/src/imap/command/authenticated.rs +++ b/src/imap/command/authenticated.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use std::sync::Arc; use anyhow::{anyhow, bail, Result}; -use imap_codec::imap_types::command::{Command, CommandBody}; +use imap_codec::imap_types::command::{Command, CommandBody, SelectExamineModifier}; use imap_codec::imap_types::core::{Atom, Literal, NonEmptyVec, QuotedChar}; use imap_codec::imap_types::datetime::DateTime; use imap_codec::imap_types::extensions::enable::CapabilityEnable; @@ -58,8 +58,8 @@ pub async fn dispatch<'a>( } => ctx.status(mailbox, item_names).await, CommandBody::Subscribe { mailbox } => ctx.subscribe(mailbox).await, CommandBody::Unsubscribe { mailbox } => ctx.unsubscribe(mailbox).await, - CommandBody::Select { mailbox, parameters } => ctx.select(mailbox, parameters).await, - CommandBody::Examine { mailbox, parameters } => ctx.examine(mailbox, parameters).await, + CommandBody::Select { mailbox, modifiers } => ctx.select(mailbox, modifiers).await, + CommandBody::Examine { mailbox, modifiers } => ctx.examine(mailbox, modifiers).await, CommandBody::Append { mailbox, flags, @@ -422,11 +422,9 @@ impl<'a> AuthenticatedContext<'a> { async fn select( self, mailbox: &MailboxCodec<'a>, - parameters: &Option<NonEmptyVec<Atom<'a>>>, + modifiers: &[SelectExamineModifier], ) -> Result<(Response<'static>, flow::Transition)> { - parameters.as_ref().map(|plist| - self.client_capabilities.select_enable(plist.as_ref()) - ); + self.client_capabilities.select_enable(modifiers); let name: &str = MailboxName(mailbox).try_into()?; @@ -462,11 +460,9 @@ impl<'a> AuthenticatedContext<'a> { async fn examine( self, mailbox: &MailboxCodec<'a>, - parameters: &Option<NonEmptyVec<Atom<'a>>>, + modifiers: &[SelectExamineModifier], ) -> Result<(Response<'static>, flow::Transition)> { - parameters.as_ref().map(|plist| - self.client_capabilities.select_enable(plist.as_ref()) - ); + self.client_capabilities.select_enable(modifiers); let name: &str = MailboxName(mailbox).try_into()?; diff --git a/src/imap/command/examined.rs b/src/imap/command/examined.rs index bb05250..a8077e3 100644 --- a/src/imap/command/examined.rs +++ b/src/imap/command/examined.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use anyhow::Result; -use imap_codec::imap_types::command::{Command, CommandBody}; +use imap_codec::imap_types::command::{Command, CommandBody, FetchModifier}; use imap_codec::imap_types::core::Charset; use imap_codec::imap_types::fetch::MacroOrMessageDataItemNames; use imap_codec::imap_types::search::SearchKey; @@ -37,8 +37,9 @@ pub async fn dispatch(ctx: ExaminedContext<'_>) -> Result<(Response<'static>, fl CommandBody::Fetch { sequence_set, macro_or_item_names, + modifiers, uid, - } => ctx.fetch(sequence_set, macro_or_item_names, uid).await, + } => ctx.fetch(sequence_set, macro_or_item_names, modifiers, uid).await, CommandBody::Search { charset, criteria, @@ -88,6 +89,7 @@ impl<'a> ExaminedContext<'a> { self, sequence_set: &SequenceSet, attributes: &'a MacroOrMessageDataItemNames<'static>, + modifiers: &[FetchModifier], uid: &bool, ) -> Result<(Response<'static>, flow::Transition)> { match self.mailbox.fetch(sequence_set, attributes, uid).await { diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs index de59ed3..862d4aa 100644 --- a/src/imap/command/selected.rs +++ b/src/imap/command/selected.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use anyhow::Result; -use imap_codec::imap_types::command::{Command, CommandBody, StoreModifier}; -use imap_codec::imap_types::core::{Charset, Atom}; +use imap_codec::imap_types::command::{Command, CommandBody, FetchModifier, StoreModifier}; +use imap_codec::imap_types::core::Charset; use imap_codec::imap_types::fetch::MacroOrMessageDataItemNames; use imap_codec::imap_types::flag::{Flag, StoreResponse, StoreType}; use imap_codec::imap_types::mailbox::Mailbox as MailboxCodec; @@ -43,8 +43,9 @@ pub async fn dispatch<'a>( CommandBody::Fetch { sequence_set, macro_or_item_names, + modifiers, uid, - } => ctx.fetch(sequence_set, macro_or_item_names, uid).await, + } => ctx.fetch(sequence_set, macro_or_item_names, modifiers, uid).await, CommandBody::Search { charset, criteria, @@ -114,6 +115,7 @@ impl<'a> SelectedContext<'a> { self, sequence_set: &SequenceSet, attributes: &'a MacroOrMessageDataItemNames<'static>, + modifiers: &[FetchModifier], uid: &bool, ) -> Result<(Response<'static>, flow::Transition)> { match self.mailbox.fetch(sequence_set, attributes, uid).await { @@ -194,7 +196,7 @@ impl<'a> SelectedContext<'a> { kind: &StoreType, response: &StoreResponse, flags: &[Flag<'a>], - modifiers: &[(Atom<'a>, StoreModifier<'a>)], + modifiers: &[StoreModifier], uid: &bool, ) -> Result<(Response<'static>, flow::Transition)> { tracing::info!(modifiers=?modifiers); |