lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit 575dccbc658886baca40afae872b83659fe22b76
parent 67a3c74e2e307c596fba7848830317dc849e560f
Author: triesap <tyson@radroots.org>
Date:   Mon,  6 Oct 2025 18:14:38 +0100

events: update event metadata timestamps and relay status handling

Diffstat:
MCargo.lock | 18++++++++++++++----
MCargo.toml | 1+
Mcrates/events/Cargo.toml | 3+--
Mcrates/events/src/post/models.rs | 2+-
Mcrates/events/src/profile/models.rs | 2+-
Mcrates/net-core/src/nostr_client/status.rs | 29+++++++++++++----------------
Mcrates/nostr/src/event_adapters.rs | 6+++---
7 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -2117,18 +2117,28 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml @@ -53,3 +53,4 @@ tracing-subscriber = { version = "0.3" } typeshare = { version = "1" } url = { version = "2" } uuid = { version = "1.16.0" } +uniffi = { version = "0.29.4" } diff --git a/crates/events/Cargo.toml b/crates/events/Cargo.toml @@ -18,4 +18,4 @@ serde = { workspace = true, default-features = false, features = ["alloc", "deri typeshare = { workspace = true, optional = true } [dev-dependencies] -serde_json = { workspace = true } -\ No newline at end of file +serde_json = { workspace = true } diff --git a/crates/events/src/post/models.rs b/crates/events/src/post/models.rs @@ -13,7 +13,7 @@ pub struct RadrootsPostEventIndex { pub struct RadrootsPostEventMetadata { pub id: String, pub author: String, - pub published_at: u32, + pub published_at: u64, pub kind: u32, pub post: RadrootsPost, } diff --git a/crates/events/src/profile/models.rs b/crates/events/src/profile/models.rs @@ -13,7 +13,7 @@ pub struct RadrootsProfileEventIndex { pub struct RadrootsProfileEventMetadata { pub id: String, pub author: String, - pub published_at: u32, + pub published_at: u64, pub kind: u32, pub profile: RadrootsProfile, } diff --git a/crates/net-core/src/nostr_client/status.rs b/crates/net-core/src/nostr_client/status.rs @@ -14,25 +14,22 @@ impl NostrClientManager { if let Some(monitor) = inner_for_task.client.monitor() { let mut rx = monitor.subscribe(); while let Ok(notification) = rx.recv().await { - let MonitorNotification::StatusChanged { relay_url, status } = notification - else { - continue; - }; + match notification { + MonitorNotification::StatusChanged { relay_url, status } => { + if let Ok(mut map) = inner_for_task.statuses.lock() { + map.insert(relay_url.clone(), status); + } else if let Ok(mut last) = inner_for_task.last_error.lock() { + *last = Some("status watcher: statuses mutex poisoned".to_string()); + warn!( + "status watcher: statuses mutex poisoned; dropping update for {}", + relay_url + ); + continue; + } - if let Ok(mut map) = inner_for_task.statuses.lock() { - map.insert(relay_url.clone(), status); - } else { - if let Ok(mut last) = inner_for_task.last_error.lock() { - *last = Some("status watcher: statuses mutex poisoned".to_string()); + info!("relay status changed {} -> {:?}", relay_url, status); } - warn!( - "status watcher: statuses mutex poisoned; dropping update for {}", - relay_url - ); - continue; } - - info!("relay status changed {} -> {:?}", relay_url, status); } } }); diff --git a/crates/nostr/src/event_adapters.rs b/crates/nostr/src/event_adapters.rs @@ -11,7 +11,7 @@ pub fn to_post_event_metadata(e: &Event) -> RadrootsPostEventMetadata { RadrootsPostEventMetadata { id: e.id.to_string(), author: e.pubkey.to_string(), - published_at: e.created_at.as_u64() as u32, + published_at: e.created_at.as_u64(), kind: e.kind.as_u16() as u32, post: RadrootsPost { content: e.content.clone(), @@ -25,7 +25,7 @@ pub fn to_profile_event_metadata(e: &Event) -> Option<RadrootsProfileEventMetada return Some(RadrootsProfileEventMetadata { id: e.id.to_string(), author: e.pubkey.to_string(), - published_at: e.created_at.as_u64() as u32, + published_at: e.created_at.as_u64(), kind: e.kind.as_u16() as u32, profile: p, }); @@ -47,7 +47,7 @@ pub fn to_profile_event_metadata(e: &Event) -> Option<RadrootsProfileEventMetada return Some(RadrootsProfileEventMetadata { id: e.id.to_string(), author: e.pubkey.to_string(), - published_at: e.created_at.as_u64() as u32, + published_at: e.created_at.as_u64(), kind: e.kind.as_u16() as u32, profile: p, });