forgejo-todo-checker/src/issues/fetch.rs

25 lines
649 B
Rust
Raw Normal View History

//
use std::collections::HashSet;
2024-09-20 07:23:36 +01:00
use crate::model::Config;
2024-12-03 07:41:51 +00:00
use color_eyre::Result;
2024-09-20 07:23:36 +01:00
use super::Issue;
pub async fn fetch_open_issues<'net, 'fs>(config: &Config<'net, 'fs>) -> Result<HashSet<Issue>> {
2024-09-20 07:23:36 +01:00
let server_url = config.server();
let repo = config.repo();
let url = format!("{server_url}/api/v1/repos/{repo}/issues?state=open");
let net = config.net();
let response = net
.get(url)
.with_option(config.auth_token())
.some(|request, auth_token| request.header("Authorization", auth_token))
.send()
.await?;
let issues: HashSet<Issue> = response.json().await?;
2024-09-20 07:23:36 +01:00
Ok(issues)
}