Skip to content

Commit

Permalink
Allow only the allocator to trigger ssa endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip-L authored and kacperzuk-neti committed Jun 4, 2024
1 parent 90a9e76 commit b8a5f7d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fplus-http-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions fplus-http-server/src/router/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ pub async fn health() -> impl Responder {
}

#[post("application/trigger_ssa")]
pub async fn trigger_ssa(info: web::Json<TriggerSSAInfo>) -> impl Responder {
match LDNApplication::trigger_ssa(info.into_inner()).await {
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 {
Ok(()) => {
return HttpResponse::Ok().body(serde_json::to_string_pretty("Success").unwrap())
}
Expand Down
11 changes: 4 additions & 7 deletions fplus-lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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::<ApplicationFile>(&app_str).unwrap();
Expand All @@ -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,
Expand Down

0 comments on commit b8a5f7d

Please sign in to comment.