validation: update api to yield a better error
This commit is contained in:
parent
b93c813dec
commit
7334e88b55
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1297,9 +1297,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rbx_asset"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||
checksum = "866fc6e4a9ce7cf32148d266c342876eb3f7432bdc09913aff11b032e77e1638"
|
||||
checksum = "077e2a0b201a777dfd2ff822766ae7d0c8c3003206115da57f7bce15ee73cbc7"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"flate2",
|
||||
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||
submissions-api = { path = "api", features = ["internal"], default-features = false, registry = "strafesnet" }
|
||||
async-nats = "0.40.0"
|
||||
futures = "0.3.31"
|
||||
rbx_asset = { version = "0.4.2", registry = "strafesnet" }
|
||||
rbx_asset = { version = "0.4.3", registry = "strafesnet" }
|
||||
rbx_binary = { version = "0.7.4", registry = "strafesnet"}
|
||||
rbx_dom_weak = { version = "2.9.0", registry = "strafesnet"}
|
||||
rbx_reflection_database = { version = "0.2.12", registry = "strafesnet"}
|
||||
|
@ -6,6 +6,7 @@ pub enum Error{
|
||||
CreatorTypeMustBeUser,
|
||||
ModelInfoDownload(rbx_asset::cloud::GetError),
|
||||
ModelLocationDownload(rbx_asset::cloud::GetError),
|
||||
NonFreeModel,
|
||||
ModelFileDownload(rbx_asset::cloud::GetError),
|
||||
ParseUserID(core::num::ParseIntError),
|
||||
ParseModelVersion(core::num::ParseIntError),
|
||||
@ -54,6 +55,11 @@ impl crate::message_handler::MessageHandler{
|
||||
version:asset_version,
|
||||
}).await.map_err(Error::ModelLocationDownload)?;
|
||||
|
||||
// if the location does not exist, you are not allowed to donwload it
|
||||
let Some(location)=location.location else{
|
||||
return Err(Error::NonFreeModel);
|
||||
};
|
||||
|
||||
// download the map model
|
||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::ModelFileDownload)?;
|
||||
|
||||
|
@ -4,6 +4,7 @@ use crate::nats_types::UploadMapfixRequest;
|
||||
#[derive(Debug)]
|
||||
pub enum Error{
|
||||
GetLocation(rbx_asset::cloud::GetError),
|
||||
NonFreeModel,
|
||||
Get(rbx_asset::cloud::GetError),
|
||||
Json(serde_json::Error),
|
||||
Upload(rbx_asset::cookie::UploadError),
|
||||
@ -24,6 +25,11 @@ impl crate::message_handler::MessageHandler{
|
||||
version:upload_info.ModelVersion,
|
||||
}).await.map_err(Error::GetLocation)?;
|
||||
|
||||
// if the location does not exist, you are not allowed to donwload it
|
||||
let Some(location)=location.location else{
|
||||
return Err(Error::NonFreeModel);
|
||||
};
|
||||
|
||||
// download the map model
|
||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::Get)?;
|
||||
|
||||
|
@ -4,6 +4,7 @@ use crate::nats_types::UploadSubmissionRequest;
|
||||
#[derive(Debug)]
|
||||
pub enum Error{
|
||||
GetLocation(rbx_asset::cloud::GetError),
|
||||
NonFreeModel,
|
||||
Get(rbx_asset::cloud::GetError),
|
||||
Json(serde_json::Error),
|
||||
Create(rbx_asset::cookie::CreateError),
|
||||
@ -25,6 +26,11 @@ impl crate::message_handler::MessageHandler{
|
||||
version:upload_info.ModelVersion,
|
||||
}).await.map_err(Error::GetLocation)?;
|
||||
|
||||
// if the location does not exist, you are not allowed to donwload it
|
||||
let Some(location)=location.location else{
|
||||
return Err(Error::NonFreeModel);
|
||||
};
|
||||
|
||||
// download the map model
|
||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::Get)?;
|
||||
|
||||
|
@ -37,6 +37,7 @@ pub enum Error{
|
||||
ScriptBlocked(Option<submissions_api::types::ScriptID>),
|
||||
ScriptNotYetReviewed(Option<submissions_api::types::ScriptID>),
|
||||
ModelLocationDownload(rbx_asset::cloud::GetError),
|
||||
NonFreeModel,
|
||||
ModelFileDownload(rbx_asset::cloud::GetError),
|
||||
ModelFileDecode(ReadDomError),
|
||||
ApiGetScriptPolicyFromHash(submissions_api::types::SingleItemError),
|
||||
@ -96,6 +97,11 @@ impl crate::message_handler::MessageHandler{
|
||||
version:validate_info.ModelVersion,
|
||||
}).await.map_err(Error::ModelLocationDownload)?;
|
||||
|
||||
// if the location does not exist, you are not allowed to donwload it
|
||||
let Some(location)=location.location else{
|
||||
return Err(Error::NonFreeModel);
|
||||
};
|
||||
|
||||
// download the map model
|
||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::ModelFileDownload)?;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user