-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from filecoin-project/disable-database
temp disable db integration
- Loading branch information
Showing
6 changed files
with
80 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,74 @@ | ||
use actix_web::web; | ||
use fplus_lib::core::application::ApplicationFile; | ||
use std::sync::Mutex; | ||
|
||
pub async fn validate_trigger(github_handle: String, pull_request_number: String) { | ||
if validate_rkh_holder(&github_handle).await { | ||
println!( | ||
"Validated Root Key Holder {} for application {}", | ||
&github_handle, pull_request_number | ||
); | ||
} else { | ||
println!( | ||
"No Root Key Holder found with github handle {}", | ||
github_handle | ||
); | ||
} | ||
pub async fn validate_trigger(github_handle: String, pull_request_number: String) -> bool { | ||
true | ||
// if validate_rkh_holder(&github_handle).await { | ||
// println!( | ||
// "Validated Root Key Holder {} for application {}", | ||
// &github_handle, pull_request_number | ||
// ); | ||
// } else { | ||
// println!( | ||
// "No Root Key Holder found with github handle {}", | ||
// github_handle | ||
// ); | ||
// } | ||
} | ||
|
||
pub async fn validate_proposal(github_handle: String, pull_request_number: String) { | ||
if validate_notary(&github_handle).await { | ||
println!( | ||
"Validated Notary {} Proposal for application {}", | ||
&github_handle, pull_request_number | ||
); | ||
} else { | ||
println!("No Notary found with github handle {}", github_handle); | ||
} | ||
pub async fn validate_proposal(github_handle: String, pull_request_number: String) -> bool { | ||
true | ||
// if validate_notary(&github_handle).await { | ||
// println!( | ||
// "Validated Notary {} Proposal for application {}", | ||
// &github_handle, pull_request_number | ||
// ); | ||
// } else { | ||
// println!("No Notary found with github handle {}", github_handle); | ||
// } | ||
} | ||
|
||
pub async fn validate_approval(github_handle: String, pull_request_number: String) { | ||
if validate_notary(&github_handle).await { | ||
println!( | ||
"Validated Notary {} Approval for application {}", | ||
&github_handle, pull_request_number | ||
); | ||
} else { | ||
println!("No Notary found with github handle {}", github_handle); | ||
} | ||
let application_file: ApplicationFile = | ||
fplus_lib::core::LDNApplication::get_by_pr_number(pull_request_number.parse().unwrap()).await.unwrap(); | ||
pub async fn validate_approval(github_handle: String, pull_request_number: String) -> bool { | ||
true | ||
// if validate_notary(&github_handle).await { | ||
// println!( | ||
// "Validated Notary {} Approval for application {}", | ||
// &github_handle, pull_request_number | ||
// ); | ||
// } else { | ||
// println!("No Notary found with github handle {}", github_handle); | ||
// } | ||
} | ||
|
||
async fn validate_rkh_holder(github_handle: &str) -> bool { | ||
let db_connection: web::Data<Mutex<mongodb::Client>> = | ||
web::Data::new(Mutex::new(fplus_database::core::setup::setup().await.unwrap())); | ||
let rkh_holders = fplus_database::core::collections::rkh::find(db_connection) | ||
.await | ||
.unwrap(); | ||
let rkh_holders: Option<fplus_database::core::collections::rkh::RootKeyHolder> = rkh_holders | ||
.into_iter() | ||
.find(|rkh| &rkh.github_handle == github_handle); | ||
if rkh_holders.is_none() { | ||
false | ||
} else { | ||
true | ||
} | ||
true | ||
// let db_connection: web::Data<Mutex<mongodb::Client>> = web::Data::new(Mutex::new( | ||
// fplus_database::core::setup::setup().await.unwrap(), | ||
// )); | ||
// let rkh_holders = fplus_database::core::collections::rkh::find(db_connection) | ||
// .await | ||
// .unwrap(); | ||
// let rkh_holders: Option<fplus_database::core::collections::rkh::RootKeyHolder> = rkh_holders | ||
// .into_iter() | ||
// .find(|rkh| &rkh.github_handle == github_handle); | ||
// if rkh_holders.is_none() { | ||
// false | ||
// } else { | ||
// true | ||
// } | ||
} | ||
|
||
async fn validate_notary(github_handle: &str) -> bool { | ||
let db_connection: web::Data<Mutex<mongodb::Client>> = | ||
web::Data::new(Mutex::new(fplus_database::core::setup::setup().await.unwrap())); | ||
let notary = fplus_database::core::collections::notary::find(db_connection) | ||
.await | ||
.unwrap(); | ||
let notary: Option<fplus_database::core::collections::notary::Notary> = notary | ||
.into_iter() | ||
.find(|n| &n.github_handle == github_handle); | ||
if notary.is_none() { | ||
false | ||
} else { | ||
true | ||
} | ||
true | ||
// let db_connection: web::Data<Mutex<mongodb::Client>> = web::Data::new(Mutex::new( | ||
// fplus_database::core::setup::setup().await.unwrap(), | ||
// )); | ||
// let notary = fplus_database::core::collections::notary::find(db_connection) | ||
// .await | ||
// .unwrap(); | ||
// let notary: Option<fplus_database::core::collections::notary::Notary> = notary | ||
// .into_iter() | ||
// .find(|n| &n.github_handle == github_handle); | ||
// if notary.is_none() { | ||
// false | ||
// } else { | ||
// true | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
use actix_web::{get, http::header::ContentType, web, HttpResponse, post}; | ||
use actix_web::{get, http::header::ContentType, post, web, HttpResponse}; | ||
use mongodb::Client; | ||
use std::sync::Mutex; | ||
|
||
#[get("/logs")] | ||
pub async fn get(db_connection: web::Data<Mutex<Client>>) -> HttpResponse { | ||
match fplus_database::core::collections::logs::find(db_connection).await { | ||
Ok(i) => HttpResponse::Ok() | ||
.content_type(ContentType::json()) | ||
.body(serde_json::to_string(&i).unwrap()), | ||
Err(_) => HttpResponse::InternalServerError().finish(), | ||
} | ||
pub async fn get() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
} | ||
|
||
#[post("/logs")] | ||
pub async fn post( | ||
db_connection: web::Data<Mutex<Client>>, | ||
rkh: web::Json<fplus_database::core::collections::logs::Log>, | ||
) -> HttpResponse { | ||
match fplus_database::core::collections::logs::insert(db_connection, rkh.into_inner()).await { | ||
Ok(_) => HttpResponse::Ok().finish(), | ||
Err(_) => HttpResponse::InternalServerError().finish(), | ||
} | ||
pub async fn post() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
use std::sync::Mutex; | ||
|
||
use actix_web::{get, HttpResponse, Responder}; | ||
|
||
pub mod application; | ||
pub mod blockchain; | ||
pub mod logs; | ||
pub mod notary; | ||
pub mod rkh; | ||
|
||
/// Return server health status | ||
#[get("/health")] | ||
pub async fn health(client: actix_web::web::Data<Mutex<mongodb::Client>>) -> impl Responder { | ||
let client = client.lock().unwrap(); | ||
match fplus_database::core::setup::db_health_check(client.clone()).await { | ||
Ok(_) => HttpResponse::Ok().body("OK"), | ||
Err(e) => HttpResponse::InternalServerError().body(format!("Error: {}", e)), | ||
} | ||
pub async fn health() -> impl Responder { | ||
HttpResponse::Ok().body("OK") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
use actix_web::{get, http::header::ContentType, web, HttpResponse, post}; | ||
use actix_web::{get, http::header::ContentType, post, web, HttpResponse}; | ||
use mongodb::Client; | ||
use std::sync::Mutex; | ||
|
||
#[get("/notary")] | ||
pub async fn get(db_connection: web::Data<Mutex<Client>>) -> HttpResponse { | ||
match fplus_database::core::collections::notary::find(db_connection).await { | ||
Ok(i) => HttpResponse::Ok() | ||
.content_type(ContentType::json()) | ||
.body(serde_json::to_string(&i).unwrap()), | ||
Err(_) => HttpResponse::InternalServerError().finish(), | ||
} | ||
pub async fn get() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
} | ||
|
||
#[post("/notary")] | ||
pub async fn post( | ||
db_connection: web::Data<Mutex<Client>>, | ||
rkh: web::Json<fplus_database::core::collections::notary::Notary>, | ||
) -> HttpResponse { | ||
match fplus_database::core::collections::notary::insert(db_connection, rkh.into_inner()).await { | ||
Ok(_) => HttpResponse::Ok().finish(), | ||
Err(_) => HttpResponse::InternalServerError().finish(), | ||
} | ||
pub async fn post() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
use actix_web::{get, http::header::ContentType, web, HttpResponse, post}; | ||
use actix_web::{get, http::header::ContentType, post, web, HttpResponse}; | ||
use mongodb::Client; | ||
use std::sync::Mutex; | ||
|
||
#[get("/rkh")] | ||
pub async fn get(db_connection: web::Data<Mutex<Client>>) -> HttpResponse { | ||
match fplus_database::core::collections::rkh::find(db_connection).await { | ||
Ok(i) => HttpResponse::Ok() | ||
.content_type(ContentType::json()) | ||
.body(serde_json::to_string(&i).unwrap()), | ||
Err(_) => HttpResponse::InternalServerError().finish(), | ||
} | ||
pub async fn get() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
} | ||
|
||
#[post("/rkh")] | ||
pub async fn post( | ||
db_connection: web::Data<Mutex<Client>>, | ||
rkh: web::Json<fplus_database::core::collections::rkh::RootKeyHolder>, | ||
) -> HttpResponse { | ||
match fplus_database::core::collections::rkh::insert(db_connection, rkh.into_inner()).await { | ||
Ok(_) => HttpResponse::Ok().finish(), | ||
Err(_) => HttpResponse::InternalServerError().finish(), | ||
} | ||
pub async fn post() -> HttpResponse { | ||
HttpResponse::InternalServerError().finish() | ||
} |