xpc: full attachment data
This commit is contained in:
@@ -164,6 +164,50 @@ pub async fn dispatch(
|
||||
.collect();
|
||||
m.insert(cstr("attachment_guids"), array_from_strs(attachment_guids));
|
||||
|
||||
// Full attachments array with metadata (mirrors DBus fields)
|
||||
let mut attachments_items: Vec<Message> = Vec::new();
|
||||
for attachment in msg.attachments.iter() {
|
||||
let mut a: XpcMap = HashMap::new();
|
||||
// Basic identifiers
|
||||
dict_put_str(&mut a, "guid", &attachment.guid);
|
||||
|
||||
// Paths and download status
|
||||
let path = attachment.get_path_for_preview(false);
|
||||
let preview_path = attachment.get_path_for_preview(true);
|
||||
let downloaded = attachment.is_downloaded(false);
|
||||
let preview_downloaded = attachment.is_downloaded(true);
|
||||
|
||||
dict_put_str(&mut a, "path", &path.to_string_lossy());
|
||||
dict_put_str(&mut a, "preview_path", &preview_path.to_string_lossy());
|
||||
dict_put_str(&mut a, "downloaded", &downloaded.to_string());
|
||||
dict_put_str(
|
||||
&mut a,
|
||||
"preview_downloaded",
|
||||
&preview_downloaded.to_string(),
|
||||
);
|
||||
|
||||
// Metadata (optional)
|
||||
if let Some(metadata) = &attachment.metadata {
|
||||
let mut metadata_map: XpcMap = HashMap::new();
|
||||
if let Some(attribution_info) = &metadata.attribution_info {
|
||||
let mut attribution_map: XpcMap = HashMap::new();
|
||||
if let Some(width) = attribution_info.width {
|
||||
dict_put_i64_as_str(&mut attribution_map, "width", width as i64);
|
||||
}
|
||||
if let Some(height) = attribution_info.height {
|
||||
dict_put_i64_as_str(&mut attribution_map, "height", height as i64);
|
||||
}
|
||||
metadata_map.insert(cstr("attribution_info"), Message::Dictionary(attribution_map));
|
||||
}
|
||||
if !metadata_map.is_empty() {
|
||||
a.insert(cstr("metadata"), Message::Dictionary(metadata_map));
|
||||
}
|
||||
}
|
||||
|
||||
attachments_items.push(Message::Dictionary(a));
|
||||
}
|
||||
m.insert(cstr("attachments"), Message::Array(attachments_items));
|
||||
|
||||
items.push(Message::Dictionary(m));
|
||||
}
|
||||
let mut reply: XpcMap = HashMap::new();
|
||||
|
||||
Reference in New Issue
Block a user