From 5edb90d6ce8cf83b155bdb76a35f3ff73af97c84 Mon Sep 17 00:00:00 2001 From: Filip Lelek Date: Tue, 1 Oct 2024 13:40:00 +0200 Subject: [PATCH] Refill update validated_by and validated_at --- fplus-http-server/src/router/application.rs | 9 ++++++++- fplus-lib/src/core/application/lifecycle.rs | 4 +++- fplus-lib/src/core/application/mod.rs | 2 +- fplus-lib/src/core/mod.rs | 7 ++++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/fplus-http-server/src/router/application.rs b/fplus-http-server/src/router/application.rs index 8ad0591e..6dbb58f2 100644 --- a/fplus-http-server/src/router/application.rs +++ b/fplus-http-server/src/router/application.rs @@ -473,7 +473,14 @@ 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 + match LDNApplication::trigger_ssa( + &query.id, + &query.owner, + &query.repo, + &query.github_username, + info.into_inner(), + ) + .await { Ok(()) => HttpResponse::Ok().body(serde_json::to_string_pretty("Success").unwrap()), Err(e) => HttpResponse::BadRequest().body(e.to_string()), diff --git a/fplus-lib/src/core/application/lifecycle.rs b/fplus-lib/src/core/application/lifecycle.rs index bcddbe34..e296cc7d 100644 --- a/fplus-lib/src/core/application/lifecycle.rs +++ b/fplus-lib/src/core/application/lifecycle.rs @@ -80,9 +80,11 @@ impl LifeCycle { self.is_active } - pub fn start_refill_request(&self, request_id: String) -> Self { + pub fn start_refill_request(&self, actor: String, request_id: String) -> Self { LifeCycle { state: AppState::ReadyToSign, + validated_by: actor, + validated_at: Utc::now().to_string(), updated_at: Utc::now().to_string(), active_request: Some(request_id), ..self.clone() diff --git a/fplus-lib/src/core/application/mod.rs b/fplus-lib/src/core/application/mod.rs index 26db8196..e8e316ab 100644 --- a/fplus-lib/src/core/application/mod.rs +++ b/fplus-lib/src/core/application/mod.rs @@ -92,7 +92,7 @@ impl file::ApplicationFile { let new_life_cycle = self .lifecycle .clone() - .start_refill_request(request.id.clone()); + .start_refill_request(request.actor.clone(), request.id.clone()); let allocations = self.allocation.clone().push(request.clone()); Self { lifecycle: new_life_cycle, diff --git a/fplus-lib/src/core/mod.rs b/fplus-lib/src/core/mod.rs index b9ccabe7..a633eeeb 100644 --- a/fplus-lib/src/core/mod.rs +++ b/fplus-lib/src/core/mod.rs @@ -1534,7 +1534,7 @@ impl LDNApplication { Ok(apps) } - async fn refill(refill_info: RefillInfo) -> Result { + async fn refill(verfier: &str, refill_info: RefillInfo) -> Result { let apps = LDNApplication::merged(refill_info.owner.clone(), refill_info.repo.clone()).await?; if let Some((content, mut app)) = apps.into_iter().find(|(_, app)| app.id == refill_info.id) @@ -1542,7 +1542,7 @@ impl LDNApplication { let uuid = uuidv4::uuid::v4(); let request_id = uuid.clone(); let new_request = AllocationRequest::new( - "SSA Bot".to_string(), + verfier.to_string(), request_id.clone(), AllocationRequestType::Refill(0), format!("{}{}", refill_info.amount, refill_info.amount_type), @@ -3851,6 +3851,7 @@ _The initial issue can be edited in order to solve the request of the verifier. id: &str, owner: &str, repo: &str, + verifier: &str, info: TriggerSSAInfo, ) -> Result<(), LDNError> { let app_model = Self::get_application_model(id.into(), owner.into(), repo.into()).await?; @@ -3896,7 +3897,7 @@ _The initial issue can be edited in order to solve the request of the verifier. owner: app_model.owner, repo: app_model.repo, }; - Self::refill(refill_info).await?; + Self::refill(verifier, refill_info).await?; Ok(()) }