feat: allow user enter custom relay for relayfeeds

This commit is contained in:
2024-11-05 15:04:39 +07:00
parent 0b97248fb8
commit d80534c51f
6 changed files with 231 additions and 25 deletions

View File

@@ -381,6 +381,35 @@ pub async fn get_all_local_interests(
Ok(alt_events)
}
#[tauri::command]
#[specta::specta]
pub async fn get_relay_list(id: String, state: State<'_, Nostr>) -> Result<String, String> {
let client = &state.client;
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
let filter = Filter::new()
.author(public_key)
.kind(Kind::RelayList)
.limit(1);
let mut events = Events::new(&[filter.clone()]);
let mut rx = client
.stream_events(vec![filter], Some(Duration::from_secs(3)))
.await
.map_err(|e| e.to_string())?;
while let Some(event) = rx.next().await {
events.insert(event);
}
if let Some(event) = events.first() {
Ok(event.as_json())
} else {
Err("Relay list not found".into())
}
}
#[tauri::command]
#[specta::specta]
pub async fn get_all_profiles(state: State<'_, Nostr>) -> Result<Vec<Mention>, String> {

View File

@@ -67,11 +67,11 @@ impl Default for Settings {
pub const DEFAULT_DIFFICULTY: u8 = 0;
pub const FETCH_LIMIT: usize = 50;
pub const QUEUE_DELAY: u64 = 300;
pub const QUEUE_DELAY: u64 = 150;
pub const NOTIFICATION_SUB_ID: &str = "lume_notification";
fn main() {
// tracing_subscriber::fmt::init();
tracing_subscriber::fmt::init();
let builder = Builder::<tauri::Wry>::new().commands(collect_commands![
get_relays,
@@ -105,6 +105,7 @@ fn main() {
get_interest,
get_all_interests,
get_all_local_interests,
get_relay_list,
set_wallet,
load_wallet,
remove_wallet,