submissions-api: v0.1.1
This commit is contained in:
parent
7e940cdfb1
commit
7d2147779a
2
submissions-api-rs/Cargo.lock
generated
2
submissions-api-rs/Cargo.lock
generated
@ -952,7 +952,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "submissions-api"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"reqwest",
|
||||
"serde",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "submissions-api"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
publish = ["strafesnet"]
|
||||
repository = "https://git.itzana.me/StrafesNET/maps-service"
|
||||
|
@ -50,13 +50,19 @@ pub struct ScriptPolicyResponse{
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
pub struct UpdateSubmissionModelRequest{
|
||||
pub ID:i64,
|
||||
pub SubmissionID:i64,
|
||||
pub ModelID:u64,
|
||||
pub ModelVersion:u64,
|
||||
}
|
||||
|
||||
pub struct SubmissionID(pub i64);
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
pub struct ActionSubmissionUploadedRequest{
|
||||
pub SubmissionID:i64,
|
||||
pub TargetAssetID:Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Context{
|
||||
base_url:String,
|
||||
@ -112,7 +118,7 @@ impl Context{
|
||||
.json().await.map_err(Error::Reqwest)
|
||||
}
|
||||
pub async fn update_submission_model(&self,config:UpdateSubmissionModelRequest)->Result<(),Error>{
|
||||
let url_raw=format!("{}/submissions/{}/model",self.base_url,config.ID);
|
||||
let url_raw=format!("{}/submissions/{}/model",self.base_url,config.SubmissionID);
|
||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
||||
|
||||
{
|
||||
@ -126,6 +132,20 @@ impl Context{
|
||||
|
||||
Ok(())
|
||||
}
|
||||
action!(action_submission_validate,"validator-validated");
|
||||
action!(action_submission_publish,"validator-published");
|
||||
pub async fn action_submission_uploaded(&self,config:ActionSubmissionUploadedRequest)->Result<(),Error>{
|
||||
let url_raw=format!("{}/submissions/{}/status/uploaded",self.base_url,config.SubmissionID);
|
||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?;
|
||||
|
||||
if let Some(target_asset_id)=config.TargetAssetID{
|
||||
url.query_pairs_mut()
|
||||
.append_pair("TargetAssetID",target_asset_id.to_string().as_str());
|
||||
}
|
||||
|
||||
self.post(url).await.map_err(Error::Reqwest)?
|
||||
.error_for_status().map_err(Error::Reqwest)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
action!(action_submission_validated,"validator-validated");
|
||||
action!(action_submission_released,"releaser-released");
|
||||
}
|
||||
|
4
validation/Cargo.lock
generated
4
validation/Cargo.lock
generated
@ -1804,9 +1804,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "submissions-api"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||
checksum = "7969c6c0b770ecfb57220c340f732d62a6fb1165b9ef038e33e7cd5a9658bdd5"
|
||||
checksum = "7a56a1a29c7608cab695b426e286a435752321ed718c03199c858b2ab13525e3"
|
||||
dependencies = [
|
||||
"reqwest",
|
||||
"serde",
|
||||
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
submissions-api = { version = "0.1.0", registry = "strafesnet" }
|
||||
submissions-api = { version = "0.1.1", registry = "strafesnet" }
|
||||
async-nats = "0.38.0"
|
||||
futures = "0.3.31"
|
||||
rbx_asset = { version = "0.2.5", registry = "strafesnet" }
|
||||
|
@ -6,7 +6,7 @@ pub enum PublishError{
|
||||
Get(rbx_asset::cookie::GetError),
|
||||
Json(serde_json::Error),
|
||||
Upload(rbx_asset::cookie::UploadError),
|
||||
ApiActionSubmissionPublish(submissions_api::Error),
|
||||
ApiActionSubmissionUploaded(submissions_api::Error),
|
||||
}
|
||||
impl std::fmt::Display for PublishError{
|
||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||
@ -52,10 +52,11 @@ impl Publisher{
|
||||
|
||||
// that's it, the database entry does not need to be changed.
|
||||
|
||||
// mark submission as published
|
||||
self.api.action_submission_publish(
|
||||
submissions_api::SubmissionID(publish_info.SubmissionID)
|
||||
).await.map_err(PublishError::ApiActionSubmissionPublish)?;
|
||||
// mark submission as uploaded, TargetAssetID is unchanged
|
||||
self.api.action_submission_uploaded(submissions_api::ActionSubmissionUploadedRequest{
|
||||
SubmissionID:publish_info.SubmissionID,
|
||||
TargetAssetID:None,
|
||||
}).await.map_err(PublishError::ApiActionSubmissionUploaded)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -50,10 +50,11 @@ impl Publisher{
|
||||
groupId:Some(crate::GROUP_STRAFESNET),
|
||||
},model_data).await.map_err(PublishError::Create)?;
|
||||
|
||||
// mark submission as published
|
||||
self.api.action_submission_publish(
|
||||
submissions_api::SubmissionID(publish_info.SubmissionID)
|
||||
).await.map_err(PublishError::ApiActionSubmissionPublish)?;
|
||||
// note the asset id of the created model for later release, and mark the submission as uploaded
|
||||
self.api.action_submission_uploaded(submissions_api::ActionSubmissionUploadedRequest{
|
||||
SubmissionID:publish_info.SubmissionID,
|
||||
TargetAssetID:Some(upload_response.AssetId),
|
||||
}).await.map_err(PublishError::ApiActionSubmissionPublish)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -167,14 +167,14 @@ impl Validator{
|
||||
|
||||
// update the submission to use the validated model
|
||||
self.api.update_submission_model(submissions_api::UpdateSubmissionModelRequest{
|
||||
ID:validate_info.SubmissionID,
|
||||
SubmissionID:validate_info.SubmissionID,
|
||||
ModelID:model_id,
|
||||
ModelVersion:1, //TODO
|
||||
}).await.map_err(ValidateError::ApiUpdateSubmissionModel)?;
|
||||
};
|
||||
|
||||
// update the submission model status to validated
|
||||
self.api.action_submission_validate(
|
||||
self.api.action_submission_validated(
|
||||
submissions_api::SubmissionID(validate_info.SubmissionID)
|
||||
).await.map_err(ValidateError::ApiActionSubmissionValidate)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user