diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-27 16:55:41 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-27 16:55:41 +0100 |
| commit | 573aaf2a8ccdb6c8c917b2d88a39c9c8103f64ef (patch) | |
| tree | 50d7a14a99df2d8e3e98516c160da2b0e8d73a3b /src/middleware | |
| parent | 14c2e8bcb8c84ae5861b82045c60e49625d27299 (diff) | |
Add compatibility middleware
Diffstat (limited to 'src/middleware')
| -rw-r--r-- | src/middleware/find_mailboxes_compatibility.rs | 14 | ||||
| -rw-r--r-- | src/middleware/mod.rs | 7 |
2 files changed, 21 insertions, 0 deletions
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<u8> { + 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(); +} diff --git a/src/middleware/mod.rs b/src/middleware/mod.rs new file mode 100644 index 0000000..a1070f4 --- /dev/null +++ b/src/middleware/mod.rs @@ -0,0 +1,7 @@ +mod find_mailboxes_compatibility; + +use find_mailboxes_compatibility::middleware as find_mailboxes_compatibility_middleware; + +type Middleware = fn(&[u8]) -> Vec<u8>; + +pub const MIDDLEWARE: [Middleware; 1] = [find_mailboxes_compatibility_middleware]; |