diff options
| -rw-r--r-- | src/repo_ref.rs | 19 | ||||
| -rw-r--r-- | src/sub_commands/send.rs | 21 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/repo_ref.rs b/src/repo_ref.rs index 3e1fd22..5d754f2 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs | |||
| @@ -191,6 +191,25 @@ impl RepoRef { | |||
| 191 | } | 191 | } |
| 192 | res | 192 | res |
| 193 | } | 193 | } |
| 194 | |||
| 195 | /// coordinates without relay hints | ||
| 196 | pub fn coordinate_with_hint(&self) -> Coordinate { | ||
| 197 | Coordinate { | ||
| 198 | kind: Kind::Custom(REPO_REF_KIND), | ||
| 199 | public_key: *self | ||
| 200 | .maintainers | ||
| 201 | .first() | ||
| 202 | .context("no maintainers in repo ref") | ||
| 203 | .unwrap(), | ||
| 204 | identifier: self.identifier.clone(), | ||
| 205 | relays: if let Some(relay) = self.relays.first() { | ||
| 206 | vec![relay.to_string()] | ||
| 207 | } else { | ||
| 208 | vec![] | ||
| 209 | }, | ||
| 210 | } | ||
| 211 | } | ||
| 212 | |||
| 194 | /// coordinates without relay hints | 213 | /// coordinates without relay hints |
| 195 | pub fn coordinates_with_timestamps(&self) -> Vec<(Coordinate, Option<Timestamp>)> { | 214 | pub fn coordinates_with_timestamps(&self) -> Vec<(Coordinate, Option<Timestamp>)> { |
| 196 | self.coordinates() | 215 | self.coordinates() |
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index a289def..d093cb6 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs | |||
| @@ -5,7 +5,11 @@ use console::Style; | |||
| 5 | use futures::future::join_all; | 5 | use futures::future::join_all; |
| 6 | use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; | 6 | use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; |
| 7 | use nostr::{ | 7 | use nostr::{ |
| 8 | nips::{nip01::Coordinate, nip10::Marker, nip19::Nip19}, | 8 | nips::{ |
| 9 | nip01::Coordinate, | ||
| 10 | nip10::Marker, | ||
| 11 | nip19::{Nip19, Nip19Event}, | ||
| 12 | }, | ||
| 9 | EventBuilder, FromBech32, Tag, TagKind, ToBech32, UncheckedUrl, | 13 | EventBuilder, FromBech32, Tag, TagKind, ToBech32, UncheckedUrl, |
| 10 | }; | 14 | }; |
| 11 | use nostr_sdk::{hashes::sha1::Hash as Sha1Hash, NostrSigner, TagStandard}; | 15 | use nostr_sdk::{hashes::sha1::Hash as Sha1Hash, NostrSigner, TagStandard}; |
| @@ -242,23 +246,24 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 242 | 246 | ||
| 243 | if root_proposal_id.is_none() { | 247 | if root_proposal_id.is_none() { |
| 244 | if let Some(event) = events.first() { | 248 | if let Some(event) = events.first() { |
| 245 | // TODO: add gitworkshop.dev to njump and remove direct gitworkshop link | 249 | let event_bech32 = if let Some(relay) = repo_ref.relays.first() { |
| 250 | Nip19Event::new(event.id(), vec![relay]).to_bech32()? | ||
| 251 | } else { | ||
| 252 | event.id().to_bech32()? | ||
| 253 | }; | ||
| 246 | println!( | 254 | println!( |
| 247 | "{}", | 255 | "{}", |
| 248 | dim.apply_to(format!( | 256 | dim.apply_to(format!( |
| 249 | "view in gitworkshop.dev: https://gitworkshop.dev/repo/{}/proposal/{}", | 257 | "view in gitworkshop.dev: https://gitworkshop.dev/repo/{}/proposal/{}", |
| 250 | repo_ref.identifier, | 258 | repo_ref.coordinate_with_hint().to_bech32()?, |
| 251 | event.id(), | 259 | &event_bech32, |
| 252 | )) | 260 | )) |
| 253 | ); | 261 | ); |
| 254 | println!( | 262 | println!( |
| 255 | "{}", | 263 | "{}", |
| 256 | dim.apply_to(format!( | 264 | dim.apply_to(format!( |
| 257 | "view in another client: https://njump.me/{}", | 265 | "view in another client: https://njump.me/{}", |
| 258 | event | 266 | &event_bech32, |
| 259 | .id() | ||
| 260 | .to_bech32() | ||
| 261 | .context("cannot produce nevent from event id")? | ||
| 262 | )) | 267 | )) |
| 263 | ); | 268 | ); |
| 264 | } | 269 | } |