feat: use upstream rust nostr
This commit is contained in:
22
src-tauri/Cargo.lock
generated
22
src-tauri/Cargo.lock
generated
@@ -2965,7 +2965,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.52.6",
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3362,7 +3362,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
|
||||
[[package]]
|
||||
name = "nostr"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64 0.22.1",
|
||||
@@ -3392,7 +3392,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-database"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"flatbuffers",
|
||||
@@ -3406,7 +3406,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-lmdb"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"heed",
|
||||
"nostr",
|
||||
@@ -3419,7 +3419,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-relay-builder"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"async-utility",
|
||||
"async-wsocket",
|
||||
@@ -3434,7 +3434,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-relay-pool"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"async-utility",
|
||||
"async-wsocket",
|
||||
@@ -3452,7 +3452,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-sdk"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"async-utility",
|
||||
"atomic-destructor",
|
||||
@@ -3472,7 +3472,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-signer"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"async-utility",
|
||||
"nostr",
|
||||
@@ -3485,7 +3485,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nostr-zapper"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"nostr",
|
||||
@@ -3629,7 +3629,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "nwc"
|
||||
version = "0.35.0"
|
||||
source = "git+https://github.com/rust-nostr/nostr#82f39b5655bd58f045194b14a2cda5ef119acef1"
|
||||
source = "git+https://github.com/rust-nostr/nostr#55c4014bc2ba301a91ba14b8363bbe44f5ee6cb6"
|
||||
dependencies = [
|
||||
"async-utility",
|
||||
"nostr",
|
||||
@@ -7029,7 +7029,7 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -41,10 +41,7 @@ pub async fn get_event(id: String, state: State<'_, Nostr>) -> Result<RichEvent,
|
||||
Ok(RichEvent { raw, parsed })
|
||||
} else {
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::relays(Some(Duration::from_secs(10))),
|
||||
)
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(10)))
|
||||
.await
|
||||
{
|
||||
Ok(events) => {
|
||||
@@ -81,10 +78,7 @@ pub async fn get_event_from(
|
||||
let filter = Filter::new().id(event_id);
|
||||
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::both(Some(Duration::from_secs(5))),
|
||||
)
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(5)))
|
||||
.await
|
||||
{
|
||||
Ok(events) => {
|
||||
@@ -113,10 +107,7 @@ pub async fn get_replies(id: String, state: State<'_, Nostr>) -> Result<Vec<Rich
|
||||
let filter = Filter::new().kinds(vec![Kind::TextNote]).event(event_id);
|
||||
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::both(Some(Duration::from_secs(5))),
|
||||
)
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(5)))
|
||||
.await
|
||||
{
|
||||
Ok(events) => {
|
||||
@@ -175,10 +166,7 @@ pub async fn get_all_events_by_author(
|
||||
.author(author)
|
||||
.limit(limit as usize);
|
||||
|
||||
match client
|
||||
.get_events_of(vec![filter], EventSource::Database)
|
||||
.await
|
||||
{
|
||||
match client.database().query(vec![filter]).await {
|
||||
Ok(events) => Ok(process_event(client, events).await),
|
||||
Err(err) => Err(err.to_string()),
|
||||
}
|
||||
@@ -209,10 +197,7 @@ pub async fn get_all_events_by_authors(
|
||||
.until(as_of)
|
||||
.authors(authors);
|
||||
|
||||
match client
|
||||
.get_events_of(vec![filter], EventSource::Database)
|
||||
.await
|
||||
{
|
||||
match client.database().query(vec![filter]).await {
|
||||
Ok(events) => Ok(process_event(client, events).await),
|
||||
Err(err) => Err(err.to_string()),
|
||||
}
|
||||
@@ -239,10 +224,7 @@ pub async fn get_all_events_by_hashtags(
|
||||
.hashtags(hashtags);
|
||||
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::both(Some(Duration::from_secs(5))),
|
||||
)
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(5)))
|
||||
.await
|
||||
{
|
||||
Ok(events) => Ok(process_event(client, events).await),
|
||||
@@ -293,10 +275,7 @@ pub async fn get_global_events(
|
||||
.until(as_of);
|
||||
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::both(Some(Duration::from_secs(5))),
|
||||
)
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(5)))
|
||||
.await
|
||||
{
|
||||
Ok(events) => Ok(process_event(client, events).await),
|
||||
@@ -477,13 +456,11 @@ pub async fn user_to_bech32(user: String, state: State<'_, Nostr>) -> Result<Str
|
||||
let public_key = PublicKey::parse(user).map_err(|err| err.to_string())?;
|
||||
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![Filter::new()
|
||||
.author(public_key)
|
||||
.kind(Kind::RelayList)
|
||||
.limit(1)],
|
||||
EventSource::both(Some(Duration::from_secs(5))),
|
||||
)
|
||||
.database()
|
||||
.query(vec![Filter::new()
|
||||
.author(public_key)
|
||||
.kind(Kind::RelayList)
|
||||
.limit(1)])
|
||||
.await
|
||||
{
|
||||
Ok(events) => match events.first() {
|
||||
|
||||
@@ -59,10 +59,7 @@ pub async fn get_profile(id: Option<String>, state: State<'_, Nostr>) -> Result<
|
||||
}
|
||||
} else {
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::relays(Some(Duration::from_secs(10))),
|
||||
)
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(10)))
|
||||
.await
|
||||
{
|
||||
Ok(events) => {
|
||||
@@ -518,10 +515,7 @@ pub async fn copy_friend(npub: &str, state: State<'_, Nostr>) -> Result<bool, St
|
||||
.limit(1);
|
||||
|
||||
if let Ok(contact_list_events) = client
|
||||
.get_events_of(
|
||||
vec![contact_list_filter],
|
||||
EventSource::both(Some(Duration::from_secs(5))),
|
||||
)
|
||||
.fetch_events(vec![contact_list_filter], Some(Duration::from_secs(5)))
|
||||
.await
|
||||
{
|
||||
for event in contact_list_events.into_iter() {
|
||||
|
||||
@@ -5,7 +5,6 @@ use specta::Type;
|
||||
use std::{
|
||||
fs::OpenOptions,
|
||||
io::{self, BufRead, Write},
|
||||
time::Duration,
|
||||
};
|
||||
use tauri::{path::BaseDirectory, Manager, State};
|
||||
|
||||
@@ -37,16 +36,7 @@ pub async fn get_relays(state: State<'_, Nostr>) -> Result<Relays, String> {
|
||||
.kind(Kind::RelayList)
|
||||
.limit(1);
|
||||
|
||||
match client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::Relays {
|
||||
timeout: Some(Duration::from_secs(5)),
|
||||
specific_relays: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
match client.database().query(vec![filter]).await {
|
||||
Ok(events) => {
|
||||
if let Some(event) = events.first() {
|
||||
let nip65_list = nip65::extract_relay_list(event).collect::<Vec<_>>();
|
||||
|
||||
@@ -4,9 +4,7 @@ use nostr_sdk::prelude::*;
|
||||
use reqwest::Client as ReqClient;
|
||||
use serde::Serialize;
|
||||
use specta::Type;
|
||||
use std::collections::HashSet;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use std::{collections::HashSet, str::FromStr, time::Duration};
|
||||
|
||||
use crate::RichEvent;
|
||||
|
||||
@@ -45,7 +43,7 @@ const NOSTR_MENTIONS: [&str; 10] = [
|
||||
"Nostr:naddr1",
|
||||
];
|
||||
|
||||
pub fn get_latest_event(events: &[Event]) -> Option<&Event> {
|
||||
pub fn get_latest_event(events: &Events) -> Option<&Event> {
|
||||
events.iter().next()
|
||||
}
|
||||
|
||||
@@ -130,7 +128,7 @@ pub fn create_tags(content: &str) -> Vec<Tag> {
|
||||
tags
|
||||
}
|
||||
|
||||
pub async fn process_event(client: &Client, events: Vec<Event>) -> Vec<RichEvent> {
|
||||
pub async fn process_event(client: &Client, events: Events) -> Vec<RichEvent> {
|
||||
// Remove event thread if event is TextNote
|
||||
let events: Vec<Event> = events
|
||||
.into_iter()
|
||||
@@ -211,10 +209,7 @@ pub async fn init_nip65(client: &Client, public_key: &str) {
|
||||
// client.connect_relay("ws://127.0.0.1:1984").await.unwrap();
|
||||
|
||||
if let Ok(events) = client
|
||||
.get_events_of(
|
||||
vec![filter],
|
||||
EventSource::relays(Some(Duration::from_secs(5))),
|
||||
)
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(5)))
|
||||
.await
|
||||
{
|
||||
if let Some(event) = events.first() {
|
||||
|
||||
Reference in New Issue
Block a user