Skip to content

Commit a499845

Browse files
committed
nostr: make EventBuilder::comment and EventBuilder::voice_message_reply args generic over CommentTarget type
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 73044ae commit a499845

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

crates/nostr/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
- Check that `a`/`A` and `k`/`K` tags have the same event kind in NIP-22 events (https://github.com/rust-nostr/nostr/pull/1035)
6868
- Deserialize NIP-47 empty strings as `None` (https://github.com/rust-nostr/nostr/pull/1079)
6969
- Make `EventBuilder::reaction` target arg generic over `ReactionTarget` type
70+
- Make `EventBuilder::comment` and `EventBuilder::voice_message_reply` args generic over `CommentTarget` type
7071

7172
### Deprecated
7273

crates/nostr/src/event/builder.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -648,17 +648,14 @@ impl EventBuilder {
648648
/// Comment
649649
///
650650
/// <https://github.com/nostr-protocol/nips/blob/master/22.md>
651-
pub fn comment<S>(
652-
content: S,
653-
comment_to: CommentTarget<'_>,
654-
root: Option<CommentTarget<'_>>,
655-
) -> Self
651+
pub fn comment<'a, S, T>(content: S, comment_to: T, root: Option<T>) -> Self
656652
where
653+
T: Into<CommentTarget<'a>>,
657654
S: Into<String>,
658655
{
659656
Self::new(Kind::Comment, content)
660-
.tags(root.map(|c| c.as_vec(true)).unwrap_or_default())
661-
.tags(comment_to.as_vec(false))
657+
.tags(root.map(|c| c.into().as_vec(true)).unwrap_or_default())
658+
.tags(comment_to.into().as_vec(false))
662659
}
663660

664661
/// Long-form text note (generally referred to as "articles" or "blog posts").
@@ -828,17 +825,14 @@ impl EventBuilder {
828825
///
829826
/// [NIP-92]: https://github.com/nostr-protocol/nips/blob/master/92.md
830827
#[inline]
831-
pub fn voice_message_reply<T>(
832-
voice_url: T,
833-
root: Option<CommentTarget<'_>>,
834-
parent: CommentTarget<'_>,
835-
) -> Self
828+
pub fn voice_message_reply<'a, T, U>(voice_url: U, root: Option<T>, parent: T) -> Self
836829
where
837-
T: Into<Url>,
830+
T: Into<CommentTarget<'a>>,
831+
U: Into<Url>,
838832
{
839833
EventBuilder::new(Kind::VoiceMessageReply, voice_url.into().as_str())
840-
.tags(root.map(|c| c.as_vec(true)).unwrap_or_default())
841-
.tags(parent.as_vec(false))
834+
.tags(root.map(|c| c.into().as_vec(true)).unwrap_or_default())
835+
.tags(parent.into().as_vec(false))
842836
}
843837

844838
/// Add reaction (like/upvote, dislike/downvote or emoji) to an event

0 commit comments

Comments
 (0)