aboutsummaryrefslogtreecommitdiff
path: root/src/imap
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-13 11:00:35 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-13 11:00:35 +0200
commita1ca6d9defc844fee52d966951701a57727050c7 (patch)
treefaccf61f4f882dc05f3812655bb6f58bde79b725 /src/imap
parent7959adb8e970c9006ea9799b5ddd6b2c9aac217a (diff)
downloadaerogramme-a1ca6d9defc844fee52d966951701a57727050c7.tar.gz
aerogramme-a1ca6d9defc844fee52d966951701a57727050c7.zip
"set flags" as a bayou op
Diffstat (limited to 'src/imap')
-rw-r--r--src/imap/command/selected.rs7
-rw-r--r--src/imap/mailbox_view.rs28
2 files changed, 11 insertions, 24 deletions
diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs
index a6fa645..1978729 100644
--- a/src/imap/command/selected.rs
+++ b/src/imap/command/selected.rs
@@ -62,7 +62,12 @@ impl<'a> SelectedContext<'a> {
}
async fn expunge(self) -> Result<(Response, flow::Transition)> {
- Ok((Response::bad("Not implemented")?, flow::Transition::None))
+ let data = self.mailbox.expunge().await?;
+
+ Ok((
+ Response::ok("EXPUNGE completed")?.with_body(data),
+ flow::Transition::None,
+ ))
}
async fn store(
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index 93d3b4d..f293bfa 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -169,29 +169,7 @@ impl MailboxView {
self.mailbox.del_flags(*uuid, &flags[..]).await?;
}
StoreType::Replace => {
- let old_flags = &self
- .known_state
- .table
- .get(uuid)
- .ok_or(anyhow!(
- "Missing message: {} (UID {}, UUID {})",
- i,
- uid,
- uuid
- ))?
- .1;
- let to_remove = old_flags
- .iter()
- .filter(|x| !flags.contains(&x))
- .cloned()
- .collect::<Vec<_>>();
- let to_add = flags
- .iter()
- .filter(|x| !old_flags.contains(&x))
- .cloned()
- .collect::<Vec<_>>();
- self.mailbox.add_flags(*uuid, &to_add[..]).await?;
- self.mailbox.del_flags(*uuid, &to_remove[..]).await?;
+ self.mailbox.set_flags(*uuid, &flags[..]).await?;
}
}
}
@@ -199,6 +177,10 @@ impl MailboxView {
self.update().await
}
+ pub async fn expunge(&mut self) -> Result<Vec<Body>> {
+ unimplemented!()
+ }
+
/// Looks up state changes in the mailbox and produces a set of IMAP
/// responses describing the new state.
pub async fn fetch(