Skip to content

Commit

Permalink
fix: amend request-history-sync command
Browse files Browse the repository at this point in the history
  • Loading branch information
tuddman committed Aug 1, 2024
1 parent aba3ce2 commit 4e36425
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions examples/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Use the CLI to send a [double ratchet message](https://github.com/xmtp/libxmtp/b
```bash
./xli.sh --db user2.db3 list-group-messages $GROUP_ID
```

9. Request a Message History Sync

```bash
./xli.sh --db user1.db3 request-history-sync
```



If you want to run the CLI against localhost, go to the root directory and run `dev/up` to start a local server. Then run the CLI commands using the `--local` flag.

Expand Down
9 changes: 6 additions & 3 deletions examples/cli/cli-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ enum Commands {
#[clap(short, long, value_parser, num_args = 1.., value_delimiter = ' ')]
account_addresses: Vec<String>,
},
HistorySyncRequest {},
RequestHistorySync {},
ReplyToHistorySyncRequest {},
/// Information about the account that owns the DB
Info {},
Expand Down Expand Up @@ -335,12 +335,13 @@ async fn main() {
let serializable: SerializableGroup = group.into();
info!("Group {}", group_id, { command_output: true, group_id: group_id, group_info: make_value(&serializable) })
}
Commands::HistorySyncRequest {} => {
Commands::RequestHistorySync {} => {
let client = create_client(&cli, IdentityStrategy::CachedOnly)
.await
.unwrap();
// client.allow_history_sync().await.unwrap();
client.sync_welcomes().await.unwrap();
client.allow_history_sync().await.unwrap();
client.send_history_request().await.unwrap();
info!("Sent history sync request", { command_output: true });
}
Expand Down Expand Up @@ -369,17 +370,18 @@ async fn create_client(cli: &Cli, account: IdentityStrategy) -> Result<Client, C
.await
.unwrap(),
);
builder = builder.history_sync_url("http://0.0.0.0:5558");
} else {
info!("Using dev network");
builder = builder.api_client(
ApiClient::create("https://grpc.dev.xmtp.network:443".into(), true)
.await
.unwrap(),
);
builder = builder.history_sync_url("https://message-history.dev.xmtp.network");
}

let client = builder.build().await.map_err(CliError::ClientBuilder)?;
client.allow_history_sync().await.unwrap();

Ok(client)
}
Expand Down Expand Up @@ -483,6 +485,7 @@ fn static_enc_key() -> EncryptionKey {
fn get_encrypted_store(db: &Option<PathBuf>) -> Result<EncryptedMessageStore, CliError> {
let store = match db {
Some(path) => {
info!("Using persistent storage: {}", path.display());
let s = path.as_path().to_string_lossy().to_string();
info!("Using persistent storage: {} ", s);
EncryptedMessageStore::new_unencrypted(StorageOption::Persistent(s))
Expand Down

0 comments on commit 4e36425

Please sign in to comment.