From cfc8add5e6d4cdb1f268e851f43037d7af77b0d3 Mon Sep 17 00:00:00 2001 From: Philip Cristiano Date: Fri, 12 Jul 2024 08:51:12 -0400 Subject: [PATCH] fix: Update for nostr-sdk tag is_reply Instead of checking tag types, which no longer works in this version --- src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 262b12d..eabab9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,12 +17,7 @@ pub fn event_to_item(e: Event) -> Item { } fn event_is_reply(e: &Event) -> bool { - println!("{:?}", &e); - e.tags.iter().any(|tag| match tag.kind() { - TagKind::P => true, - TagKind::E => false, - _ => return false, - }) + e.tags.iter().any(|tag| tag.is_reply()) } pub fn linkify_content(content: String) -> String { @@ -82,15 +77,20 @@ mod test_events { } #[test] - fn exclude_text_notes_referencing_pubkeys() { + fn exclude_replies() { let secret_key = SecretKey::from_bech32(BECH32_SK).unwrap(); let my_keys = Keys::new(secret_key); let other_pub_key = PublicKey::from_bech32(OTHER_BECH32_SK).unwrap(); let t = Tag::public_key(other_pub_key); - let e_note: Event = EventBuilder::text_note("Text note from nostr-sdk", [t]) + + let original_note: Event = EventBuilder::text_note("Text note from nostr-sdk", [t]) .to_event(&my_keys) .unwrap(); + let e_note: Event = + EventBuilder::text_note_reply("Text note from nostr-sdk", &original_note, None, None) + .to_event(&my_keys) + .unwrap(); let notes = vec![e_note]; let filtered_notes = filter_out_replies(notes);