Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIL-315] fix: Refill update validated_by and validated_at #231

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion fplus-http-server/src/router/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,14 @@ pub async fn trigger_ssa(
query: web::Query<VerifierActionsQueryParams>,
info: web::Json<TriggerSSAInfo>,
) -> 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()),
Expand Down
4 changes: 3 additions & 1 deletion fplus-lib/src/core/application/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion fplus-lib/src/core/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions fplus-lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,15 +1534,15 @@ impl LDNApplication {
Ok(apps)
}

async fn refill(refill_info: RefillInfo) -> Result<bool, LDNError> {
async fn refill(verfier: &str, refill_info: RefillInfo) -> Result<bool, LDNError> {
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)
{
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),
Expand Down Expand Up @@ -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?;
Expand Down Expand Up @@ -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(())
}

Expand Down