You've already forked AstralRinth
forked from didirus/AstralRinth
Fix deps, download URLs, remove duplicate deps (#310)
This commit is contained in:
@@ -202,25 +202,23 @@ impl actix_web::ResponseError for ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
fn error_response(&self) -> actix_web::web::HttpResponse {
|
||||
actix_web::web::HttpResponse::build(self.status_code()).json(
|
||||
crate::models::error::ApiError {
|
||||
error: match self {
|
||||
ApiError::EnvError(..) => "environment_error",
|
||||
ApiError::SqlxDatabaseError(..) => "database_error",
|
||||
ApiError::DatabaseError(..) => "database_error",
|
||||
ApiError::AuthenticationError(..) => "unauthorized",
|
||||
ApiError::CustomAuthenticationError(..) => "unauthorized",
|
||||
ApiError::XmlError(..) => "xml_error",
|
||||
ApiError::JsonError(..) => "json_error",
|
||||
ApiError::SearchError(..) => "search_error",
|
||||
ApiError::IndexingError(..) => "indexing_error",
|
||||
ApiError::FileHostingError(..) => "file_hosting_error",
|
||||
ApiError::InvalidInputError(..) => "invalid_input",
|
||||
ApiError::ValidationError(..) => "invalid_input",
|
||||
},
|
||||
description: &self.to_string(),
|
||||
fn error_response(&self) -> actix_web::HttpResponse {
|
||||
actix_web::HttpResponse::build(self.status_code()).json(crate::models::error::ApiError {
|
||||
error: match self {
|
||||
ApiError::EnvError(..) => "environment_error",
|
||||
ApiError::SqlxDatabaseError(..) => "database_error",
|
||||
ApiError::DatabaseError(..) => "database_error",
|
||||
ApiError::AuthenticationError(..) => "unauthorized",
|
||||
ApiError::CustomAuthenticationError(..) => "unauthorized",
|
||||
ApiError::XmlError(..) => "xml_error",
|
||||
ApiError::JsonError(..) => "json_error",
|
||||
ApiError::SearchError(..) => "search_error",
|
||||
ApiError::IndexingError(..) => "indexing_error",
|
||||
ApiError::FileHostingError(..) => "file_hosting_error",
|
||||
ApiError::InvalidInputError(..) => "invalid_input",
|
||||
ApiError::ValidationError(..) => "invalid_input",
|
||||
},
|
||||
)
|
||||
description: &self.to_string(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ pub async fn mod_search(
|
||||
.hits
|
||||
.into_iter()
|
||||
.map(|x| ResultSearchMod {
|
||||
mod_id: format!("local-{}", x.project_id.clone()),
|
||||
mod_id: format!("local-{}", x.project_id),
|
||||
slug: x.slug,
|
||||
author: x.author.clone(),
|
||||
title: x.title,
|
||||
|
||||
@@ -34,7 +34,10 @@ pub struct InitialVersionData {
|
||||
pub version_title: String,
|
||||
#[validate(length(max = 65536))]
|
||||
pub version_body: Option<String>,
|
||||
#[validate(length(min = 0, max = 256))]
|
||||
#[validate(
|
||||
length(min = 0, max = 256),
|
||||
custom(function = "crate::util::validate::validate_deps")
|
||||
)]
|
||||
pub dependencies: Vec<Dependency>,
|
||||
#[validate(length(min = 1))]
|
||||
pub game_versions: Vec<GameVersion>,
|
||||
@@ -630,22 +633,24 @@ pub async fn upload_file(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let file_name_encode = format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id,
|
||||
version_number,
|
||||
urlencoding::encode(file_name)
|
||||
);
|
||||
let file_name = format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id, version_number, &file_name
|
||||
);
|
||||
|
||||
let upload_data = file_host
|
||||
.upload_file(
|
||||
content_type,
|
||||
&format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id,
|
||||
version_number,
|
||||
urlencoding::encode(&file_name)
|
||||
),
|
||||
data.freeze(),
|
||||
)
|
||||
.upload_file(content_type, &file_name, data.freeze())
|
||||
.await?;
|
||||
|
||||
uploaded_files.push(UploadedFile {
|
||||
file_id: upload_data.file_id,
|
||||
file_name: upload_data.file_name.clone(),
|
||||
file_name: file_name_encode,
|
||||
});
|
||||
|
||||
// TODO: Malware scan + file validation
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use super::ApiError;
|
||||
use crate::database::models::version_item::QueryVersion;
|
||||
use crate::file_hosting::FileHost;
|
||||
use crate::{models, database};
|
||||
use crate::models::projects::{GameVersion, Loader, Version};
|
||||
use crate::models::teams::Permissions;
|
||||
use crate::util::auth::get_user_from_headers;
|
||||
use crate::util::routes::ok_or_not_found;
|
||||
use crate::{database, models};
|
||||
use actix_web::{delete, get, post, web, HttpRequest, HttpResponse};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::PgPool;
|
||||
|
||||
@@ -171,6 +171,10 @@ pub struct EditVersion {
|
||||
#[validate(length(max = 65536))]
|
||||
pub changelog: Option<String>,
|
||||
pub version_type: Option<models::projects::VersionType>,
|
||||
#[validate(
|
||||
length(min = 0, max = 256),
|
||||
custom(function = "crate::util::validate::validate_deps")
|
||||
)]
|
||||
pub dependencies: Option<Vec<Dependency>>,
|
||||
pub game_versions: Option<Vec<models::projects::GameVersion>>,
|
||||
pub loaders: Option<Vec<models::projects::Loader>>,
|
||||
|
||||
Reference in New Issue
Block a user