diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 9 | ||||
| -rw-r--r-- | src/lib/client.rs | 26 | ||||
| -rw-r--r-- | src/lib/git_events.rs | 12 |
3 files changed, 22 insertions, 25 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index d42c904..1738790 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -1244,11 +1244,10 @@ async fn get_proposal_and_revision_root_from_patch( | |||
| 1244 | bail!("thread root is not a git patch"); | 1244 | bail!("thread root is not a git patch"); |
| 1245 | } | 1245 | } |
| 1246 | 1246 | ||
| 1247 | if proposal_or_revision | 1247 | if proposal_or_revision.tags.iter().any(|t| { |
| 1248 | .tags | 1248 | t.as_slice().len() > 1 |
| 1249 | .iter() | 1249 | && ["revision-root", "root-revision"].contains(&t.as_slice()[1].as_str()) |
| 1250 | .any(|t| t.as_slice().len() > 1 && t.as_slice()[1].eq("revision-root")) | 1250 | }) { |
| 1251 | { | ||
| 1252 | Ok(( | 1251 | Ok(( |
| 1253 | EventId::parse( | 1252 | EventId::parse( |
| 1254 | &proposal_or_revision | 1253 | &proposal_or_revision |
diff --git a/src/lib/client.rs b/src/lib/client.rs index 9ce3e24..0984b19 100644 --- a/src/lib/client.rs +++ b/src/lib/client.rs | |||
| @@ -32,7 +32,7 @@ use mockall::*; | |||
| 32 | use nostr::{ | 32 | use nostr::{ |
| 33 | Event, | 33 | Event, |
| 34 | event::{TagKind, TagStandard, UnsignedEvent}, | 34 | event::{TagKind, TagStandard, UnsignedEvent}, |
| 35 | filter::{Alphabet, MatchEventOptions}, | 35 | filter::Alphabet, |
| 36 | nips::{ | 36 | nips::{ |
| 37 | nip01::Coordinate, | 37 | nip01::Coordinate, |
| 38 | nip05::{Nip05Address, Nip05Profile}, | 38 | nip05::{Nip05Address, Nip05Profile}, |
| @@ -149,12 +149,20 @@ impl Connect for Client { | |||
| 149 | Client { | 149 | Client { |
| 150 | client: if let Some(keys) = opts.keys { | 150 | client: if let Some(keys) = opts.keys { |
| 151 | nostr_sdk::ClientBuilder::new() | 151 | nostr_sdk::ClientBuilder::new() |
| 152 | .opts(ClientOptions::new().relay_limits(RelayLimits::disable())) | 152 | .opts( |
| 153 | ClientOptions::new() | ||
| 154 | .relay_limits(RelayLimits::disable()) | ||
| 155 | .verify_subscriptions(true), | ||
| 156 | ) | ||
| 153 | .signer(keys) | 157 | .signer(keys) |
| 154 | .build() | 158 | .build() |
| 155 | } else { | 159 | } else { |
| 156 | nostr_sdk::ClientBuilder::new() | 160 | nostr_sdk::ClientBuilder::new() |
| 157 | .opts(ClientOptions::new().relay_limits(RelayLimits::disable())) | 161 | .opts( |
| 162 | ClientOptions::new() | ||
| 163 | .relay_limits(RelayLimits::disable()) | ||
| 164 | .verify_subscriptions(true), | ||
| 165 | ) | ||
| 158 | .build() | 166 | .build() |
| 159 | }, | 167 | }, |
| 160 | relay_default_set: opts.relay_default_set, | 168 | relay_default_set: opts.relay_default_set, |
| @@ -606,17 +614,7 @@ impl Connect for Client { | |||
| 606 | fresh_profiles = HashSet::new(); | 614 | fresh_profiles = HashSet::new(); |
| 607 | 615 | ||
| 608 | let relay = self.client.relay(&relay_url).await?; | 616 | let relay = self.client.relay(&relay_url).await?; |
| 609 | let events: Vec<nostr::Event> = get_events_of(&relay, filters.clone(), &None) | 617 | let events: Vec<nostr::Event> = get_events_of(&relay, filters.clone(), &None).await?; |
| 610 | .await? | ||
| 611 | .iter() | ||
| 612 | // don't process events that don't match filters | ||
| 613 | .filter(|e| { | ||
| 614 | filters | ||
| 615 | .iter() | ||
| 616 | .any(|f| f.match_event(e, MatchEventOptions::default())) | ||
| 617 | }) | ||
| 618 | .cloned() | ||
| 619 | .collect(); | ||
| 620 | // TODO: try reconcile | 618 | // TODO: try reconcile |
| 621 | 619 | ||
| 622 | process_fetched_events( | 620 | process_fetched_events( |
diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs index 76c31de..5ea630a 100644 --- a/src/lib/git_events.rs +++ b/src/lib/git_events.rs | |||
| @@ -75,10 +75,10 @@ pub fn event_is_patch_set_root(event: &Event) -> bool { | |||
| 75 | 75 | ||
| 76 | pub fn event_is_revision_root(event: &Event) -> bool { | 76 | pub fn event_is_revision_root(event: &Event) -> bool { |
| 77 | (event.kind.eq(&Kind::GitPatch) | 77 | (event.kind.eq(&Kind::GitPatch) |
| 78 | && event | 78 | && event.tags.iter().any(|t| { |
| 79 | .tags | 79 | t.as_slice().len() > 1 |
| 80 | .iter() | 80 | && ["revision-root", "root-revision"].contains(&t.as_slice()[1].as_str()) |
| 81 | .any(|t| t.as_slice().len() > 1 && t.as_slice()[1].eq("revision-root"))) | 81 | })) |
| 82 | || (event.kind.eq(&KIND_PULL_REQUEST) | 82 | || (event.kind.eq(&KIND_PULL_REQUEST) |
| 83 | && event | 83 | && event |
| 84 | .tags | 84 | .tags |
| @@ -180,7 +180,7 @@ pub async fn generate_patch_event( | |||
| 180 | } else if let Some(event_ref) = root_proposal_id.clone() { | 180 | } else if let Some(event_ref) = root_proposal_id.clone() { |
| 181 | vec![ | 181 | vec![ |
| 182 | Tag::hashtag("root"), | 182 | Tag::hashtag("root"), |
| 183 | Tag::hashtag("revision-root"), | 183 | Tag::hashtag("root-revision"), |
| 184 | // TODO check if id is for a root proposal (perhaps its for an issue?) | 184 | // TODO check if id is for a root proposal (perhaps its for an issue?) |
| 185 | event_tag_from_nip19_or_hex( | 185 | event_tag_from_nip19_or_hex( |
| 186 | &event_ref, | 186 | &event_ref, |
| @@ -605,7 +605,7 @@ pub async fn generate_cover_letter_and_patch_events( | |||
| 605 | if let Some(event_ref) = root_proposal_id.clone() { | 605 | if let Some(event_ref) = root_proposal_id.clone() { |
| 606 | vec![ | 606 | vec![ |
| 607 | Tag::hashtag("root"), | 607 | Tag::hashtag("root"), |
| 608 | Tag::hashtag("revision-root"), | 608 | Tag::hashtag("root-revision"), |
| 609 | // TODO check if id is for a root proposal (perhaps its for an issue?) | 609 | // TODO check if id is for a root proposal (perhaps its for an issue?) |
| 610 | event_tag_from_nip19_or_hex(&event_ref,"proposal",EventRefType::Reply, false, false)?, | 610 | event_tag_from_nip19_or_hex(&event_ref,"proposal",EventRefType::Reply, false, false)?, |
| 611 | ] | 611 | ] |