plumb all known attachments via dbus if known
This commit is contained in:
@@ -138,29 +138,50 @@ impl DbusRepository for ServerImpl {
|
||||
arg::Variant(Box::new(msg.sender.display_name())),
|
||||
);
|
||||
|
||||
// Add file transfer GUIDs if present
|
||||
if !msg.file_transfer_guids.is_empty() {
|
||||
match serde_json::to_string(&msg.file_transfer_guids) {
|
||||
Ok(json_str) => {
|
||||
map.insert("file_transfer_guids".into(), arg::Variant(Box::new(json_str)));
|
||||
// Add attachments array
|
||||
let attachments: Vec<arg::PropMap> = msg.attachments
|
||||
.into_iter()
|
||||
.map(|attachment| {
|
||||
let mut attachment_map = arg::PropMap::new();
|
||||
attachment_map.insert("guid".into(), arg::Variant(Box::new(attachment.guid.clone())));
|
||||
|
||||
// Get attachment paths and download status
|
||||
let path = attachment.get_path(false);
|
||||
let preview_path = attachment.get_path(true);
|
||||
let downloaded = attachment.is_downloaded(false);
|
||||
let preview_downloaded = attachment.is_downloaded(true);
|
||||
|
||||
attachment_map.insert("path".into(), arg::Variant(Box::new(path.to_string_lossy().to_string())));
|
||||
attachment_map.insert("preview_path".into(), arg::Variant(Box::new(preview_path.to_string_lossy().to_string())));
|
||||
attachment_map.insert("downloaded".into(), arg::Variant(Box::new(downloaded)));
|
||||
attachment_map.insert("preview_downloaded".into(), arg::Variant(Box::new(preview_downloaded)));
|
||||
|
||||
// Add metadata if present
|
||||
if let Some(ref metadata) = attachment.metadata {
|
||||
let mut metadata_map = arg::PropMap::new();
|
||||
|
||||
// Add attribution_info if present
|
||||
if let Some(ref attribution_info) = metadata.attribution_info {
|
||||
let mut attribution_map = arg::PropMap::new();
|
||||
|
||||
if let Some(width) = attribution_info.width {
|
||||
attribution_map.insert("width".into(), arg::Variant(Box::new(width as i32)));
|
||||
}
|
||||
if let Some(height) = attribution_info.height {
|
||||
attribution_map.insert("height".into(), arg::Variant(Box::new(height as i32)));
|
||||
}
|
||||
|
||||
metadata_map.insert("attribution_info".into(), arg::Variant(Box::new(attribution_map)));
|
||||
}
|
||||
|
||||
attachment_map.insert("metadata".into(), arg::Variant(Box::new(metadata_map)));
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to serialize file transfer GUIDs for message {}: {}", msg_id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attachment_map
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Add attachment metadata if present
|
||||
if let Some(ref attachment_metadata) = msg.attachment_metadata {
|
||||
match serde_json::to_string(attachment_metadata) {
|
||||
Ok(json_str) => {
|
||||
map.insert("attachment_metadata".into(), arg::Variant(Box::new(json_str)));
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to serialize attachment metadata for message {}: {}", msg_id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
map.insert("attachments".into(), arg::Variant(Box::new(attachments)));
|
||||
|
||||
map
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user