summaryrefslogtreecommitdiff
path: root/src/cmd/remove.rs
blob: 8d26e68d222e0e27a049add40a0693d7ef367d22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::path::PathBuf;

use protobuf::Message as _;

use crate::cmd::open_submaildir;
use crate::error::Result;
use crate::pb3::jwebmail::{RemoveReq, RemoveResp};

pub fn remove(p: PathBuf, req: &[u8]) -> Result<Vec<u8>> {
    let r = RemoveReq::parse_from_bytes(req)?;

    let md = open_submaildir(p, &r.folder);
    md.add_flags(&r.mid, "T")?;

    let resp = RemoveResp::new();
    resp.write_to_bytes().map_err(|e| e.into())
}