Skip to content

Commit 2dcde03

Browse files
committed
nostr: add EventBuilder::interest_set
Closes #465 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 217e388 commit 2dcde03

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
### Added
3535

36+
* nostr: add `EventBuilder::interest_set` ([Yuki Kishimoto])
3637
* book: add some python examples ([RydalWater])
3738

3839
### Fixed

bindings/nostr-ffi/src/event/builder.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,16 @@ impl EventBuilder {
734734
}
735735
}
736736

737+
/// Interest set
738+
///
739+
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
740+
#[uniffi::constructor]
741+
pub fn interest_set(hashtags: Vec<String>) -> Self {
742+
Self {
743+
inner: nostr::EventBuilder::interest_set(hashtags),
744+
}
745+
}
746+
737747
/// Emoji set
738748
///
739749
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>

bindings/nostr-js/src/event/builder.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,16 @@ impl JsEventBuilder {
751751
}
752752
}
753753

754+
/// Interest set
755+
///
756+
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
757+
#[wasm_bindgen(js_name = interestSet)]
758+
pub fn interest_set(hashtags: Vec<String>) -> Self {
759+
Self {
760+
inner: EventBuilder::interest_set(hashtags),
761+
}
762+
}
763+
754764
/// Emoji set
755765
///
756766
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>

crates/nostr/src/event/builder.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,22 @@ impl EventBuilder {
15701570
)
15711571
}
15721572

1573+
/// Interest set
1574+
///
1575+
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>
1576+
#[inline]
1577+
pub fn interest_set<I, S>(hashtags: I) -> Self
1578+
where
1579+
I: IntoIterator<Item = S>,
1580+
S: Into<String>,
1581+
{
1582+
Self::new(
1583+
Kind::InterestSet,
1584+
"",
1585+
hashtags.into_iter().map(|t| Tag::hashtag(t)),
1586+
)
1587+
}
1588+
15731589
/// Emoji set
15741590
///
15751591
/// <https://github.com/nostr-protocol/nips/blob/master/51.md>

0 commit comments

Comments
 (0)