Adds the ability to sync just one conversation
This commit is contained in:
@@ -21,7 +21,9 @@ pub enum Commands {
|
||||
Conversations,
|
||||
|
||||
/// Runs a sync operation.
|
||||
Sync,
|
||||
Sync {
|
||||
conversation_id: Option<String>,
|
||||
},
|
||||
|
||||
/// Prints the server Kordophone version.
|
||||
Version,
|
||||
@@ -69,7 +71,7 @@ impl Commands {
|
||||
match cmd {
|
||||
Commands::Version => client.print_version().await,
|
||||
Commands::Conversations => client.print_conversations().await,
|
||||
Commands::Sync => client.sync_conversations().await,
|
||||
Commands::Sync { conversation_id } => client.sync_conversations(conversation_id).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,
|
||||
@@ -109,9 +111,14 @@ impl DaemonCli {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn sync_conversations(&mut self) -> Result<()> {
|
||||
KordophoneRepository::sync_all_conversations(&self.proxy())
|
||||
.map_err(|e| anyhow::anyhow!("Failed to sync conversations: {}", e))
|
||||
pub async fn sync_conversations(&mut self, conversation_id: Option<String>) -> Result<()> {
|
||||
if let Some(conversation_id) = conversation_id {
|
||||
KordophoneRepository::sync_conversation(&self.proxy(), &conversation_id)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to sync conversation: {}", e))
|
||||
} else {
|
||||
KordophoneRepository::sync_all_conversations(&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<()> {
|
||||
|
||||
Reference in New Issue
Block a user