tangled
alpha
login
or
join now
bad-example.com
/
hacktober-bot
6
fork
atom
announcing good-first-issue tags added on @tangled.sh (not affiliated with tangled!)
6
fork
atom
overview
issues
1
pulls
pipelines
get repo handle to render links to issues page
bad-example.com
5 months ago
ac157708
881bcfde
+48
1 changed file
expand all
collapse all
unified
split
src
main.rs
+48
src/main.rs
···
21
language::Language,
22
collection::Collection,
23
value::Data,
0
24
},
25
};
26
use std::time::Duration;
···
120
Ok(record_map)
121
}
122
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
123
#[tokio::main]
124
async fn main() -> Result<()> {
125
env_logger::init();
···
238
continue;
239
};
240
0
0
0
0
0
241
let repo_record = match get_record(&req_client, repo).await {
242
Ok(m) => m,
243
Err(e) => {
···
249
eprintln!("failed to get name for repo for {subject}");
250
continue;
251
};
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
252
253
eprintln!("got {subject} {title:?} for {name}");
254
}
···
21
language::Language,
22
collection::Collection,
23
value::Data,
24
+
string::AtUri,
25
},
26
};
27
use std::time::Duration;
···
121
Ok(record_map)
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
+
149
#[tokio::main]
150
async fn main() -> Result<()> {
151
env_logger::init();
···
264
continue;
265
};
266
267
+
let Ok(repo_uri) = AtUri::new(repo) else {
268
+
eprintln!("failed to parse repo to aturi for {subject}");
269
+
continue;
270
+
};
271
+
272
let repo_record = match get_record(&req_client, repo).await {
273
Ok(m) => m,
274
Err(e) => {
···
280
eprintln!("failed to get name for repo for {subject}");
281
continue;
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#""#);
300
301
eprintln!("got {subject} {title:?} for {name}");
302
}