daemon: incorporate update monitor in daemon activities
This commit is contained in:
@@ -20,11 +20,14 @@ pub enum Commands {
|
||||
/// Gets all known conversations.
|
||||
Conversations,
|
||||
|
||||
/// Runs a sync operation.
|
||||
/// Runs a full sync operation for a conversation and its messages.
|
||||
Sync {
|
||||
conversation_id: Option<String>,
|
||||
},
|
||||
|
||||
/// Runs a sync operation for the conversation list.
|
||||
SyncList,
|
||||
|
||||
/// Prints the server Kordophone version.
|
||||
Version,
|
||||
|
||||
@@ -75,6 +78,7 @@ impl Commands {
|
||||
Commands::Version => client.print_version().await,
|
||||
Commands::Conversations => client.print_conversations().await,
|
||||
Commands::Sync { conversation_id } => client.sync_conversations(conversation_id).await,
|
||||
Commands::SyncList => client.sync_conversations_list().await,
|
||||
Commands::Config { command } => client.config(command).await,
|
||||
Commands::Signals => client.wait_for_signals().await,
|
||||
Commands::Messages { conversation_id, last_message_id } => client.print_messages(conversation_id, last_message_id).await,
|
||||
@@ -125,6 +129,11 @@ impl DaemonCli {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn sync_conversations_list(&mut self) -> Result<()> {
|
||||
KordophoneRepository::sync_conversation_list(&self.proxy())
|
||||
.map_err(|e| anyhow::anyhow!("Failed to sync conversations: {}", e))
|
||||
}
|
||||
|
||||
pub async fn print_messages(&mut self, conversation_id: String, last_message_id: Option<String>) -> Result<()> {
|
||||
let messages = KordophoneRepository::get_messages(&self.proxy(), &conversation_id, &last_message_id.unwrap_or_default())?;
|
||||
println!("Number of messages: {}", messages.len());
|
||||
|
||||
Reference in New Issue
Block a user