-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c706bd
commit 8456e8b
Showing
9 changed files
with
232 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ pub mod nip05; | |
pub mod nip11; | ||
//pub mod nip44; | ||
pub mod nip46; | ||
pub mod nip53; | ||
pub mod nip57; | ||
pub mod nip94; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
use std::str::FromStr; | ||
|
||
use nostr::nips::nip53; | ||
use nostr::secp256k1::schnorr::Signature; | ||
use nostr::types::url::UncheckedUrl; | ||
|
||
use crate::{ImageDimensions, PublicKey, Timestamp}; | ||
|
||
pub struct LiveEventHost { | ||
pub public_key: PublicKey, | ||
pub relay_url: Option<String>, | ||
pub proof: Option<String>, | ||
} | ||
|
||
impl From<LiveEventHost> for nip53::LiveEventHost { | ||
fn from(value: LiveEventHost) -> Self { | ||
Self { | ||
public_key: *value.public_key, | ||
relay_url: value.relay_url.map(UncheckedUrl::from), | ||
proof: match value.proof { | ||
Some(sig) => Signature::from_str(&sig).ok(), | ||
None => None, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
pub struct Image { | ||
pub url: String, | ||
pub dimensions: Option<ImageDimensions>, | ||
} | ||
|
||
pub enum LiveEventStatus { | ||
Planned(), | ||
Live(), | ||
Ended(), | ||
Custom { custom: String }, | ||
} | ||
|
||
impl From<LiveEventStatus> for nip53::LiveEventStatus { | ||
fn from(value: LiveEventStatus) -> Self { | ||
match value { | ||
LiveEventStatus::Planned() => Self::Planned, | ||
LiveEventStatus::Live() => Self::Live, | ||
LiveEventStatus::Ended() => Self::Ended, | ||
LiveEventStatus::Custom { custom } => Self::Custom(custom), | ||
} | ||
} | ||
} | ||
|
||
pub struct Person { | ||
pub public_key: PublicKey, | ||
pub url: Option<String>, | ||
} | ||
|
||
pub struct LiveEvent { | ||
pub id: String, | ||
pub title: Option<String>, | ||
pub summary: Option<String>, | ||
pub image: Option<Image>, | ||
pub hashtags: Vec<String>, | ||
pub streaming: Option<String>, | ||
pub recording: Option<String>, | ||
pub start: Option<Timestamp>, | ||
pub ends: Option<Timestamp>, | ||
pub status: Option<LiveEventStatus>, | ||
pub current_participants: Option<u64>, | ||
pub total_participants: Option<u64>, | ||
pub relays: Vec<String>, | ||
pub host: Option<LiveEventHost>, | ||
pub speakers: Vec<Person>, | ||
pub participants: Vec<Person>, | ||
} | ||
|
||
impl From<LiveEvent> for nip53::LiveEvent { | ||
fn from(value: LiveEvent) -> Self { | ||
Self { | ||
id: value.id, | ||
title: value.title, | ||
summary: value.summary, | ||
image: value.image.map(|i: Image| { | ||
( | ||
UncheckedUrl::from(i.url), | ||
i.dimensions.map(|d: ImageDimensions| d.into()), | ||
) | ||
}), | ||
hashtags: value.hashtags, | ||
streaming: value.streaming.map(UncheckedUrl::from), | ||
recording: value.recording.map(UncheckedUrl::from), | ||
starts: value.start.map(|t| *t), | ||
ends: value.ends.map(|t| *t), | ||
status: value.status.map(|s| s.into()), | ||
current_participants: value.current_participants, | ||
total_participants: value.total_participants, | ||
relays: value.relays.into_iter().map(UncheckedUrl::from).collect(), | ||
host: value.host.map(|h| h.into()), | ||
speakers: value | ||
.speakers | ||
.into_iter() | ||
.map(|s| (*s.public_key, s.url.map(UncheckedUrl::from))) | ||
.collect(), | ||
participants: value | ||
.participants | ||
.into_iter() | ||
.map(|s| (*s.public_key, s.url.map(UncheckedUrl::from))) | ||
.collect(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.