this repo has no description
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Get did doc/pds for account

+23 -1
+23 -1
src/did.rs
··· 4 4 #[derive(Debug)] 5 5 pub struct DidDoc { 6 6 pub did: String, 7 + pub pds: String, 7 8 } 8 9 9 10 fn get_txt_did(handle: &String) -> Result<String, ()> { ··· 63 64 } 64 65 65 66 fn parse_doc(did: String, text: String) -> Result<DidDoc, ()> { 66 - return Ok(DidDoc { did: String::new() }); 67 + let text_json = match json::parse(&text) { 68 + Ok(val) => val, 69 + Err(_) => return Err(()), 70 + }; 71 + 72 + for service in text_json["service"].members() { 73 + if service["id"] 74 + .as_str() 75 + .is_some_and(|x| x.ends_with("#atproto_pds")) 76 + && service["type"] 77 + .as_str() 78 + .is_some_and(|x| x == "AtprotoPersonalDataServer") 79 + && let Some(pds) = service["serviceEndpoint"].as_str() 80 + { 81 + return Ok(DidDoc { 82 + did: did, 83 + pds: pds.to_string(), 84 + }); 85 + } 86 + } 87 + 88 + return Err(()); 67 89 } 68 90 69 91 fn get_plc_doc(plc: &str) -> Result<DidDoc, ()> {