You've already forked AstralRinth
forked from didirus/AstralRinth
Fix plugin validator, fix version urls, clippy lints, additional categories (#421)
This commit is contained in:
@@ -25,11 +25,18 @@ pub async fn count_download(
|
||||
let project_id: crate::database::models::ids::ProjectId =
|
||||
download_body.hash.into();
|
||||
|
||||
let id_option = crate::models::ids::base62_impl::parse_base62(
|
||||
&download_body.version_name,
|
||||
)
|
||||
.ok()
|
||||
.map(|x| x as i64);
|
||||
|
||||
let (version_id, project_id) = if let Some(version) = sqlx::query!(
|
||||
"SELECT id, mod_id FROM versions
|
||||
WHERE (version_number = $1 AND mod_id = $2)",
|
||||
WHERE ((version_number = $1 OR id = $3) AND mod_id = $2)",
|
||||
download_body.version_name,
|
||||
project_id as crate::database::models::ids::ProjectId
|
||||
project_id as crate::database::models::ids::ProjectId,
|
||||
id_option
|
||||
)
|
||||
.fetch_optional(pool.as_ref())
|
||||
.await?
|
||||
|
||||
@@ -118,7 +118,7 @@ pub async fn maven_metadata(
|
||||
.last()
|
||||
.unwrap_or(&"release".to_string())
|
||||
.to_string(),
|
||||
release: latest_release.unwrap_or_default().to_string(),
|
||||
release: latest_release.unwrap_or_default(),
|
||||
versions: Versions {
|
||||
versions: new_versions,
|
||||
},
|
||||
|
||||
@@ -170,19 +170,34 @@ struct ProjectCreateData {
|
||||
/// A list of the categories that the project is in.
|
||||
pub additional_categories: Vec<String>,
|
||||
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
/// An optional link to where to submit bugs or issues with the project.
|
||||
pub issues_url: Option<String>,
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
/// An optional link to the source code for the project.
|
||||
pub source_url: Option<String>,
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
/// An optional link to the project's wiki page or other relevant information.
|
||||
pub wiki_url: Option<String>,
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
/// An optional link to the project's license page
|
||||
pub license_url: Option<String>,
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
/// An optional link to the project's discord.
|
||||
pub discord_url: Option<String>,
|
||||
/// An optional list of all donation links the project has\
|
||||
@@ -550,7 +565,7 @@ pub async fn project_create_inner(
|
||||
&cdn_url,
|
||||
&content_disposition,
|
||||
project_id,
|
||||
&version_data.version_number,
|
||||
created_version.version_id.into(),
|
||||
&*project_create_data.project_type,
|
||||
version_data.loaders.clone(),
|
||||
version_data.game_versions.clone(),
|
||||
|
||||
@@ -266,35 +266,50 @@ pub struct EditProject {
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
pub issues_url: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
pub source_url: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
pub wiki_url: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
pub license_url: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
#[validate(url, length(max = 2048))]
|
||||
#[validate(
|
||||
custom(function = "crate::util::validate::validate_url"),
|
||||
length(max = 2048)
|
||||
)]
|
||||
pub discord_url: Option<Option<String>>,
|
||||
#[validate]
|
||||
pub donation_urls: Option<Vec<DonationLink>>,
|
||||
|
||||
@@ -302,7 +302,7 @@ async fn version_create_inner(
|
||||
&cdn_url,
|
||||
&content_disposition,
|
||||
version.project_id.into(),
|
||||
&version.version_number,
|
||||
version.version_id.into(),
|
||||
&*project_type,
|
||||
version_data.loaders,
|
||||
version_data.game_versions,
|
||||
@@ -520,7 +520,6 @@ async fn upload_file_to_version_inner(
|
||||
}
|
||||
|
||||
let project_id = ProjectId(version.project_id.0 as u64);
|
||||
let version_number = version.version_number;
|
||||
|
||||
let project_type = sqlx::query!(
|
||||
"
|
||||
@@ -567,7 +566,7 @@ async fn upload_file_to_version_inner(
|
||||
let mut dependencies = version
|
||||
.dependencies
|
||||
.iter()
|
||||
.map(|x| models::version_item::DependencyBuilder {
|
||||
.map(|x| DependencyBuilder {
|
||||
project_id: x.project_id,
|
||||
version_id: x.version_id,
|
||||
file_name: None,
|
||||
@@ -584,7 +583,7 @@ async fn upload_file_to_version_inner(
|
||||
&cdn_url,
|
||||
&content_disposition,
|
||||
project_id,
|
||||
&version_number,
|
||||
version_id.into(),
|
||||
&*project_type,
|
||||
version.loaders.clone().into_iter().map(Loader).collect(),
|
||||
version
|
||||
@@ -626,7 +625,7 @@ pub async fn upload_file(
|
||||
cdn_url: &str,
|
||||
content_disposition: &actix_web::http::header::ContentDisposition,
|
||||
project_id: ProjectId,
|
||||
version_number: &str,
|
||||
version_id: VersionId,
|
||||
project_type: &str,
|
||||
loaders: Vec<Loader>,
|
||||
game_versions: Vec<GameVersion>,
|
||||
@@ -748,13 +747,11 @@ pub async fn upload_file(
|
||||
let file_path_encode = format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id,
|
||||
version_number,
|
||||
version_id,
|
||||
urlencoding::encode(file_name)
|
||||
);
|
||||
let file_path = format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id, version_number, &file_name
|
||||
);
|
||||
let file_path =
|
||||
format!("data/{}/versions/{}/{}", project_id, version_id, &file_name);
|
||||
|
||||
let upload_data = file_host
|
||||
.upload_file(content_type, &file_path, data.freeze())
|
||||
|
||||
Reference in New Issue
Block a user