implement nip4e interop tags

This commit is contained in:
2026-11-04 08:42:18 +07:00
parent 198f13bd1d
commit 029ab21983
5 changed files with 350 additions and 31 deletions
+14 -1
View File
@@ -5,6 +5,10 @@ use nostr_sdk::prelude::*;
pub struct Announcement {
/// The public key of the device that created this announcement.
public_key: PublicKey,
/// The id of the announcement event, for ordering
event_id: EventId,
/// The creation time of the announcement event
created_at: Timestamp,
}
impl Announcement {
@@ -16,11 +20,20 @@ impl Announcement {
.and_then(|tag| tag.content())
.and_then(|c| PublicKey::parse(c).ok())?;
Some(Self { public_key })
Some(Self {
public_key,
event_id: event.id,
created_at: event.created_at,
})
}
/// Returns the public key of the device that created this announcement.
pub fn public_key(&self) -> PublicKey {
self.public_key
}
pub fn is_newer_than(&self, other: &Self) -> bool {
self.created_at > other.created_at
|| (self.created_at == other.created_at && self.event_id < other.event_id)
}
}