From 573aaf2a8ccdb6c8c917b2d88a39c9c8103f64ef Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Mon, 27 Jan 2025 16:55:41 +0100 Subject: Add compatibility middleware --- src/middleware/find_mailboxes_compatibility.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/middleware/find_mailboxes_compatibility.rs (limited to 'src/middleware/find_mailboxes_compatibility.rs') diff --git a/src/middleware/find_mailboxes_compatibility.rs b/src/middleware/find_mailboxes_compatibility.rs new file mode 100644 index 0000000..f1a450b --- /dev/null +++ b/src/middleware/find_mailboxes_compatibility.rs @@ -0,0 +1,14 @@ +use log::debug; + +/// MailDrop can't find folders to sync because it sends FIND MAILBOXES /* +/// which is not understood by modern servers. It instead replaces it with +/// a LIST command. +pub fn middleware(input: &[u8]) -> Vec { + let command = String::from_utf8_lossy(input); + if let Some(tag) = command.split("FIND MAILBOXES /*").next() { + let replacement = format!("{} LIST \"/INBOX\" \"*\"\r\n", tag.trim()); + debug!("### {replacement}"); + return replacement.into_bytes(); + } + return input.to_vec(); +} -- cgit