diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-19 22:10:23 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-07-19 22:10:23 +0100 |
| commit | 29a093993ce7d0210ac39ceb1a25acc9350492e7 (patch) | |
| tree | b8ae2a13b975b051bda7e9461f1b8fddd986b3ca /src/sub_commands/send.rs | |
| parent | dde029b4f5988cfa830ebc36bee0f35c93bd2544 (diff) | |
feat: save created events to cache
as soon as they are successfully sent to at least one relay
Diffstat (limited to 'src/sub_commands/send.rs')
| -rw-r--r-- | src/sub_commands/send.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index f94eed3..95d3eb0 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -239,6 +239,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 239 | 239 | ||
| 240 | send_events( | 240 | send_events( |
| 241 | &client, | 241 | &client, |
| 242 | git_repo_path, | ||
| 242 | events.clone(), | 243 | events.clone(), |
| 243 | user_ref.relays.write(), | 244 | user_ref.relays.write(), |
| 244 | repo_ref.relays.clone(), | 245 | repo_ref.relays.clone(), |
| @@ -279,6 +280,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 279 | pub async fn send_events( | 280 | pub async fn send_events( |
| 280 | #[cfg(test)] client: &crate::client::MockConnect, | 281 | #[cfg(test)] client: &crate::client::MockConnect, |
| 281 | #[cfg(not(test))] client: &Client, | 282 | #[cfg(not(test))] client: &Client, |
| 283 | git_repo_path: &Path, | ||
| 282 | events: Vec<nostr::Event>, | 284 | events: Vec<nostr::Event>, |
| 283 | my_write_relays: Vec<String>, | 285 | my_write_relays: Vec<String>, |
| 284 | repo_read_relays: Vec<String>, | 286 | repo_read_relays: Vec<String>, |
| @@ -392,7 +394,10 @@ pub async fn send_events( | |||
| 392 | pb.inc(0); // need to make pb display intially | 394 | pb.inc(0); // need to make pb display intially |
| 393 | let mut failed = false; | 395 | let mut failed = false; |
| 394 | for event in &events { | 396 | for event in &events { |
| 395 | match client.send_event_to(relay.as_str(), event.clone()).await { | 397 | match client |
| 398 | .send_event_to(git_repo_path, relay.as_str(), event.clone()) | ||
| 399 | .await | ||
| 400 | { | ||
| 396 | Ok(_) => pb.inc(1), | 401 | Ok(_) => pb.inc(1), |
| 397 | Err(e) => { | 402 | Err(e) => { |
| 398 | pb.set_style(pb_after_style_failed.clone()); | 403 | pb.set_style(pb_after_style_failed.clone()); |