diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-12-10 12:12:14 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-12-10 12:12:14 +0000 |
| commit | 36eb9395567dc0022b1700ec9cda1389baf22476 (patch) | |
| tree | b5ed71fc7431faacfa29690739db2fe77a0cdc7d /src/lib/git | |
| parent | 8d8c21d05e4d8d7af30a96704a5919efc07010dc (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.rs | 10 |
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 | ||
| 240 | pub 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 | |||
| 240 | fn save_nip05_to_git_config_cache( | 250 | fn save_nip05_to_git_config_cache( |
| 241 | nip05: &str, | 251 | nip05: &str, |
| 242 | public_key: &PublicKey, | 252 | public_key: &PublicKey, |