diff options
Diffstat (limited to 'src/imap/command/authenticated.rs')
-rw-r--r-- | src/imap/command/authenticated.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/imap/command/authenticated.rs b/src/imap/command/authenticated.rs index 26b1946..eb8833d 100644 --- a/src/imap/command/authenticated.rs +++ b/src/imap/command/authenticated.rs @@ -6,7 +6,7 @@ use anyhow::{anyhow, bail, Result}; use imap_codec::imap_types::command::{ Command, CommandBody, ListReturnItem, SelectExamineModifier, }; -use imap_codec::imap_types::core::{Atom, Literal, NonEmptyVec, QuotedChar}; +use imap_codec::imap_types::core::{Atom, Literal, QuotedChar, Vec1}; use imap_codec::imap_types::datetime::DateTime; use imap_codec::imap_types::extensions::enable::CapabilityEnable; use imap_codec::imap_types::flag::{Flag, FlagNameAttribute}; @@ -17,10 +17,10 @@ use imap_codec::imap_types::status::{StatusDataItem, StatusDataItemName}; use crate::imap::capability::{ClientCapability, ServerCapability}; use crate::imap::command::{anystate, MailboxName}; use crate::imap::flow; -use crate::imap::mailbox_view::MailboxView; +use crate::imap::mailbox_view::{MailboxView, UpdateParameters}; use crate::imap::response::Response; +use crate::imap::Body; -use crate::mail::mailbox::Mailbox; use crate::mail::uidindex::*; use crate::mail::user::{User, MAILBOX_HIERARCHY_DELIMITER as MBX_HIER_DELIM_RAW}; use crate::mail::IMF; @@ -549,6 +549,8 @@ impl<'a> AuthenticatedContext<'a> { )) } + //@FIXME we should write a specific version for the "selected" state + //that returns some unsollicited responses async fn append( self, mailbox: &MailboxCodec<'a>, @@ -558,7 +560,7 @@ impl<'a> AuthenticatedContext<'a> { ) -> Result<(Response<'static>, flow::Transition)> { let append_tag = self.req.tag.clone(); match self.append_internal(mailbox, flags, date, message).await { - Ok((_mb, uidvalidity, uid, _modseq)) => Ok(( + Ok((_mb_view, uidvalidity, uid, _modseq)) => Ok(( Response::build() .tag(append_tag) .message("APPEND completed") @@ -580,7 +582,7 @@ impl<'a> AuthenticatedContext<'a> { fn enable( self, - cap_enable: &NonEmptyVec<CapabilityEnable<'static>>, + cap_enable: &Vec1<CapabilityEnable<'static>>, ) -> Result<(Response<'static>, flow::Transition)> { let mut response_builder = Response::build().to_req(self.req); let capabilities = self.client_capabilities.try_enable(cap_enable.as_ref()); @@ -593,13 +595,14 @@ impl<'a> AuthenticatedContext<'a> { )) } + //@FIXME should be refactored and integrated to the mailbox view pub(crate) async fn append_internal( self, mailbox: &MailboxCodec<'a>, flags: &[Flag<'a>], date: &Option<DateTime>, message: &Literal<'a>, - ) -> Result<(Arc<Mailbox>, ImapUidvalidity, ImapUid, ModSeq)> { + ) -> Result<(MailboxView, ImapUidvalidity, ImapUid, ModSeq)> { let name: &str = MailboxName(mailbox).try_into()?; let mb_opt = self.user.open_mailbox(&name).await?; @@ -607,6 +610,7 @@ impl<'a> AuthenticatedContext<'a> { Some(mb) => mb, None => bail!("Mailbox does not exist"), }; + let mut view = MailboxView::new(mb, self.client_capabilities.condstore.is_enabled()).await; if date.is_some() { tracing::warn!("Cannot set date when appending message"); @@ -617,9 +621,11 @@ impl<'a> AuthenticatedContext<'a> { let flags = flags.iter().map(|x| x.to_string()).collect::<Vec<_>>(); // TODO: filter allowed flags? ping @Quentin - let (uidvalidity, uid, modseq) = mb.append(msg, None, &flags[..]).await?; + let (uidvalidity, uid, modseq) = + view.internal.mailbox.append(msg, None, &flags[..]).await?; + //let unsollicited = view.update(UpdateParameters::default()).await?; - Ok((mb, uidvalidity, uid, modseq)) + Ok((view, uidvalidity, uid, modseq)) } } |