upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib/git
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-12-10 12:12:14 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-12-10 12:12:14 +0000
commit36eb9395567dc0022b1700ec9cda1389baf22476 (patch)
treeb5ed71fc7431faacfa29690739db2fe77a0cdc7d /src/lib/git
parent8d8c21d05e4d8d7af30a96704a5919efc07010dc (diff)
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.
Diffstat (limited to 'src/lib/git')
-rw-r--r--src/lib/git/nostr_url.rs10
1 files changed, 10 insertions, 0 deletions
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>) ->
237 } 237 }
238} 238}
239 239
240pub fn use_nip05_git_config_cache_to_find_nip05_from_public_key(
241 public_key: &PublicKey,
242 git_repo: &Option<&Repo>,
243) -> Result<Option<String>> {
244 let h = load_nip_cache(git_repo)?;
245 Ok(h.iter()
246 .find_map(|(k, v)| if *v == *public_key { Some(k) } else { None })
247 .cloned())
248}
249
240fn save_nip05_to_git_config_cache( 250fn save_nip05_to_git_config_cache(
241 nip05: &str, 251 nip05: &str,
242 public_key: &PublicKey, 252 public_key: &PublicKey,