From b8a5f7dc24d90cd99e4d73b1c82d4a477d6fbe4d Mon Sep 17 00:00:00 2001 From: Filip-L <67787091+Filip-L@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:14:50 +0200 Subject: [PATCH] Allow only the allocator to trigger ssa endpoint --- fplus-http-server/src/main.rs | 2 +- fplus-http-server/src/router/application.rs | 4 ++-- fplus-lib/src/core/mod.rs | 11 ++++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fplus-http-server/src/main.rs b/fplus-http-server/src/main.rs index dcffc20..cbcec84 100644 --- a/fplus-http-server/src/main.rs +++ b/fplus-http-server/src/main.rs @@ -79,6 +79,7 @@ async fn main() -> std::io::Result<()> { .service(router::application::approve) .service(router::application::decline) .service(router::application::additional_info_required) + .service(router::application::trigger_ssa) ) .service(router::application::merged) .service(router::application::active) @@ -96,7 +97,6 @@ async fn main() -> std::io::Result<()> { .service(router::application::delete_branch) .service(router::application::cache_renewal) .service(router::application::update_from_issue) - .service(router::application::trigger_ssa) .service(router::blockchain::address_allowance) .service(router::blockchain::verified_clients) .service(router::verifier::verifiers) diff --git a/fplus-http-server/src/router/application.rs b/fplus-http-server/src/router/application.rs index 8af51d2..b974a77 100644 --- a/fplus-http-server/src/router/application.rs +++ b/fplus-http-server/src/router/application.rs @@ -457,8 +457,8 @@ pub async fn health() -> impl Responder { } #[post("application/trigger_ssa")] -pub async fn trigger_ssa(info: web::Json) -> impl Responder { - match LDNApplication::trigger_ssa(info.into_inner()).await { +pub async fn trigger_ssa(query: web::Query, info: web::Json) -> impl Responder { + match LDNApplication::trigger_ssa(&query.id, &query.owner, &query.repo, info.into_inner()).await { Ok(()) => { return HttpResponse::Ok().body(serde_json::to_string_pretty("Success").unwrap()) } diff --git a/fplus-lib/src/core/mod.rs b/fplus-lib/src/core/mod.rs index 20ef6c8..90bb443 100644 --- a/fplus-lib/src/core/mod.rs +++ b/fplus-lib/src/core/mod.rs @@ -47,9 +47,6 @@ pub struct CreateApplicationInfo { #[derive(Deserialize)] pub struct TriggerSSAInfo { - pub id: String, - pub owner: String, - pub repo: String, pub amount: String, pub amount_type: String, } @@ -3534,15 +3531,15 @@ _The initial issue can be edited in order to solve the request of the verifier. Ok(updated_application) // Return the updated ApplicationFile } - pub async fn trigger_ssa(info: TriggerSSAInfo) -> Result<(), LDNError> { + pub async fn trigger_ssa(id: &str, owner: &str, repo: &str, info: TriggerSSAInfo) -> Result<(), LDNError> { let app_model = - Self::get_application_model(info.id.clone(), info.owner.clone(), info.repo.clone()) + Self::get_application_model(id.into(), owner.into(), repo.into()) .await?; let app_str = app_model.application.ok_or_else(|| { LDNError::Load(format!( "Application {} does not have an application field", - info.id + id )) })?; let application_file = serde_json::from_str::(&app_str).unwrap(); @@ -3566,7 +3563,7 @@ _The initial issue can be edited in order to solve the request of the verifier. return Err(LDNError::Load("The sum of datacap requested so far and requested amount exceeds total requested amount".into())); } let refill_info = RefillInfo { - id: info.id, + id: id.into(), amount: info.amount, amount_type: info.amount_type, owner: app_model.owner,