From faca15f164c8e2860d27144f75f2dee05742ec6d Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 13 Jul 2022 11:19:08 +0200 Subject: LMTP refactoring, implement EXPUNGE --- src/imap/mailbox_view.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/imap') 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::>(); 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> { - 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 -- cgit v1.2.3