mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
add message info
This commit is contained in:
@@ -19,6 +19,7 @@ use serde::Serialize;
|
|||||||
pub struct ExportChatResult {
|
pub struct ExportChatResult {
|
||||||
chat_json: String,
|
chat_json: String,
|
||||||
// locations_geo_json: String,
|
// locations_geo_json: String,
|
||||||
|
message_info: Vec<(u32, String)>,
|
||||||
referenced_blobs: Vec<String>,
|
referenced_blobs: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +52,12 @@ pub fn pack_exported_chat(
|
|||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zip.add_directory("msg_info/", Default::default())?;
|
||||||
|
for msg_info in artifact.message_info {
|
||||||
|
zip.start_file_from_path(Path::new(&format!("msg_info/{}.txt", msg_info.0)), options)?;
|
||||||
|
zip.write_all((msg_info.1).as_bytes())?;
|
||||||
|
}
|
||||||
|
|
||||||
zip.finish()?;
|
zip.finish()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -215,12 +222,17 @@ pub async fn export_chat(context: &Context, chat_id: ChatId) -> ExportChatResult
|
|||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut message_info: Vec<(u32, String)> = Vec::new();
|
||||||
let mut message_json: Vec<MessageJSON> = Vec::new();
|
let mut message_json: Vec<MessageJSON> = Vec::new();
|
||||||
|
|
||||||
for message in &messages {
|
for message in &messages {
|
||||||
if let Ok(msg) = &message {
|
if let Ok(msg) = &message {
|
||||||
let msg_json: MessageJSON = MessageJSON::from_message(msg, &context).await;
|
let msg_json: MessageJSON = MessageJSON::from_message(msg, &context).await;
|
||||||
message_json.push(msg_json)
|
message_json.push(msg_json);
|
||||||
|
|
||||||
|
message_info.push((msg.id.to_u32(), get_msg_info(&context, msg.id).await))
|
||||||
|
} else {
|
||||||
|
// todo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +248,7 @@ pub async fn export_chat(context: &Context, chat_id: ChatId) -> ExportChatResult
|
|||||||
blobs.dedup();
|
blobs.dedup();
|
||||||
ExportChatResult {
|
ExportChatResult {
|
||||||
chat_json: serde_json::to_string(&chat_json).unwrap(),
|
chat_json: serde_json::to_string(&chat_json).unwrap(),
|
||||||
|
message_info: message_info,
|
||||||
referenced_blobs: blobs,
|
referenced_blobs: blobs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user