upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/client.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2023-12-01 00:00:00 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2023-12-01 00:00:00 +0000
commit06be0bc44011411b78217459f505ed12281b32c4 (patch)
tree36cab80e309d33f20fedcc97258700a379aa348e /src/client.rs
parent492cc67887855cecb3fb501c4b61af50bf645b73 (diff)
feat(prs-list) list and pull selected as branch
- fetch prs and present as a selectable list - create and / or checkout branch for selected pr - apply latest patches as commits
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/client.rs b/src/client.rs
index 1037b1b..860562c 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -20,6 +20,7 @@ use nostr::Event;
20pub struct Client { 20pub struct Client {
21 client: nostr_sdk::Client, 21 client: nostr_sdk::Client,
22 fallback_relays: Vec<String>, 22 fallback_relays: Vec<String>,
23 more_fallback_relays: Vec<String>,
23} 24}
24 25
25#[cfg_attr(test, automock)] 26#[cfg_attr(test, automock)]
@@ -30,6 +31,7 @@ pub trait Connect {
30 async fn set_keys(&mut self, keys: &nostr::Keys); 31 async fn set_keys(&mut self, keys: &nostr::Keys);
31 async fn disconnect(&self) -> Result<()>; 32 async fn disconnect(&self) -> Result<()>;
32 fn get_fallback_relays(&self) -> &Vec<String>; 33 fn get_fallback_relays(&self) -> &Vec<String>;
34 fn get_more_fallback_relays(&self) -> &Vec<String>;
33 async fn send_event_to(&self, url: &str, event: nostr::event::Event) -> Result<nostr::EventId>; 35 async fn send_event_to(&self, url: &str, event: nostr::event::Event) -> Result<nostr::EventId>;
34 async fn get_events( 36 async fn get_events(
35 &self, 37 &self,
@@ -47,12 +49,17 @@ impl Connect for Client {
47 "ws://localhost:8051".to_string(), 49 "ws://localhost:8051".to_string(),
48 "ws://localhost:8052".to_string(), 50 "ws://localhost:8052".to_string(),
49 ], 51 ],
52 more_fallback_relays: vec![
53 "ws://localhost:8055".to_string(),
54 "ws://localhost:8056".to_string(),
55 ],
50 } 56 }
51 } 57 }
52 fn new(opts: Params) -> Self { 58 fn new(opts: Params) -> Self {
53 Client { 59 Client {
54 client: nostr_sdk::Client::new(&opts.keys.unwrap_or(nostr::Keys::generate())), 60 client: nostr_sdk::Client::new(&opts.keys.unwrap_or(nostr::Keys::generate())),
55 fallback_relays: opts.fallback_relays, 61 fallback_relays: opts.fallback_relays,
62 more_fallback_relays: opts.more_fallback_relays,
56 } 63 }
57 } 64 }
58 65
@@ -69,6 +76,10 @@ impl Connect for Client {
69 &self.fallback_relays 76 &self.fallback_relays
70 } 77 }
71 78
79 fn get_more_fallback_relays(&self) -> &Vec<String> {
80 &self.more_fallback_relays
81 }
82
72 async fn send_event_to(&self, url: &str, event: Event) -> Result<nostr::EventId> { 83 async fn send_event_to(&self, url: &str, event: Event) -> Result<nostr::EventId> {
73 self.client.add_relay(url, None).await?; 84 self.client.add_relay(url, None).await?;
74 self.client.connect_relay(url).await?; 85 self.client.connect_relay(url).await?;
@@ -130,6 +141,7 @@ async fn get_events_of(
130pub struct Params { 141pub struct Params {
131 pub keys: Option<nostr::Keys>, 142 pub keys: Option<nostr::Keys>,
132 pub fallback_relays: Vec<String>, 143 pub fallback_relays: Vec<String>,
144 pub more_fallback_relays: Vec<String>,
133} 145}
134 146
135fn get_dedup_events(relay_results: Vec<Result<Vec<nostr::Event>>>) -> Vec<Event> { 147fn get_dedup_events(relay_results: Vec<Result<Vec<nostr::Event>>>) -> Vec<Event> {