Allow v2 version creation route to accept environment (#6454)

* Allow v2 version creation route to accept environment

* fix
This commit is contained in:
aecsocket
2026-06-20 19:30:32 +00:00
committed by GitHub
parent 86a224419c
commit be65589e4d
3 changed files with 107 additions and 17 deletions
@@ -184,6 +184,12 @@ pub async fn project_create(
server_side,
),
);
if let Some(environment) = v.environment {
fields.insert(
"environment".to_string(),
json!(environment),
);
}
fields.insert(
"game_versions".to_string(),
json!(v.game_versions),
+21 -16
View File
@@ -55,6 +55,7 @@ pub struct InitialVersionData {
pub dependencies: Vec<Dependency>,
#[validate(length(min = 1))]
pub game_versions: Vec<String>,
pub environment: Option<String>,
#[serde(alias = "version_type")]
pub release_channel: VersionType,
#[validate(length(min = 1))]
@@ -160,22 +161,26 @@ pub async fn version_create(
.iter()
.any(|field| field == "environment")
{
// If so, we get the field of an example version of the project, and set the side types to match.
fields.insert(
"environment".into(),
get_example_version_fields(
legacy_create.project_id,
client,
&redis,
)
.await?
.into_iter()
.flatten()
.find(|f| f.field_name == "environment")
.map_or(json!("unknown"), |f| {
f.value.serialize_internal()
}),
);
let environment =
if let Some(environment) = legacy_create.environment {
json!(environment)
} else {
// If so, we get the field of an example version of the project, and set the side types to match.
get_example_version_fields(
legacy_create.project_id,
client,
&redis,
)
.await?
.into_iter()
.flatten()
.find(|f| f.field_name == "environment")
.map_or(json!("unknown"), |f| {
f.value.serialize_internal()
})
};
fields.insert("environment".into(), environment);
}
// Handle project type via file extension prediction
let mut project_type = None;