feat: add global_repositories query
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::{auth::User, error::Result, user::RepositorySchema, validate::validate_repo};
|
||||
use actix_web::{HttpResponse, web};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::AppState;
|
||||
|
||||
|
||||
@@ -4,5 +4,6 @@ use actix_web::{HttpResponse, web};
|
||||
use crate::AppState;
|
||||
|
||||
pub async fn global_repos(app_state: web::Data<AppState>) -> Result<HttpResponse> {
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
let repos = app_state.user.global_repositories().await?;
|
||||
Ok(repos)
|
||||
}
|
||||
|
||||
@@ -76,8 +76,15 @@ impl UserRepository {
|
||||
.await?
|
||||
.items()
|
||||
.iter()
|
||||
.filter_map(|item| Some(item.get("full_name")?.as_s().ok()?.to_string()))
|
||||
.filter_map(|item| {
|
||||
if (*item.get("approved")?.as_bool().ok()?) == false {
|
||||
return None;
|
||||
};
|
||||
Some(item.get("full_name")?.as_s().ok()?.to_string())
|
||||
})
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
}
|
||||
|
||||
pub async fn add_repository(
|
||||
@@ -97,6 +104,7 @@ impl UserRepository {
|
||||
.item("gsi1pk", AttributeValue::S("REPOS".into()))
|
||||
.item("gsi1sk", AttributeValue::S(now.clone()))
|
||||
.item("imported_at", AttributeValue::S(now))
|
||||
.item("approved", AttributeValue::Bool(false))
|
||||
.send()
|
||||
.await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user