mirror of
https://github.com/lumehq/lume.git
synced 2025-03-29 03:02:14 +01:00
chore: update keys.rs
and relay.rs
(#193)
This commit is contained in:
parent
bba324ea53
commit
b90ad1421f
@ -88,12 +88,12 @@ pub async fn save_account(
|
|||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub async fn load_account(npub: &str, state: State<'_, Nostr>) -> Result<bool, String> {
|
pub async fn load_account(npub: &str, state: State<'_, Nostr>) -> Result<bool, String> {
|
||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
let keyring = Entry::new(&npub, "nostr_secret").unwrap();
|
let keyring = Entry::new(npub, "nostr_secret").unwrap();
|
||||||
|
|
||||||
match keyring.get_password() {
|
match keyring.get_password() {
|
||||||
Ok(password) => {
|
Ok(password) => {
|
||||||
if password.starts_with("bunker://") {
|
if password.starts_with("bunker://") {
|
||||||
let local_keyring = Entry::new(&npub, "bunker_local_account").unwrap();
|
let local_keyring = Entry::new(npub, "bunker_local_account").unwrap();
|
||||||
|
|
||||||
match local_keyring.get_password() {
|
match local_keyring.get_password() {
|
||||||
Ok(local_password) => {
|
Ok(local_password) => {
|
||||||
|
@ -19,7 +19,7 @@ pub async fn get_relays(state: State<'_, Nostr>) -> Result<Relays, ()> {
|
|||||||
|
|
||||||
// Get connected relays
|
// Get connected relays
|
||||||
let list = client.relays().await;
|
let list = client.relays().await;
|
||||||
let connected_relays: Vec<String> = list.into_iter().map(|(url, _)| url.to_string()).collect();
|
let connected_relays: Vec<String> = list.into_keys().map(|url| url.to_string()).collect();
|
||||||
|
|
||||||
// Get NIP-65 relay list
|
// Get NIP-65 relay list
|
||||||
let signer = client.signer().await.unwrap();
|
let signer = client.signer().await.unwrap();
|
||||||
@ -80,9 +80,9 @@ pub async fn get_relays(state: State<'_, Nostr>) -> Result<Relays, ()> {
|
|||||||
pub async fn connect_relay(relay: &str, state: State<'_, Nostr>) -> Result<bool, ()> {
|
pub async fn connect_relay(relay: &str, state: State<'_, Nostr>) -> Result<bool, ()> {
|
||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
if let Ok(status) = client.add_relay(relay).await {
|
if let Ok(status) = client.add_relay(relay).await {
|
||||||
if status == true {
|
if status {
|
||||||
println!("connecting to relay: {}", relay);
|
println!("connecting to relay: {}", relay);
|
||||||
let _ = client.connect_relay(relay);
|
let _ = client.connect_relay(relay).await;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
@ -96,8 +96,8 @@ pub async fn connect_relay(relay: &str, state: State<'_, Nostr>) -> Result<bool,
|
|||||||
#[specta::specta]
|
#[specta::specta]
|
||||||
pub async fn remove_relay(relay: &str, state: State<'_, Nostr>) -> Result<bool, ()> {
|
pub async fn remove_relay(relay: &str, state: State<'_, Nostr>) -> Result<bool, ()> {
|
||||||
let client = &state.client;
|
let client = &state.client;
|
||||||
if let Ok(_) = client.remove_relay(relay).await {
|
if (client.remove_relay(relay).await).is_ok() {
|
||||||
let _ = client.disconnect_relay(relay);
|
let _ = client.disconnect_relay(relay).await;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user