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

use protobuf::Message as _;

use crate::cmd::open_submaildir;
use crate::error::Result;
use crate::pb3::jwebmail::{MoveReq, MoveResp};

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

    let from = open_submaildir(p.clone(), &r.from_f);
    let to = open_submaildir(p, &r.to_f);
    from.move_to(&r.mid, &to)?;

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