announcing good-first-issue tags added on @tangled.sh (not affiliated with tangled!)

get repo handle to render links to issues page

+48
+48
src/main.rs
··· 21 21 language::Language, 22 22 collection::Collection, 23 23 value::Data, 24 + string::AtUri, 24 25 }, 25 26 }; 26 27 use std::time::Duration; ··· 120 121 Ok(record_map) 121 122 } 122 123 124 + async fn get_handle(client: &reqwest::Client, identifier: &str) -> Result<Option<String>> { 125 + let mut url: Url = "https://slingshot.microcosm.blue".parse()?; 126 + url.set_path("/xrpc/com.bad-example.identity.resolveMiniDoc"); 127 + url.query_pairs_mut().append_pair("identifier", identifier); 128 + let handle = client 129 + .get(url) 130 + .send() 131 + .await? 132 + .error_for_status()? 133 + .json::<serde_json::Value>() 134 + .await? 135 + .as_object() 136 + .ok_or("minidoc response was not a json object")? 137 + .get("handle") 138 + .ok_or("minidoc response obj did not have 'handle' key")? 139 + .as_str() 140 + .ok_or("minidoc handle was not a string")? 141 + .to_string(); 142 + if handle == "handle.invalid" { 143 + Ok(None) 144 + } else { 145 + Ok(Some(handle)) 146 + } 147 + } 148 + 123 149 #[tokio::main] 124 150 async fn main() -> Result<()> { 125 151 env_logger::init(); ··· 238 264 continue; 239 265 }; 240 266 267 + let Ok(repo_uri) = AtUri::new(repo) else { 268 + eprintln!("failed to parse repo to aturi for {subject}"); 269 + continue; 270 + }; 271 + 241 272 let repo_record = match get_record(&req_client, repo).await { 242 273 Ok(m) => m, 243 274 Err(e) => { ··· 249 280 eprintln!("failed to get name for repo for {subject}"); 250 281 continue; 251 282 }; 283 + 284 + let repo_handle = match get_handle(&req_client, repo_uri.authority().as_str()).await { 285 + Ok(Some(h)) => h, 286 + Ok(None) => { 287 + eprintln!("invalid handle from identifier in {repo_uri} for {subject}"); 288 + continue; 289 + } 290 + Err(e) => { 291 + eprintln!("failed to get repo handle from identifier: {e} for {subject}"); 292 + continue; 293 + } 294 + }; 295 + 296 + let issues_url = format!("https://tangled.org/@{repo_handle}/{name}/issues"); 297 + println!("hi: {issues_url}"); 298 + 299 + // let message = format!(r#""#); 252 300 253 301 eprintln!("got {subject} {title:?} for {name}"); 254 302 }