From 36eb9395567dc0022b1700ec9cda1389baf22476 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 10 Dec 2024 12:12:14 +0000 Subject: fix(nostr_url): use nip05 in nostr url if cached prioritise using nip05 nostr url format when the nip05, public key mapping is stored in the (usually local) git config. --- src/lib/git/nostr_url.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/lib/git/nostr_url.rs') diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs index 8bf458b..bc56e1a 100644 --- a/src/lib/git/nostr_url.rs +++ b/src/lib/git/nostr_url.rs @@ -237,6 +237,16 @@ fn resolve_nip05_from_git_config_cache(nip05: &str, git_repo: &Option<&Repo>) -> } } +pub fn use_nip05_git_config_cache_to_find_nip05_from_public_key( + public_key: &PublicKey, + git_repo: &Option<&Repo>, +) -> Result> { + let h = load_nip_cache(git_repo)?; + Ok(h.iter() + .find_map(|(k, v)| if *v == *public_key { Some(k) } else { None }) + .cloned()) +} + fn save_nip05_to_git_config_cache( nip05: &str, public_key: &PublicKey, -- cgit v1.2.3