wip: update nostr sdk
Some checks failed
Rust / build (ubuntu-latest, stable) (push) Failing after 1m35s
Some checks failed
Rust / build (ubuntu-latest, stable) (push) Failing after 1m35s
This commit is contained in:
@@ -4,7 +4,7 @@ use std::collections::HashSet;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::rc::Rc;
|
||||
|
||||
use anyhow::{anyhow, Error};
|
||||
use anyhow::{anyhow, Context as AnyhowContext, Error};
|
||||
use gpui::{
|
||||
App, AppContext, Context, Entity, Global, IntoElement, ParentElement, SharedString, Styled,
|
||||
Subscription, Task, Window,
|
||||
@@ -137,8 +137,8 @@ impl RelayAuth {
|
||||
async fn handle_notifications(client: &Client, tx: &flume::Sender<AuthRequest>) {
|
||||
let mut notifications = client.notifications();
|
||||
|
||||
while let Ok(notification) = notifications.recv().await {
|
||||
if let RelayPoolNotification::Message {
|
||||
while let Some(notification) = notifications.next().await {
|
||||
if let ClientNotification::Message {
|
||||
message: RelayMessage::Auth { challenge },
|
||||
relay_url,
|
||||
} = notification
|
||||
@@ -184,34 +184,33 @@ impl RelayAuth {
|
||||
let url_clone = url.clone();
|
||||
|
||||
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
||||
let signer = client.signer().await?;
|
||||
|
||||
// Construct event
|
||||
let event: Event = EventBuilder::auth(challenge_clone, url_clone.clone())
|
||||
.sign(&signer)
|
||||
.await?;
|
||||
let builder = EventBuilder::auth(challenge_clone, url_clone.clone());
|
||||
let event = client.sign_event_builder(builder).await?;
|
||||
|
||||
// Get the event ID
|
||||
let id = event.id;
|
||||
|
||||
// Get the relay
|
||||
let relay = client.pool().relay(url_clone).await?;
|
||||
let relay = client.relay(url_clone).await?.context("Relay not found")?;
|
||||
let relay_url = relay.url();
|
||||
|
||||
// Subscribe to notifications
|
||||
let mut notifications = relay.notifications();
|
||||
|
||||
// Send the AUTH message
|
||||
relay.send_msg(ClientMessage::Auth(Cow::Borrowed(&event)))?;
|
||||
relay
|
||||
.send_msg(ClientMessage::Auth(Cow::Borrowed(&event)))
|
||||
.await?;
|
||||
|
||||
while let Ok(notification) = notifications.recv().await {
|
||||
while let Some(notification) = notifications.next().await {
|
||||
match notification {
|
||||
RelayNotification::Message {
|
||||
message: RelayMessage::Ok { event_id, .. },
|
||||
} => {
|
||||
if id == event_id {
|
||||
// Re-subscribe to previous subscription
|
||||
relay.resubscribe().await?;
|
||||
// relay.resubscribe().await?;
|
||||
|
||||
// Get all pending events that need to be resent
|
||||
let mut tracker = tracker().write().await;
|
||||
@@ -228,7 +227,6 @@ impl RelayAuth {
|
||||
}
|
||||
}
|
||||
RelayNotification::AuthenticationFailed => break,
|
||||
RelayNotification::Shutdown => break,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user