fetch: support fetching mails before a specified date

This commit is contained in:
rustmailer
2025-12-29 12:06:04 +08:00
parent 06a126461b
commit 76ab16b55b
4 changed files with 119 additions and 35 deletions
+8 -1
View File
@@ -84,12 +84,19 @@ impl ImapExecutor {
account: &AccountModel,
mailbox: &MailBox,
start_uid: u64,
before: Option<&str>
) -> BichonResult<()> {
assert!(start_uid > 0, "start_uid must be greater than 0");
let query = match before {
Some(date) => format!("UID {start_uid}:* BEFORE {date}"),
None => format!("UID {start_uid}:*"),
};
let uid_list = self
.uid_search(
&mailbox.encoded_name(),
format!("UID {start_uid}:*").as_str(),
&query,
)
.await?;