Private
Public Access
1
0

plub through attachment guids via messages

This commit is contained in:
2025-05-26 16:52:38 -07:00
parent 2b5df53cc3
commit e55b29eb4d
15 changed files with 214 additions and 20 deletions

View File

@@ -17,6 +17,7 @@ keyring = { version = "3.6.2", features = ["sync-secret-service"] }
kordophone = { path = "../kordophone" }
kordophone-db = { path = "../kordophone-db" }
log = "0.4.25"
serde_json = "1.0"
thiserror = "2.0.12"
tokio = { version = "1", features = ["full"] }
tokio-condvar = "0.3.0"

View File

@@ -58,7 +58,16 @@
<method name="GetMessages">
<arg type="s" name="conversation_id" direction="in"/>
<arg type="s" name="last_message_id" direction="in"/>
<arg type="aa{sv}" direction="out" name="messages"/>
<arg type="aa{sv}" direction="out" name="messages">
<annotation name="org.freedesktop.DBus.DocString"
value="Array of dictionaries. Each dictionary has keys:
'id' (string): Unique message identifier
'text' (string): Message body text
'date' (int64): Message timestamp
'sender' (string): Sender display name
'file_transfer_guids' (string, optional): JSON array of file transfer GUIDs
'attachment_metadata' (string, optional): JSON string of attachment metadata"/>
</arg>
</method>
<method name="SendMessage">

View File

@@ -128,6 +128,7 @@ impl DbusRepository for ServerImpl {
messages
.into_iter()
.map(|msg| {
let msg_id = msg.id.clone(); // Store ID for potential error logging
let mut map = arg::PropMap::new();
map.insert("id".into(), arg::Variant(Box::new(msg.id)));
map.insert("text".into(), arg::Variant(Box::new(msg.text)));
@@ -139,6 +140,31 @@ impl DbusRepository for ServerImpl {
"sender".into(),
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)));
}
Err(e) => {
log::warn!("Failed to serialize file transfer GUIDs for message {}: {}", msg_id, e);
}
}
}
// 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
})
.collect()