Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ mod tests {
cleanup_interval: Duration::from_secs(120),
session_timeout: Duration::from_secs(600),
request_timeout: Duration::from_secs(60),
relay_list_urls: None,
bootstrap_relay_urls: None,
publish_relay_list: true,
profile_metadata: None,
};

let config = GatewayConfig { nostr_config };
Expand Down
5 changes: 5 additions & 0 deletions src/relay/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ impl RelayPoolTrait for MockRelayPool {

Ok(())
}

/// Mock ignores target URLs — delegates to `publish()`.
async fn publish_to(&self, _urls: &[String], builder: EventBuilder) -> Result<EventId> {
self.publish(builder).await
}
}

// ── Helpers ───────────────────────────────────────────────────────────────────
Expand Down
16 changes: 16 additions & 0 deletions src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub trait RelayPoolTrait: Send + Sync {
async fn public_key(&self) -> Result<PublicKey>;
/// Subscribe to events matching filters.
async fn subscribe(&self, filters: Vec<Filter>) -> Result<()>;
/// Sign and publish an event to specific relay URLs.
async fn publish_to(&self, urls: &[String], builder: EventBuilder) -> Result<EventId>;
}

/// Relay pool wrapper for managing Nostr relay connections.
Expand Down Expand Up @@ -135,6 +137,16 @@ impl RelayPool {
}
Ok(())
}

/// Sign and publish an event to specific relay URLs.
pub async fn publish_to(&self, urls: &[String], builder: EventBuilder) -> Result<EventId> {
let output = self
.client
.send_event_builder_to(urls, builder)
.await
.map_err(|e| Error::Transport(e.to_string()))?;
Ok(output.val)
}
}

#[async_trait]
Expand Down Expand Up @@ -177,4 +189,8 @@ impl RelayPoolTrait for RelayPool {
async fn subscribe(&self, filters: Vec<Filter>) -> Result<()> {
RelayPool::subscribe(self, filters).await
}

async fn publish_to(&self, urls: &[String], builder: EventBuilder) -> Result<EventId> {
RelayPool::publish_to(self, urls, builder).await
}
}
Loading
Loading