mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 00:59:07 -05:00
feat(NIP-15): Implement NIP15
NIP15 sends an EOSE notice to clients after all stored events are sent to allow loading indicators and other use cases.
This commit is contained in:
parent
538d139ebf
commit
a36ad378f6
|
@ -575,6 +575,12 @@ pub async fn db_query(
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
query_tx
|
||||||
|
.blocking_send(QueryResult {
|
||||||
|
sub_id: sub.get_id(),
|
||||||
|
event: "EOSE".to_string(),
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
debug!(
|
debug!(
|
||||||
"query completed ({} rows) in {:?}",
|
"query completed ({} rows) in {:?}",
|
||||||
row_count,
|
row_count,
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl From<config::Info> for RelayInfo {
|
||||||
description: i.description,
|
description: i.description,
|
||||||
pubkey: i.pubkey,
|
pubkey: i.pubkey,
|
||||||
contact: i.contact,
|
contact: i.contact,
|
||||||
supported_nips: Some(vec![1, 2, 11]),
|
supported_nips: Some(vec![1, 2, 11, 15]),
|
||||||
software: Some("https://git.sr.ht/~gheartsfield/nostr-rs-relay".to_owned()),
|
software: Some("https://git.sr.ht/~gheartsfield/nostr-rs-relay".to_owned()),
|
||||||
version: CARGO_PKG_VERSION.map(|x| x.to_owned()),
|
version: CARGO_PKG_VERSION.map(|x| x.to_owned()),
|
||||||
}
|
}
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -424,11 +424,16 @@ async fn nostr_server(
|
||||||
},
|
},
|
||||||
Some(query_result) = query_rx.recv() => {
|
Some(query_result) = query_rx.recv() => {
|
||||||
// database informed us of a query result we asked for
|
// database informed us of a query result we asked for
|
||||||
client_received_event_count += 1;
|
|
||||||
// send a result
|
|
||||||
let subesc = query_result.sub_id.replace("\"", "");
|
let subesc = query_result.sub_id.replace("\"", "");
|
||||||
let send_str = format!("[\"EVENT\",\"{}\",{}]", subesc, &query_result.event);
|
if query_result.event == "EOSE" {
|
||||||
ws_stream.send(Message::Text(send_str)).await.ok();
|
let send_str = format!("[\"EOSE\",\"{}\"]", subesc);
|
||||||
|
ws_stream.send(Message::Text(send_str)).await.ok();
|
||||||
|
} else {
|
||||||
|
client_received_event_count += 1;
|
||||||
|
// send a result
|
||||||
|
let send_str = format!("[\"EVENT\",\"{}\",{}]", subesc, &query_result.event);
|
||||||
|
ws_stream.send(Message::Text(send_str)).await.ok();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// TODO: consider logging the LaggedRecv error
|
// TODO: consider logging the LaggedRecv error
|
||||||
Ok(global_event) = bcast_rx.recv() => {
|
Ok(global_event) = bcast_rx.recv() => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user