Private
Public Access
1
0

plumb attachment guids for sendmessage

This commit is contained in:
2025-06-12 20:36:40 -07:00
parent 930f905efc
commit ff03e73758
6 changed files with 22 additions and 8 deletions

View File

@@ -81,10 +81,20 @@
<method name="SendMessage"> <method name="SendMessage">
<arg type="s" name="conversation_id" direction="in"/> <arg type="s" name="conversation_id" direction="in"/>
<arg type="s" name="text" direction="in"/> <arg type="s" name="text" direction="in"/>
<arg type="as" name="attachment_guids" direction="in"/>
<arg type="s" name="outgoing_message_id" direction="out"/> <arg type="s" name="outgoing_message_id" direction="out"/>
<annotation name="org.freedesktop.DBus.DocString" <annotation name="org.freedesktop.DBus.DocString"
value="Sends a message to the server. Returns the outgoing message ID."/> value="Sends a message to the server. Returns the outgoing message ID.
Arguments:
- conversation_id: The ID of the conversation to send the message to.
- text: The text of the message to send.
- attachment_guids: The GUIDs of the attachments to send.
Returns:
- outgoing_message_id: The ID of the outgoing message.
"/>
</method> </method>
<signal name="MessagesUpdated"> <signal name="MessagesUpdated">

View File

@@ -48,8 +48,9 @@ pub enum Event {
/// Parameters: /// Parameters:
/// - conversation_id: The ID of the conversation to send the message to. /// - conversation_id: The ID of the conversation to send the message to.
/// - text: The text of the message to send. /// - text: The text of the message to send.
/// - attachment_guids: The GUIDs of the attachments to send.
/// - reply: The outgoing message ID (not the server-assigned message ID). /// - reply: The outgoing message ID (not the server-assigned message ID).
SendMessage(String, String, Reply<Uuid>), SendMessage(String, String, Vec<String>, Reply<Uuid>),
/// Notifies the daemon that a message has been sent. /// Notifies the daemon that a message has been sent.
/// Parameters: /// Parameters:

View File

@@ -251,10 +251,10 @@ impl Daemon {
reply.send(()).unwrap(); reply.send(()).unwrap();
} }
Event::SendMessage(conversation_id, text, reply) => { Event::SendMessage(conversation_id, text, attachment_guids, reply) => {
let conversation_id = conversation_id.clone(); let conversation_id = conversation_id.clone();
let uuid = self let uuid = self
.enqueue_outgoing_message(text, conversation_id.clone()) .enqueue_outgoing_message(text, conversation_id.clone(), attachment_guids)
.await; .await;
reply.send(uuid).unwrap(); reply.send(uuid).unwrap();
@@ -396,11 +396,12 @@ impl Daemon {
.await .await
} }
async fn enqueue_outgoing_message(&mut self, text: String, conversation_id: String) -> Uuid { async fn enqueue_outgoing_message(&mut self, text: String, conversation_id: String, attachment_guids: Vec<String>) -> Uuid {
let conversation_id = conversation_id.clone(); let conversation_id = conversation_id.clone();
let outgoing_message = OutgoingMessage::builder() let outgoing_message = OutgoingMessage::builder()
.text(text) .text(text)
.conversation_id(conversation_id.clone()) .conversation_id(conversation_id.clone())
.file_transfer_guids(attachment_guids)
.build(); .build();
// Keep a record of this so we can provide a consistent model to the client. // Keep a record of this so we can provide a consistent model to the client.

View File

@@ -226,8 +226,9 @@ impl DbusRepository for ServerImpl {
&mut self, &mut self,
conversation_id: String, conversation_id: String,
text: String, text: String,
attachment_guids: Vec<String>,
) -> Result<String, dbus::MethodErr> { ) -> Result<String, dbus::MethodErr> {
self.send_event_sync(|r| Event::SendMessage(conversation_id, text, r)) self.send_event_sync(|r| Event::SendMessage(conversation_id, text, attachment_guids, r))
.map(|uuid| uuid.to_string()) .map(|uuid| uuid.to_string())
} }

View File

@@ -177,8 +177,9 @@ impl DaemonCli {
conversation_id: String, conversation_id: String,
text: String, text: String,
) -> Result<()> { ) -> Result<()> {
let attachment_guids: Vec<&str> = vec![];
let outgoing_message_id = let outgoing_message_id =
KordophoneRepository::send_message(&self.proxy(), &conversation_id, &text)?; KordophoneRepository::send_message(&self.proxy(), &conversation_id, &text, attachment_guids)?;
println!("Outgoing message ID: {}", outgoing_message_id); println!("Outgoing message ID: {}", outgoing_message_id);
Ok(()) Ok(())
} }