aboutsummaryrefslogtreecommitdiff
path: root/src/middleware/find_mailboxes_compatibility.rs
blob: b8bd33a67969f50cc0dc89feeb7d33dbc99ad29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 command.contains("FIND MAILBOXES /*") {
        if let Some(tag) = command.split("FIND MAILBOXES /*").next() {
            let replacement = format!("{} LIST \"/INBOX\" \"*\"\r\n", tag.trim());
            debug!("### {replacement}");
            return replacement.into_bytes();
        }
    }
    input.to_vec()
}