validator: update metadata on Submitted
This commit is contained in:
parent
1b73af9fe2
commit
a5daa2df4a
validation
@ -167,6 +167,9 @@ impl Context{
|
||||
);
|
||||
action!("submissions",action_submission_submitted,config,ActionSubmissionSubmittedRequest,"status/validator-submitted",config.SubmissionID,
|
||||
("ModelVersion",config.ModelVersion.to_string().as_str())
|
||||
("DisplayName",config.DisplayName.as_str())
|
||||
("Creator",config.Creator.as_str())
|
||||
("GameID",config.GameID.to_string().as_str())
|
||||
);
|
||||
action!("submissions",action_submission_validated,config,SubmissionID,"status/validator-validated",config.0,);
|
||||
action!("submissions",update_submission_validated_model,config,UpdateSubmissionModelRequest,"validated-model",config.SubmissionID,
|
||||
@ -196,6 +199,9 @@ impl Context{
|
||||
);
|
||||
action!("mapfixes",action_mapfix_submitted,config,ActionMapfixSubmittedRequest,"status/validator-submitted",config.MapfixID,
|
||||
("ModelVersion",config.ModelVersion.to_string().as_str())
|
||||
("DisplayName",config.DisplayName.as_str())
|
||||
("Creator",config.Creator.as_str())
|
||||
("GameID",config.GameID.to_string().as_str())
|
||||
);
|
||||
action!("mapfixes",action_mapfix_validated,config,MapfixID,"status/validator-validated",config.0,);
|
||||
action!("mapfixes",update_mapfix_validated_model,config,UpdateMapfixModelRequest,"validated-model",config.MapfixID,
|
||||
|
@ -228,6 +228,9 @@ pub struct UpdateSubmissionModelRequest{
|
||||
pub struct ActionSubmissionSubmittedRequest{
|
||||
pub SubmissionID:i64,
|
||||
pub ModelVersion:u64,
|
||||
pub DisplayName:String,
|
||||
pub Creator:String,
|
||||
pub GameID:u32,
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
@ -267,6 +270,9 @@ pub struct UpdateMapfixModelRequest{
|
||||
pub struct ActionMapfixSubmittedRequest{
|
||||
pub MapfixID:i64,
|
||||
pub ModelVersion:u64,
|
||||
pub DisplayName:String,
|
||||
pub Creator:String,
|
||||
pub GameID:u32,
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::download::download_asset_version;
|
||||
use crate::rbx_util::{class_is_a,get_mapinfo,get_root_instance,read_dom,MapInfo,ReadDomError};
|
||||
use crate::rbx_util::{class_is_a,get_mapinfo,get_root_instance,read_dom,ReadDomError,GameID};
|
||||
|
||||
use heck::{ToSnakeCase,ToTitleCase};
|
||||
|
||||
@ -61,6 +61,17 @@ impl std::fmt::Display for Check{
|
||||
}
|
||||
}
|
||||
|
||||
pub enum CheckStatus{
|
||||
Passed{
|
||||
display_name:String,
|
||||
creator:String,
|
||||
game_id:GameID,
|
||||
},
|
||||
Failed{
|
||||
report:CheckReport,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CheckReport{
|
||||
// === METADATA CHECKS ===
|
||||
@ -204,13 +215,13 @@ impl Counts{
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check(dom:&rbx_dom_weak::WeakDom)->CheckReport{
|
||||
pub fn check(dom:&rbx_dom_weak::WeakDom)->CheckStatus{
|
||||
// empty report with all checks failed
|
||||
let mut report=CheckReport::default();
|
||||
|
||||
// extract the root instance, otherwise immediately return
|
||||
let Ok(model_instance)=get_root_instance(&dom)else{
|
||||
return report;
|
||||
return CheckStatus::Failed{report};
|
||||
};
|
||||
|
||||
report.exactly_one_root=Check::Pass;
|
||||
@ -223,10 +234,10 @@ pub fn check(dom:&rbx_dom_weak::WeakDom)->CheckReport{
|
||||
}
|
||||
|
||||
// extract model info
|
||||
let MapInfo{display_name,creator,game_id}=get_mapinfo(&dom,model_instance);
|
||||
let map_info=get_mapinfo(&dom,model_instance);
|
||||
|
||||
// check DisplayName
|
||||
if let Ok(display_name)=display_name{
|
||||
if let Ok(display_name)=map_info.display_name{
|
||||
if !display_name.is_empty(){
|
||||
report.has_display_name=Check::Pass;
|
||||
if display_name==display_name.to_title_case(){
|
||||
@ -236,14 +247,14 @@ pub fn check(dom:&rbx_dom_weak::WeakDom)->CheckReport{
|
||||
}
|
||||
|
||||
// check Creator
|
||||
if let Ok(creator)=creator{
|
||||
if let Ok(creator)=map_info.creator{
|
||||
if !creator.is_empty(){
|
||||
report.has_creator=Check::Pass;
|
||||
}
|
||||
}
|
||||
|
||||
// check GameID
|
||||
if game_id.is_ok(){
|
||||
if map_info.game_id.is_ok(){
|
||||
report.model_name_prefix_is_valid=Check::Pass;
|
||||
}
|
||||
|
||||
@ -298,11 +309,20 @@ pub fn check(dom:&rbx_dom_weak::WeakDom)->CheckReport{
|
||||
report.no_duplicate_wormhole_out=Check::Pass;
|
||||
}
|
||||
|
||||
report
|
||||
if report.pass(){
|
||||
CheckStatus::Passed{
|
||||
// TODO: refactor data structure to avoid pain
|
||||
display_name:map_info.display_name.unwrap().to_owned(),
|
||||
creator:map_info.creator.unwrap().to_owned(),
|
||||
game_id:map_info.game_id.unwrap(),
|
||||
}
|
||||
}else{
|
||||
CheckStatus::Failed{report}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CheckReportAndVersion{
|
||||
pub report:CheckReport,
|
||||
pub status:CheckStatus,
|
||||
pub version:u64,
|
||||
}
|
||||
|
||||
@ -329,8 +349,8 @@ impl crate::message_handler::MessageHandler{
|
||||
// decode dom (slow!)
|
||||
let dom=maybe_gzip.read_with(read_dom,read_dom).map_err(Error::ModelFileDecode)?;
|
||||
|
||||
let report=check(&dom);
|
||||
let status=check(&dom);
|
||||
|
||||
Ok(CheckReportAndVersion{report,version})
|
||||
Ok(CheckReportAndVersion{status,version})
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::check::CheckReportAndVersion;
|
||||
use crate::check::{CheckStatus,CheckReportAndVersion};
|
||||
use crate::nats_types::CheckMapfixRequest;
|
||||
|
||||
#[allow(dead_code)]
|
||||
@ -21,23 +21,27 @@ impl crate::message_handler::MessageHandler{
|
||||
|
||||
// update the mapfix depending on the result
|
||||
match check_result{
|
||||
Ok(CheckReportAndVersion{report,version})=>{
|
||||
if report.pass(){
|
||||
Ok(CheckReportAndVersion{status,version})=>{
|
||||
match status{
|
||||
// update the mapfix model status to submitted
|
||||
CheckStatus::Passed{display_name,creator,game_id}=>
|
||||
self.api.action_mapfix_submitted(
|
||||
submissions_api::types::ActionMapfixSubmittedRequest{
|
||||
MapfixID:mapfix_id,
|
||||
ModelVersion:version,
|
||||
DisplayName:display_name,
|
||||
Creator:creator,
|
||||
GameID:game_id as u32,
|
||||
}
|
||||
).await.map_err(Error::ApiActionMapfixCheck)?;
|
||||
}else{
|
||||
).await.map_err(Error::ApiActionMapfixCheck)?,
|
||||
// update the mapfix model status to request changes
|
||||
CheckStatus::Failed{report}=>
|
||||
self.api.action_mapfix_request_changes(
|
||||
submissions_api::types::ActionMapfixRequestChangesRequest{
|
||||
MapfixID:mapfix_id,
|
||||
ErrorMessage:report.to_string(),
|
||||
}
|
||||
).await.map_err(Error::ApiActionMapfixCheck)?;
|
||||
).await.map_err(Error::ApiActionMapfixCheck)?,
|
||||
}
|
||||
},
|
||||
Err(e)=>{
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::check::CheckReportAndVersion;
|
||||
use crate::check::{CheckStatus,CheckReportAndVersion};
|
||||
use crate::nats_types::CheckSubmissionRequest;
|
||||
|
||||
#[allow(dead_code)]
|
||||
@ -21,23 +21,27 @@ impl crate::message_handler::MessageHandler{
|
||||
|
||||
// update the submission depending on the result
|
||||
match check_result{
|
||||
Ok(CheckReportAndVersion{report,version})=>{
|
||||
if report.pass(){
|
||||
Ok(CheckReportAndVersion{status,version})=>{
|
||||
match status{
|
||||
// update the submission model status to submitted
|
||||
CheckStatus::Passed{display_name,creator,game_id}=>
|
||||
self.api.action_submission_submitted(
|
||||
submissions_api::types::ActionSubmissionSubmittedRequest{
|
||||
SubmissionID:submission_id,
|
||||
ModelVersion:version,
|
||||
DisplayName:display_name,
|
||||
Creator:creator,
|
||||
GameID:game_id as u32,
|
||||
}
|
||||
).await.map_err(Error::ApiActionSubmissionCheck)?;
|
||||
}else{
|
||||
).await.map_err(Error::ApiActionSubmissionCheck)?,
|
||||
// update the submission model status to request changes
|
||||
CheckStatus::Failed{report}=>
|
||||
self.api.action_submission_request_changes(
|
||||
submissions_api::types::ActionSubmissionRequestChangesRequest{
|
||||
SubmissionID:submission_id,
|
||||
ErrorMessage:report.to_string(),
|
||||
}
|
||||
).await.map_err(Error::ApiActionSubmissionCheck)?;
|
||||
).await.map_err(Error::ApiActionSubmissionCheck)?,
|
||||
}
|
||||
},
|
||||
Err(e)=>{
|
||||
|
@ -89,6 +89,7 @@ pub struct MapInfo<'a>{
|
||||
pub game_id:Result<GameID,ParseGameIDError>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum StringValueError{
|
||||
ObjectNotFound,
|
||||
ValueNotSet,
|
||||
|
Loading…
x
Reference in New Issue
Block a user