From c4c262a5e9bfeb30bc0106d9ea51dfce7e4fa1f3 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 4 Sep 2024 16:44:43 +0100 Subject: refactor(remote): split into modules to make it easier to read --- src/lib/git_events.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/lib/git_events.rs') diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs index 8689b33..2e9f797 100644 --- a/src/lib/git_events.rs +++ b/src/lib/git_events.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use anyhow::{bail, Context, Result}; use nostr::nips::{nip01::Coordinate, nip10::Marker, nip19::Nip19}; use nostr_sdk::{ - hashes::sha1::Hash as Sha1Hash, Event, EventBuilder, FromBech32, Kind, Tag, TagKind, + hashes::sha1::Hash as Sha1Hash, Event, EventBuilder, EventId, FromBech32, Kind, Tag, TagKind, TagStandard, UncheckedUrl, }; use nostr_signer::NostrSigner; @@ -37,6 +37,19 @@ pub fn get_commit_id_from_patch(event: &Event) -> Result { } } +pub fn get_event_root(event: &nostr::Event) -> Result { + Ok(EventId::parse( + event + .tags() + .iter() + .find(|t| t.is_root()) + .context("no thread root in event")? + .as_vec() + .get(1) + .unwrap(), + )?) +} + pub fn status_kinds() -> Vec { vec![ Kind::GitStatusOpen, -- cgit v1.2.3