summaryrefslogtreecommitdiff
path: root/src/cmd/remove.rs
blob: 991c8357bf8ee9c07b3a2d3fadaa8312505baef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::cmd::{open_submaildir, MailStorage};
use crate::de_jmhoffmann_jwebmail_mailstorage::Call_Remove;

pub fn remove(
    ms: &MailStorage,
    call: &mut dyn Call_Remove,
    folder: String,
    mid: String,
) -> varlink::Result<()> {
    if let Some(p) = ms.maildir_path.read().unwrap().clone() {
        let md = open_submaildir(p, &folder);

        md.delete(&mid).map_err(varlink::map_context!())?;

        call.reply()
    } else {
        call.reply_not_initialized()
    }
}