aboutsummaryrefslogtreecommitdiff
path: root/src/imap
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-13 11:19:08 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-13 11:19:08 +0200
commitfaca15f164c8e2860d27144f75f2dee05742ec6d (patch)
treee81ef9a4360e20685b0f8b2e14ee024119b69fd7 /src/imap
parenta1ca6d9defc844fee52d966951701a57727050c7 (diff)
downloadaerogramme-faca15f164c8e2860d27144f75f2dee05742ec6d.tar.gz
aerogramme-faca15f164c8e2860d27144f75f2dee05742ec6d.zip
LMTP refactoring, implement EXPUNGE
Diffstat (limited to 'src/imap')
-rw-r--r--src/imap/mailbox_view.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index f293bfa..371bc50 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -160,7 +160,7 @@ impl MailboxView {
let flags = flags.iter().map(|x| x.to_string()).collect::<Vec<_>>();
let mails = self.get_mail_ids(sequence_set)?;
- for (i, uid, uuid) in mails.iter() {
+ for (_i, _uid, uuid) in mails.iter() {
match kind {
StoreType::Add => {
self.mailbox.add_flags(*uuid, &flags[..]).await?;
@@ -178,7 +178,19 @@ impl MailboxView {
}
pub async fn expunge(&mut self) -> Result<Vec<Body>> {
- unimplemented!()
+ let deleted_flag = Flag::Deleted.to_string();
+ let msgs = self
+ .known_state
+ .table
+ .iter()
+ .filter(|(_uuid, (_uid, flags))| flags.iter().any(|x| *x == deleted_flag))
+ .map(|(uuid, _)| *uuid);
+
+ for msg in msgs {
+ self.mailbox.delete(msg).await?;
+ }
+
+ self.update().await
}
/// Looks up state changes in the mailbox and produces a set of IMAP