remove unnecessary data structure

This commit is contained in:
Quaternions 2024-12-06 19:45:44 -08:00
parent 572e51961c
commit a019e61556

View File

@ -3,14 +3,6 @@ use crate::nats_types::ValidateRequest;
const SCRIPT_CONCURRENCY:usize=16; const SCRIPT_CONCURRENCY:usize=16;
enum Valid{
Untouched,
Modified{
model_id:u64,
model_version:u64,
},
}
enum Policy{ enum Policy{
Allowed, Allowed,
Blocked, Blocked,
@ -150,8 +142,8 @@ impl Validator{
} }
} }
// use a data structure to represent the validity // if the model was validated, the submission must be changed to use the modified model
let valid=if modified{ if modified{
// serialize model (slow!) // serialize model (slow!)
let mut data=Vec::new(); let mut data=Vec::new();
rbx_binary::to_writer(&mut data,&dom,&[dom.root_ref()]).map_err(ValidateError::WriteDom)?; rbx_binary::to_writer(&mut data,&dom,&[dom.root_ref()]).map_err(ValidateError::WriteDom)?;
@ -186,28 +178,14 @@ impl Validator{
(response.AssetId,model_version) (response.AssetId,model_version)
}; };
// tell the submission validate request to change the model // update the submission to use the validated model
Valid::Modified{ self.api.update_submission_model(api::UpdateSubmissionModelRequest{
model_id, ID:validate_info.submission_id,
model_version, ModelID:model_id,
} ModelVersion:model_version,
}else{ }).await.map_err(ValidateError::ApiUpdateSubmissionModel)?;
Valid::Untouched
}; };
// update the submission model if it was modified
match valid{
Valid::Untouched=>(),
Valid::Modified{model_id,model_version}=>{
// update the submission to use the validated model
self.api.update_submission_model(api::UpdateSubmissionModelRequest{
ID:validate_info.submission_id,
ModelID:model_id,
ModelVersion:model_version,
}).await.map_err(ValidateError::ApiUpdateSubmissionModel)?;
},
}
// update the submission model to display as validated // update the submission model to display as validated
self.api.action_submission_validate( self.api.action_submission_validate(
api::SubmissionID(validate_info.submission_id) api::SubmissionID(validate_info.submission_id)