mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
repl export-chat-requires destination path
and combind the public accessible functions into one
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
extern crate dirs;
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use anyhow::{bail, ensure, Error};
|
||||
use async_std::path::Path;
|
||||
@@ -15,7 +14,7 @@ use deltachat::context::*;
|
||||
use deltachat::dc_receive_imf::*;
|
||||
use deltachat::dc_tools::*;
|
||||
use deltachat::error::Error;
|
||||
use deltachat::export_chat::{export_chat, pack_exported_chat};
|
||||
use deltachat::export_chat::export_chat_to_zip;
|
||||
use deltachat::imex::*;
|
||||
use deltachat::location;
|
||||
use deltachat::log::LogExt;
|
||||
@@ -390,7 +389,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
||||
protect <chat-id>\n\
|
||||
unprotect <chat-id>\n\
|
||||
delchat <chat-id>\n\
|
||||
export-chat <chat-id>\n\
|
||||
export-chat <chat-id> <destination-file>\n\
|
||||
===========================Contact requests==\n\
|
||||
decidestartchat <msg-id>\n\
|
||||
decideblock <msg-id>\n\
|
||||
@@ -1028,24 +1027,10 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
||||
}
|
||||
"export-chat" => {
|
||||
ensure!(!arg1.is_empty(), "Argument <chat-id> missing.");
|
||||
ensure!(!arg2.is_empty(), "Argument <destination file> missing.");
|
||||
let chat_id = ChatId::new(arg1.parse()?);
|
||||
let res = export_chat(&context, chat_id).await;
|
||||
// println!("{:?}", res);
|
||||
let timestamp = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
let destination_raw = context.get_blobdir().join(format!(
|
||||
"exported_{}_{}.zip",
|
||||
chat_id.to_u32(),
|
||||
timestamp
|
||||
));
|
||||
let destination = destination_raw.to_str().unwrap();
|
||||
let pack_res = pack_exported_chat(&context, res, destination);
|
||||
match &pack_res {
|
||||
Ok(()) => println!("Exported chat successfully to {}", destination),
|
||||
Err(err) => println!("Error {:?}", err),
|
||||
};
|
||||
// todo check if path is valid (dest dir exists) and ends in .zip
|
||||
export_chat_to_zip(&context, chat_id, arg2).await;
|
||||
}
|
||||
"msginfo" => {
|
||||
ensure!(!arg1.is_empty(), "Argument <msg-id> missing.");
|
||||
|
||||
Reference in New Issue
Block a user