Skip to content

Commit

Permalink
feat: root must be same with parent if user not provide
Browse files Browse the repository at this point in the history
  • Loading branch information
reyamir committed Nov 9, 2024
1 parent 8403246 commit e074fa4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/nostr/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ impl EventBuilder {
/// If no `root` is passed, the `rely_to` will be used for root `e` tag.
///
/// <https://github.com/nostr-protocol/nips/blob/master/10.md>
#[deprecated(since = "0.36.0", note = "Use `EventBuilder::comment` method instead.")]
pub fn text_note_reply<S>(
content: S,
reply_to: &Event,
Expand Down Expand Up @@ -525,6 +526,7 @@ impl EventBuilder {
public_key: Some(root.pubkey),
uppercase: true,
}));

// Kind
tags.push(Tag::from_standardized_without_cell(TagStandard::Kind {
kind: root.kind,
Expand All @@ -544,6 +546,21 @@ impl EventBuilder {
})
.cloned(),
);
} else {
// ID and author
tags.push(Tag::from_standardized_without_cell(TagStandard::Event {
event_id: comment_to.id,
relay_url: relay_url.clone(),
marker: None,
public_key: Some(comment_to.pubkey),
uppercase: true,
}));

// Kind
tags.push(Tag::from_standardized_without_cell(TagStandard::Kind {
kind: comment_to.kind,
uppercase: true,
}));
}

// Add `e` tag of event author
Expand All @@ -554,6 +571,7 @@ impl EventBuilder {
public_key: Some(comment_to.pubkey),
uppercase: false,
}));

// Add `k` tag of event kind
tags.push(Tag::from_standardized_without_cell(TagStandard::Kind {
kind: comment_to.kind,
Expand Down

0 comments on commit e074fa4

Please sign in to comment.