Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions crates/nostr/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,42 @@ impl EventBuilder {
)))
}

/// Date-Based Calendar Event
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
#[inline]
pub fn date_based_calendar_event(event: DateBasedCalendarEvent) -> Self {
let tags: Vec<Tag> = event.into();
Self::new(Kind::DateBasedCalendarEvent, "").tags(tags)
}

/// Time-Based Calendar Event
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
#[inline]
pub fn time_based_calendar_event(event: TimeBasedCalendarEvent) -> Self {
let tags: Vec<Tag> = event.into();
Self::new(Kind::TimeBasedCalendarEvent, "").tags(tags)
}

/// Calendar
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
#[inline]
pub fn calendar(calendar: Calendar) -> Self {
let tags: Vec<Tag> = calendar.into();
Self::new(Kind::Calendar, "").tags(tags)
}

/// Calendar Event RSVP
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
#[inline]
pub fn calendar_event_rsvp(rsvp: CalendarEventRsvp) -> Self {
let tags: Vec<Tag> = rsvp.into();
Self::new(Kind::CalendarEventRsvp, "").tags(tags)
}

/// Label
///
/// <https://github.com/nostr-protocol/nips/blob/master/32.md>
Expand Down
4 changes: 4 additions & 0 deletions crates/nostr/src/event/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ kind_variants! {
ChatMessage => 9, "Chat Message", "<https://github.com/nostr-protocol/nips/blob/master/C7.md>",
Thread => 11, "Thread", "<https://github.com/nostr-protocol/nips/blob/master/7D.md>",
WebBookmark => 39701, "Web Bookmark", "<https://github.com/nostr-protocol/nips/blob/master/B0.md>",
DateBasedCalendarEvent => 31922, "Date-based Calendar Event", "<https://github.com/nostr-protocol/nips/blob/master/52.md>",
TimeBasedCalendarEvent => 31923, "Time-based Calendar Event", "<https://github.com/nostr-protocol/nips/blob/master/52.md>",
Calendar => 31924, "Calendar", "<https://github.com/nostr-protocol/nips/blob/master/52.md>",
CalendarEventRsvp => 31925, "Calendar Event RSVP", "<https://github.com/nostr-protocol/nips/blob/master/52.md>",
}

impl PartialEq for Kind {
Expand Down
18 changes: 18 additions & 0 deletions crates/nostr/src/event/tag/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ pub enum TagKind<'a> {
Emoji,
/// Encrypted
Encrypted,
/// End (singular, NIP-52)
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
End,
/// Ends
Ends,
/// Expiration
Expand All @@ -83,6 +87,10 @@ pub enum TagKind<'a> {
File,
/// Image
Image,
/// Location
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
Location,
/// License of the shared content
///
/// <https://github.com/nostr-protocol/nips/blob/master/C0.md>
Expand Down Expand Up @@ -147,6 +155,10 @@ pub enum TagKind<'a> {
Server,
/// Size of the file in bytes
Size,
/// Start (singular, NIP-52)
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
Start,
/// Starts
Starts,
/// Status
Expand Down Expand Up @@ -336,12 +348,14 @@ impl<'a> TagKind<'a> {
Self::Dim => "dim",
Self::Emoji => "emoji",
Self::Encrypted => "encrypted",
Self::End => "end",
Self::Ends => "ends",
Self::Expiration => "expiration",
Self::Extension => "extension",
Self::File => "file",
Self::Head => "HEAD",
Self::Image => "image",
Self::Location => "location",
Self::License => "license",
Self::Lnurl => "lnurl",
Self::Magnet => "magnet",
Expand Down Expand Up @@ -369,6 +383,7 @@ impl<'a> TagKind<'a> {
Self::Runtime => "runtime",
Self::Server => "server",
Self::Size => "size",
Self::Start => "start",
Self::Starts => "starts",
Self::Status => "status",
Self::Streaming => "streaming",
Expand Down Expand Up @@ -415,11 +430,13 @@ impl<'a> From<&'a str> for TagKind<'a> {
"dim" => Self::Dim,
"emoji" => Self::Emoji,
"encrypted" => Self::Encrypted,
"end" => Self::End,
"ends" => Self::Ends,
"expiration" => Self::Expiration,
"extension" => Self::Extension,
"file" => Self::File,
"image" => Self::Image,
"location" => Self::Location,
"license" => Self::License,
"lnurl" => Self::Lnurl,
"magnet" => Self::Magnet,
Expand Down Expand Up @@ -447,6 +464,7 @@ impl<'a> From<&'a str> for TagKind<'a> {
"HEAD" => Self::Head,
"server" => Self::Server,
"size" => Self::Size,
"start" => Self::Start,
"starts" => Self::Starts,
"status" => Self::Status,
"streaming" => Self::Streaming,
Expand Down
7 changes: 7 additions & 0 deletions crates/nostr/src/event/tag/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ pub enum TagStandard {
Hashtag(String),
Geohash(String),
Identifier(String),
/// Location
///
/// <https://github.com/nostr-protocol/nips/blob/master/52.md>
Location(String),
/// External Content ID
///
/// <https://github.com/nostr-protocol/nips/blob/master/73.md>
Expand Down Expand Up @@ -517,6 +521,7 @@ impl TagStandard {
TagKind::Word => Ok(Self::Word(tag_1.to_string())),
TagKind::Alt => Ok(Self::Alt(tag_1.to_string())),
TagKind::Dim => Ok(Self::Dim(ImageDimensions::from_str(tag_1)?)),
TagKind::Location => Ok(Self::Location(tag_1.to_string())),
_ => Err(Error::UnknownStandardizedTag),
};
}
Expand Down Expand Up @@ -658,6 +663,7 @@ impl TagStandard {
character: Alphabet::D,
uppercase: false,
}),
Self::Location(..) => TagKind::Location,
Self::ExternalContent { uppercase, .. } => TagKind::SingleLetter(SingleLetterTag {
character: Alphabet::I,
uppercase: *uppercase,
Expand Down Expand Up @@ -901,6 +907,7 @@ impl From<TagStandard> for Vec<String> {
TagStandard::Hashtag(t) => vec![tag_kind, t],
TagStandard::Geohash(g) => vec![tag_kind, g],
TagStandard::Identifier(d) => vec![tag_kind, d],
TagStandard::Location(loc) => vec![tag_kind, loc],
TagStandard::Coordinate {
coordinate,
relay_url,
Expand Down
1 change: 1 addition & 0 deletions crates/nostr/src/nips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub mod nip48;
#[cfg(feature = "nip49")]
pub mod nip49;
pub mod nip51;
pub mod nip52;
pub mod nip53;
pub mod nip56;
#[cfg(feature = "nip57")]
Expand Down
Loading