diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-22 17:31:03 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-22 17:31:03 +0100 |
commit | 9b26e251e3d6d7b850064a2c1ed5bb5870918f1e (patch) | |
tree | a90c8adb0a97e7e58c90727d7ad7419a5fa0ccd6 /src/imap | |
parent | 2adf73dd8e6e76997d4fb67f9f7b3fe065530722 (diff) | |
download | aerogramme-9b26e251e3d6d7b850064a2c1ed5bb5870918f1e.tar.gz aerogramme-9b26e251e3d6d7b850064a2c1ed5bb5870918f1e.zip |
formatting
Diffstat (limited to 'src/imap')
-rw-r--r-- | src/imap/command/authenticated.rs | 11 | ||||
-rw-r--r-- | src/imap/command/selected.rs | 7 | ||||
-rw-r--r-- | src/imap/flow.rs | 2 | ||||
-rw-r--r-- | src/imap/mailbox_view.rs | 10 | ||||
-rw-r--r-- | src/imap/mod.rs | 2 | ||||
-rw-r--r-- | src/imap/session.rs | 10 |
6 files changed, 25 insertions, 17 deletions
diff --git a/src/imap/command/authenticated.rs b/src/imap/command/authenticated.rs index 129c2fd..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, Vec1, 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}; @@ -14,12 +14,12 @@ use imap_codec::imap_types::mailbox::{ListMailbox, Mailbox as MailboxCodec}; use imap_codec::imap_types::response::{Code, CodeOther, Data}; use imap_codec::imap_types::status::{StatusDataItem, StatusDataItemName}; -use crate::imap::Body; use crate::imap::capability::{ClientCapability, ServerCapability}; use crate::imap::command::{anystate, MailboxName}; use crate::imap::flow; use crate::imap::mailbox_view::{MailboxView, UpdateParameters}; use crate::imap::response::Response; +use crate::imap::Body; use crate::mail::uidindex::*; use crate::mail::user::{User, MAILBOX_HIERARCHY_DELIMITER as MBX_HIER_DELIM_RAW}; @@ -560,8 +560,6 @@ 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_view, uidvalidity, uid, _modseq)) => Ok(( Response::build() .tag(append_tag) @@ -623,8 +621,9 @@ 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) = view.internal.mailbox.append(msg, None, &flags[..]).await?; - //let unsollicited = view.update(UpdateParameters::default()).await?; + let (uidvalidity, uid, modseq) = + view.internal.mailbox.append(msg, None, &flags[..]).await?; + //let unsollicited = view.update(UpdateParameters::default()).await?; Ok((view, uidvalidity, uid, modseq)) } diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs index e871509..d000905 100644 --- a/src/imap/command/selected.rs +++ b/src/imap/command/selected.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use anyhow::Result; use imap_codec::imap_types::command::{Command, CommandBody, FetchModifier, StoreModifier}; -use imap_codec::imap_types::core::{Vec1, Charset}; +use imap_codec::imap_types::core::{Charset, Vec1}; 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; @@ -59,7 +59,10 @@ pub async fn dispatch<'a>( charset, criteria, uid, - } => ctx.search(charset, &SearchKey::And(criteria.clone()), uid).await, + } => { + ctx.search(charset, &SearchKey::And(criteria.clone()), uid) + .await + } CommandBody::Expunge { // UIDPLUS (rfc4315) uid_sequence_set, diff --git a/src/imap/flow.rs b/src/imap/flow.rs index 4405e71..e372d69 100644 --- a/src/imap/flow.rs +++ b/src/imap/flow.rs @@ -2,8 +2,8 @@ use std::error::Error as StdError; use std::fmt; use std::sync::Arc; -use tokio::sync::Notify; use imap_codec::imap_types::core::Tag; +use tokio::sync::Notify; use crate::imap::mailbox_view::MailboxView; use crate::mail::user::User; diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs index f6395b4..1c53b93 100644 --- a/src/imap/mailbox_view.rs +++ b/src/imap/mailbox_view.rs @@ -370,7 +370,7 @@ impl MailboxView { .fetch() .zip(futures::stream::iter(mail_idx_list)) // [3/6] Derive an IMAP-specific view from the results, apply the filters - .map(|(maybe_qr, midx)| match maybe_qr { + .map(|(maybe_qr, midx)| match maybe_qr { Ok(qr) => Ok((MailView::new(&qr, midx)?.filter(&ap)?, midx)), Err(e) => Err(e), }) @@ -381,7 +381,10 @@ impl MailboxView { // [5/6] Register the \Seen flags if matches!(seen, SeenFlag::MustAdd) { let seen_flag = Flag::Seen.to_string(); - self.internal.mailbox.add_flags(midx.uuid, &[seen_flag]).await?; + self.internal + .mailbox + .add_flags(midx.uuid, &[seen_flag]) + .await?; } Ok::<_, anyhow::Error>(body) @@ -429,13 +432,12 @@ impl MailboxView { Ok(true) => Some(Ok(*midx)), Ok(_) => None, Err(e) => Some(Err(e)), - } + }, Err(e) => Some(Err(e)), }; futures::future::ready(r) }); - // 7. Chain both streams (part resolved from index, part resolved from metadata+body) let main_stream = futures::stream::iter(kept_idx) .map(Ok) diff --git a/src/imap/mod.rs b/src/imap/mod.rs index dbf72fe..02ab9ce 100644 --- a/src/imap/mod.rs +++ b/src/imap/mod.rs @@ -15,7 +15,7 @@ mod session; use std::net::SocketAddr; -use anyhow::{anyhow, bail, Result, Context}; +use anyhow::{anyhow, bail, Context, Result}; use futures::stream::{FuturesUnordered, StreamExt}; use tokio::net::TcpListener; diff --git a/src/imap/session.rs b/src/imap/session.rs index 9165574..fa3232a 100644 --- a/src/imap/session.rs +++ b/src/imap/session.rs @@ -4,8 +4,8 @@ use crate::imap::flow; use crate::imap::request::Request; use crate::imap::response::{Response, ResponseOrIdle}; use crate::login::ArcLoginProvider; -use anyhow::{anyhow, bail, Result, Context}; -use imap_codec::imap_types::{core::Tag, command::Command}; +use anyhow::{anyhow, bail, Context, Result}; +use imap_codec::imap_types::{command::Command, core::Tag}; //----- pub struct Instance { @@ -43,7 +43,11 @@ impl Instance { .state .apply(transition) .context("IDLE transition failed") - .and_then(|_| self.state.notify().ok_or(anyhow!("IDLE state has no Notify object"))); + .and_then(|_| { + self.state + .notify() + .ok_or(anyhow!("IDLE state has no Notify object")) + }); // Build an appropriate response match maybe_stop { |