daemon: implements post office
This commit is contained in:
@@ -138,7 +138,7 @@ impl ClientCli {
|
||||
.text(message)
|
||||
.build();
|
||||
|
||||
let message = self.api.send_message(outgoing_message).await?;
|
||||
let message = self.api.send_message(&outgoing_message).await?;
|
||||
println!("Message sent: {}", message.guid);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ pub enum Commands {
|
||||
|
||||
/// Deletes all conversations.
|
||||
DeleteAllConversations,
|
||||
|
||||
/// Enqueues an outgoing message to be sent to a conversation.
|
||||
SendMessage {
|
||||
conversation_id: String,
|
||||
text: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@@ -83,6 +89,7 @@ impl Commands {
|
||||
Commands::Signals => client.wait_for_signals().await,
|
||||
Commands::Messages { conversation_id, last_message_id } => client.print_messages(conversation_id, last_message_id).await,
|
||||
Commands::DeleteAllConversations => client.delete_all_conversations().await,
|
||||
Commands::SendMessage { conversation_id, text } => client.enqueue_outgoing_message(conversation_id, text).await,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,6 +152,12 @@ impl DaemonCli {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn enqueue_outgoing_message(&mut self, conversation_id: String, text: String) -> Result<()> {
|
||||
let outgoing_message_id = KordophoneRepository::send_message(&self.proxy(), &conversation_id, &text)?;
|
||||
println!("Outgoing message ID: {}", outgoing_message_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn wait_for_signals(&mut self) -> Result<()> {
|
||||
use dbus::Message;
|
||||
mod dbus_signals {
|
||||
|
||||
Reference in New Issue
Block a user