From ac1577080601c11c7e0887c68d58658da21cc4f4 Mon Sep 17 00:00:00 2001 From: phil Date: Sun, 5 Oct 2025 20:36:16 -0400 Subject: [PATCH] get repo handle to render links to issues page --- src/main.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/main.rs b/src/main.rs index d1dc4d2..64cb7fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,7 @@ use jacquard::{ language::Language, collection::Collection, value::Data, + string::AtUri, }, }; use std::time::Duration; @@ -120,6 +121,31 @@ async fn get_record(client: &reqwest::Client, at_uri: &str) -> Result Result> { + let mut url: Url = "https://slingshot.microcosm.blue".parse()?; + url.set_path("/xrpc/com.bad-example.identity.resolveMiniDoc"); + url.query_pairs_mut().append_pair("identifier", identifier); + let handle = client + .get(url) + .send() + .await? + .error_for_status()? + .json::() + .await? + .as_object() + .ok_or("minidoc response was not a json object")? + .get("handle") + .ok_or("minidoc response obj did not have 'handle' key")? + .as_str() + .ok_or("minidoc handle was not a string")? + .to_string(); + if handle == "handle.invalid" { + Ok(None) + } else { + Ok(Some(handle)) + } +} + #[tokio::main] async fn main() -> Result<()> { env_logger::init(); @@ -238,6 +264,11 @@ async fn main() -> Result<()> { continue; }; + let Ok(repo_uri) = AtUri::new(repo) else { + eprintln!("failed to parse repo to aturi for {subject}"); + continue; + }; + let repo_record = match get_record(&req_client, repo).await { Ok(m) => m, Err(e) => { @@ -250,6 +281,23 @@ async fn main() -> Result<()> { continue; }; + let repo_handle = match get_handle(&req_client, repo_uri.authority().as_str()).await { + Ok(Some(h)) => h, + Ok(None) => { + eprintln!("invalid handle from identifier in {repo_uri} for {subject}"); + continue; + } + Err(e) => { + eprintln!("failed to get repo handle from identifier: {e} for {subject}"); + continue; + } + }; + + let issues_url = format!("https://tangled.org/@{repo_handle}/{name}/issues"); + println!("hi: {issues_url}"); + + // let message = format!(r#""#); + eprintln!("got {subject} {title:?} for {name}"); } -- 2.51.2