Structured files/directories and nip01, nip02, nip17 implementation

This commit is contained in:
Malte Schröder
2025-12-07 17:50:25 +01:00
commit b651c13fed
14 changed files with 1965 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
use anyhow::Result;
use nostr_sdk::prelude::*;
use nostr_sdk::nostr::TagStandard;
use crate::nips::nip02;
pub async fn get_contacts(client: &Client) -> Result<Vec<Contact>> {
let event_opt = nip02::get_contact_list_event(client).await?;
match event_opt {
Some(event) => {
let mut contacts = Vec::new();
for tag in event.tags {
if let Some(TagStandard::PublicKey { public_key, relay_url, alias, .. }) = tag.as_standardized() {
// Werte kopieren/klonen (Ownership Fix)
let mut contact = Contact::new(*public_key);
contact.relay_url = relay_url.clone();
contact.alias = alias.clone();
contacts.push(contact);
}
}
Ok(contacts)
}
None => Ok(Vec::new()),
}
}