You've already forked AstralRinth
forked from didirus/AstralRinth
Fix deps, download URLs, remove duplicate deps (#310)
This commit is contained in:
65
Cargo.lock
generated
65
Cargo.lock
generated
@@ -26,23 +26,6 @@ dependencies = [
|
|||||||
"tokio-util 0.6.9",
|
"tokio-util 0.6.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "actix-codec"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a36c014a3e811624313b51a227b775ecba55d36ef9462bbaac7d4f13e54c9271"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"bytes",
|
|
||||||
"futures-core",
|
|
||||||
"futures-sink",
|
|
||||||
"log",
|
|
||||||
"memchr",
|
|
||||||
"pin-project-lite",
|
|
||||||
"tokio",
|
|
||||||
"tokio-util 0.6.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-codec"
|
name = "actix-codec"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@@ -62,9 +45,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-cors"
|
name = "actix-cors"
|
||||||
version = "0.6.0-beta.10"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8debd30414af03e9411186aac95e0230b0bb1e91146f48015dfab5c049940223"
|
checksum = "30dbd116ef7532f56e2f6d7c511736ea0b124d914ee8820a5271247bf89f06aa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-service",
|
"actix-service",
|
||||||
"actix-utils",
|
"actix-utils",
|
||||||
@@ -78,11 +61,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-http"
|
name = "actix-http"
|
||||||
version = "3.0.0-rc.3"
|
version = "3.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a8b5ba038f3bb4aa29ad9bdd7eba09955ff04503263c497fc61a389d6412f4e8"
|
checksum = "0f3fdd63b9cfeaf92eeeece719dabbddddb420a57d3fd171ce1490ecfb7086b1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-codec 0.5.0",
|
"actix-codec",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
"actix-service",
|
"actix-service",
|
||||||
"actix-utils",
|
"actix-utils",
|
||||||
@@ -125,9 +108,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-multipart"
|
name = "actix-multipart"
|
||||||
version = "0.4.0-beta.13"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c59b1f14a8b2bc14df9be544d173f5390da5b62d531e406fd0f0ce9b825fea5a"
|
checksum = "c9edfb0e7663d7fe18c8d5b668c9c1bcf79176b1dcc9d4da9592503209a6bfb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-utils",
|
"actix-utils",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
@@ -143,9 +126,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-router"
|
name = "actix-router"
|
||||||
version = "0.5.0-rc.3"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb6506dbef336634ff35d994d58daa0a412ea23751f15f9b4dcac4d594b1ed1f"
|
checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytestring",
|
"bytestring",
|
||||||
"firestorm",
|
"firestorm",
|
||||||
@@ -207,11 +190,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-web"
|
name = "actix-web"
|
||||||
version = "4.0.0-rc.3"
|
version = "4.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83e3c85bc4116b69913b03f16cff8cade1212508fcd321847d9cfe3d3e41f991"
|
checksum = "f4e5ebffd51d50df56a3ae0de0e59487340ca456f05dd0b90c0a7a6dd6a74d31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-codec 0.4.2",
|
"actix-codec",
|
||||||
"actix-http",
|
"actix-http",
|
||||||
"actix-macros",
|
"actix-macros",
|
||||||
"actix-router",
|
"actix-router",
|
||||||
@@ -222,6 +205,7 @@ dependencies = [
|
|||||||
"actix-web-codegen",
|
"actix-web-codegen",
|
||||||
"ahash 0.7.6",
|
"ahash 0.7.6",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"bytestring",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cookie",
|
"cookie",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
@@ -246,9 +230,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-web-codegen"
|
name = "actix-web-codegen"
|
||||||
version = "0.5.0-rc.2"
|
version = "4.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4d0976042e6ddc82c7d0dedd64d39959bc26d9bba098b2f6c32a73fbef784eaf"
|
checksum = "7525bedf54704abb1d469e88d7e7e9226df73778798a69cea5022d53b2ae91bc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-router",
|
"actix-router",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -285,7 +269,7 @@ version = "0.7.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.4",
|
"getrandom 0.2.5",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
@@ -316,9 +300,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.54"
|
version = "1.0.55"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a99269dff3bc004caa411f38845c20303f1e393ca2bd6581576fa3a7f59577d"
|
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-channel"
|
name = "async-channel"
|
||||||
@@ -1056,9 +1040,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
|
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -1371,6 +1355,7 @@ dependencies = [
|
|||||||
"futures-timer",
|
"futures-timer",
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
"hex",
|
"hex",
|
||||||
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"meilisearch-sdk",
|
"meilisearch-sdk",
|
||||||
@@ -1943,7 +1928,7 @@ version = "0.6.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.4",
|
"getrandom 0.2.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1970,7 +1955,7 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.4",
|
"getrandom 0.2.5",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2178,9 +2163,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.5"
|
version = "1.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0486718e92ec9a68fbed73bb5ef687d71103b142595b406835649bebd33f72c7"
|
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix = "0.12.0"
|
actix = "0.12.0"
|
||||||
actix-web = "4.0.0-rc.2"
|
actix-web = "4.0.0"
|
||||||
actix-rt = "2.6.0"
|
actix-rt = "2.6.0"
|
||||||
tokio-stream = "0.1.8"
|
tokio-stream = "0.1.8"
|
||||||
actix-multipart = "0.4.0-beta.13"
|
actix-multipart = "0.4.0"
|
||||||
actix-cors = "0.6.0-beta.8"
|
actix-cors = "0.6.0"
|
||||||
|
|
||||||
meilisearch-sdk = "0.6.0"
|
meilisearch-sdk = "0.6.0"
|
||||||
reqwest = { version = "0.11.9", features = ["json"] }
|
reqwest = { version = "0.11.9", features = ["json"] }
|
||||||
@@ -36,6 +36,7 @@ sha1 = { version = "0.6.0", features = ["std"] }
|
|||||||
sha2 = "0.9.2"
|
sha2 = "0.9.2"
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
zip = "0.5.12"
|
zip = "0.5.12"
|
||||||
|
itertools = "0.10.3"
|
||||||
|
|
||||||
validator = { version = "0.13", features = ["derive"] }
|
validator = { version = "0.13", features = ["derive"] }
|
||||||
regex = "1.5.4"
|
regex = "1.5.4"
|
||||||
|
|||||||
@@ -639,27 +639,6 @@
|
|||||||
"nullable": []
|
"nullable": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"22f3f089050594199c3a3265da8ca68264a7457ae6ec4aef3644035a2022a830": {
|
|
||||||
"query": "\n SELECT version.id id FROM (\n SELECT DISTINCT ON(v.id) v.id, v.date_published FROM versions v\n INNER JOIN game_versions_versions gvv ON gvv.joining_version_id = v.id AND gvv.game_version_id IN (SELECT game_version_id FROM game_versions_versions WHERE joining_version_id = $2)\n INNER JOIN loaders_versions lv ON lv.version_id = v.id AND lv.loader_id IN (SELECT loader_id FROM loaders_versions WHERE version_id = $2)\n WHERE v.mod_id = $1\n ) AS version\n ORDER BY version.date_published DESC\n LIMIT 1\n ",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"ordinal": 0,
|
|
||||||
"name": "id",
|
|
||||||
"type_info": "Int8"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Int8",
|
|
||||||
"Int8"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"232d7d0319c20dd5fff29331b067d6c6373bcff761a77958a2bb5f59068a83a5": {
|
"232d7d0319c20dd5fff29331b067d6c6373bcff761a77958a2bb5f59068a83a5": {
|
||||||
"query": "\n UPDATE team_members\n SET permissions = $1\n WHERE (team_id = $2 AND user_id = $3)\n ",
|
"query": "\n UPDATE team_members\n SET permissions = $1\n WHERE (team_id = $2 AND user_id = $3)\n ",
|
||||||
"describe": {
|
"describe": {
|
||||||
@@ -1941,6 +1920,27 @@
|
|||||||
"nullable": []
|
"nullable": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"62416ea5972daa46ff2d077f631a8a30d9ec922056cf7ff1b0d74d9511010c96": {
|
||||||
|
"query": "\n SELECT version.id id FROM (\n SELECT DISTINCT ON(v.id) v.id, v.date_published FROM versions v\n INNER JOIN game_versions_versions gvv ON gvv.joining_version_id = v.id AND gvv.game_version_id IN (SELECT game_version_id FROM game_versions_versions WHERE joining_version_id = $2)\n INNER JOIN loaders_versions lv ON lv.version_id = v.id AND lv.loader_id IN (SELECT loader_id FROM loaders_versions WHERE version_id = $2)\n WHERE v.mod_id = $1\n ) AS version\n ORDER BY version.date_published DESC\n LIMIT 1\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "id",
|
||||||
|
"type_info": "Int8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Int8",
|
||||||
|
"Int8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"6326543f7cbd0ce03bbfe234ee82ca1b61d411589dc2d61753598679942cfdd8": {
|
"6326543f7cbd0ce03bbfe234ee82ca1b61d411589dc2d61753598679942cfdd8": {
|
||||||
"query": "\n SELECT md.url url, dp.id platform_id, dp.name dp_name, dp.short short\n FROM mods_donations md\n INNER JOIN donation_platforms dp ON md.joining_platform_id = dp.id\n WHERE md.joining_mod_id = $1\n ",
|
"query": "\n SELECT md.url url, dp.id platform_id, dp.name dp_name, dp.short short\n FROM mods_donations md\n INNER JOIN donation_platforms dp ON md.joining_platform_id = dp.id\n WHERE md.joining_mod_id = $1\n ",
|
||||||
"describe": {
|
"describe": {
|
||||||
|
|||||||
@@ -29,25 +29,30 @@ impl DependencyBuilder {
|
|||||||
version_id: VersionId,
|
version_id: VersionId,
|
||||||
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||||
) -> Result<(), DatabaseError> {
|
) -> Result<(), DatabaseError> {
|
||||||
let version_dependency_id = if let Some(project_id) = self.project_id {
|
let (version_dependency_id, project_dependency_id): (Option<VersionId>, Option<ProjectId>) =
|
||||||
sqlx::query!(
|
if self.version_id.is_some() {
|
||||||
"
|
(self.version_id, None)
|
||||||
SELECT version.id id FROM (
|
} else if let Some(project_id) = self.project_id {
|
||||||
SELECT DISTINCT ON(v.id) v.id, v.date_published FROM versions v
|
let version_id = sqlx::query!(
|
||||||
INNER JOIN game_versions_versions gvv ON gvv.joining_version_id = v.id AND gvv.game_version_id IN (SELECT game_version_id FROM game_versions_versions WHERE joining_version_id = $2)
|
"
|
||||||
INNER JOIN loaders_versions lv ON lv.version_id = v.id AND lv.loader_id IN (SELECT loader_id FROM loaders_versions WHERE version_id = $2)
|
SELECT version.id id FROM (
|
||||||
WHERE v.mod_id = $1
|
SELECT DISTINCT ON(v.id) v.id, v.date_published FROM versions v
|
||||||
) AS version
|
INNER JOIN game_versions_versions gvv ON gvv.joining_version_id = v.id AND gvv.game_version_id IN (SELECT game_version_id FROM game_versions_versions WHERE joining_version_id = $2)
|
||||||
ORDER BY version.date_published DESC
|
INNER JOIN loaders_versions lv ON lv.version_id = v.id AND lv.loader_id IN (SELECT loader_id FROM loaders_versions WHERE version_id = $2)
|
||||||
LIMIT 1
|
WHERE v.mod_id = $1
|
||||||
",
|
) AS version
|
||||||
project_id as ProjectId,
|
ORDER BY version.date_published DESC
|
||||||
version_id as VersionId,
|
LIMIT 1
|
||||||
)
|
",
|
||||||
.fetch_optional(&mut *transaction).await?.map(|x| VersionId(x.id))
|
project_id as ProjectId,
|
||||||
} else {
|
version_id as VersionId,
|
||||||
self.version_id
|
)
|
||||||
};
|
.fetch_optional(&mut *transaction).await?.map(|x| VersionId(x.id));
|
||||||
|
|
||||||
|
(version_id, Some(project_id))
|
||||||
|
} else {
|
||||||
|
(None, None)
|
||||||
|
};
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"
|
"
|
||||||
@@ -57,7 +62,7 @@ impl DependencyBuilder {
|
|||||||
version_id as VersionId,
|
version_id as VersionId,
|
||||||
self.dependency_type,
|
self.dependency_type,
|
||||||
version_dependency_id.map(|x| x.0),
|
version_dependency_id.map(|x| x.0),
|
||||||
self.project_id.map(|x| x.0),
|
project_dependency_id.map(|x| x.0),
|
||||||
)
|
)
|
||||||
.execute(&mut *transaction)
|
.execute(&mut *transaction)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -26,20 +26,20 @@ pub enum ARError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResponseError for ARError {
|
impl ResponseError for ARError {
|
||||||
fn error_response(&self) -> actix_web::web::HttpResponse {
|
fn error_response(&self) -> actix_web::HttpResponse {
|
||||||
match self {
|
match self {
|
||||||
Self::LimitedError {
|
Self::LimitedError {
|
||||||
max_requests,
|
max_requests,
|
||||||
remaining,
|
remaining,
|
||||||
reset,
|
reset,
|
||||||
} => {
|
} => {
|
||||||
let mut response = actix_web::web::HttpResponse::TooManyRequests();
|
let mut response = actix_web::HttpResponse::TooManyRequests();
|
||||||
response.insert_header(("x-ratelimit-limit", max_requests.to_string()));
|
response.insert_header(("x-ratelimit-limit", max_requests.to_string()));
|
||||||
response.insert_header(("x-ratelimit-remaining", remaining.to_string()));
|
response.insert_header(("x-ratelimit-remaining", remaining.to_string()));
|
||||||
response.insert_header(("x-ratelimit-reset", reset.to_string()));
|
response.insert_header(("x-ratelimit-reset", reset.to_string()));
|
||||||
response.body(self.to_string())
|
response.body(self.to_string())
|
||||||
}
|
}
|
||||||
_ => actix_web::web::HttpResponse::build(self.status_code()).body(self.to_string()),
|
_ => actix_web::HttpResponse::build(self.status_code()).body(self.to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,25 +202,23 @@ impl actix_web::ResponseError for ApiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error_response(&self) -> actix_web::web::HttpResponse {
|
fn error_response(&self) -> actix_web::HttpResponse {
|
||||||
actix_web::web::HttpResponse::build(self.status_code()).json(
|
actix_web::HttpResponse::build(self.status_code()).json(crate::models::error::ApiError {
|
||||||
crate::models::error::ApiError {
|
error: match self {
|
||||||
error: match self {
|
ApiError::EnvError(..) => "environment_error",
|
||||||
ApiError::EnvError(..) => "environment_error",
|
ApiError::SqlxDatabaseError(..) => "database_error",
|
||||||
ApiError::SqlxDatabaseError(..) => "database_error",
|
ApiError::DatabaseError(..) => "database_error",
|
||||||
ApiError::DatabaseError(..) => "database_error",
|
ApiError::AuthenticationError(..) => "unauthorized",
|
||||||
ApiError::AuthenticationError(..) => "unauthorized",
|
ApiError::CustomAuthenticationError(..) => "unauthorized",
|
||||||
ApiError::CustomAuthenticationError(..) => "unauthorized",
|
ApiError::XmlError(..) => "xml_error",
|
||||||
ApiError::XmlError(..) => "xml_error",
|
ApiError::JsonError(..) => "json_error",
|
||||||
ApiError::JsonError(..) => "json_error",
|
ApiError::SearchError(..) => "search_error",
|
||||||
ApiError::SearchError(..) => "search_error",
|
ApiError::IndexingError(..) => "indexing_error",
|
||||||
ApiError::IndexingError(..) => "indexing_error",
|
ApiError::FileHostingError(..) => "file_hosting_error",
|
||||||
ApiError::FileHostingError(..) => "file_hosting_error",
|
ApiError::InvalidInputError(..) => "invalid_input",
|
||||||
ApiError::InvalidInputError(..) => "invalid_input",
|
ApiError::ValidationError(..) => "invalid_input",
|
||||||
ApiError::ValidationError(..) => "invalid_input",
|
|
||||||
},
|
|
||||||
description: &self.to_string(),
|
|
||||||
},
|
},
|
||||||
)
|
description: &self.to_string(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub async fn mod_search(
|
|||||||
.hits
|
.hits
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| ResultSearchMod {
|
.map(|x| ResultSearchMod {
|
||||||
mod_id: format!("local-{}", x.project_id.clone()),
|
mod_id: format!("local-{}", x.project_id),
|
||||||
slug: x.slug,
|
slug: x.slug,
|
||||||
author: x.author.clone(),
|
author: x.author.clone(),
|
||||||
title: x.title,
|
title: x.title,
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ pub struct InitialVersionData {
|
|||||||
pub version_title: String,
|
pub version_title: String,
|
||||||
#[validate(length(max = 65536))]
|
#[validate(length(max = 65536))]
|
||||||
pub version_body: Option<String>,
|
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>,
|
pub dependencies: Vec<Dependency>,
|
||||||
#[validate(length(min = 1))]
|
#[validate(length(min = 1))]
|
||||||
pub game_versions: Vec<GameVersion>,
|
pub game_versions: Vec<GameVersion>,
|
||||||
@@ -630,22 +633,24 @@ pub async fn upload_file(
|
|||||||
)
|
)
|
||||||
.await?;
|
.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
|
let upload_data = file_host
|
||||||
.upload_file(
|
.upload_file(content_type, &file_name, data.freeze())
|
||||||
content_type,
|
|
||||||
&format!(
|
|
||||||
"data/{}/versions/{}/{}",
|
|
||||||
project_id,
|
|
||||||
version_number,
|
|
||||||
urlencoding::encode(&file_name)
|
|
||||||
),
|
|
||||||
data.freeze(),
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
uploaded_files.push(UploadedFile {
|
uploaded_files.push(UploadedFile {
|
||||||
file_id: upload_data.file_id,
|
file_id: upload_data.file_id,
|
||||||
file_name: upload_data.file_name.clone(),
|
file_name: file_name_encode,
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Malware scan + file validation
|
// TODO: Malware scan + file validation
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use super::ApiError;
|
use super::ApiError;
|
||||||
use crate::database::models::version_item::QueryVersion;
|
use crate::database::models::version_item::QueryVersion;
|
||||||
use crate::file_hosting::FileHost;
|
use crate::file_hosting::FileHost;
|
||||||
use crate::{models, database};
|
|
||||||
use crate::models::projects::{GameVersion, Loader, Version};
|
use crate::models::projects::{GameVersion, Loader, Version};
|
||||||
use crate::models::teams::Permissions;
|
use crate::models::teams::Permissions;
|
||||||
use crate::util::auth::get_user_from_headers;
|
use crate::util::auth::get_user_from_headers;
|
||||||
use crate::util::routes::ok_or_not_found;
|
use crate::util::routes::ok_or_not_found;
|
||||||
|
use crate::{database, models};
|
||||||
use actix_web::{delete, get, post, web, HttpRequest, HttpResponse};
|
use actix_web::{delete, get, post, web, HttpRequest, HttpResponse};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|||||||
@@ -171,6 +171,10 @@ pub struct EditVersion {
|
|||||||
#[validate(length(max = 65536))]
|
#[validate(length(max = 65536))]
|
||||||
pub changelog: Option<String>,
|
pub changelog: Option<String>,
|
||||||
pub version_type: Option<models::projects::VersionType>,
|
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 dependencies: Option<Vec<Dependency>>,
|
||||||
pub game_versions: Option<Vec<models::projects::GameVersion>>,
|
pub game_versions: Option<Vec<models::projects::GameVersion>>,
|
||||||
pub loaders: Option<Vec<models::projects::Loader>>,
|
pub loaders: Option<Vec<models::projects::Loader>>,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::models::error::ApiError;
|
use crate::models::error::ApiError;
|
||||||
use crate::models::projects::SearchRequest;
|
use crate::models::projects::SearchRequest;
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::web::HttpResponse;
|
use actix_web::HttpResponse;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use meilisearch_sdk::client::Client;
|
use meilisearch_sdk::client::Client;
|
||||||
use meilisearch_sdk::document::Document;
|
use meilisearch_sdk::document::Document;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use itertools::Itertools;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use validator::{ValidationErrors, ValidationErrorsKind};
|
use validator::{ValidationErrors, ValidationErrorsKind};
|
||||||
@@ -53,3 +54,26 @@ pub fn validation_errors_to_string(errors: ValidationErrors, adder: Option<Strin
|
|||||||
|
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn validate_deps(
|
||||||
|
values: &[crate::models::projects::Dependency],
|
||||||
|
) -> Result<(), validator::ValidationError> {
|
||||||
|
if values
|
||||||
|
.iter()
|
||||||
|
.duplicates_by(|x| {
|
||||||
|
format!(
|
||||||
|
"{}-{}",
|
||||||
|
x.version_id
|
||||||
|
.unwrap_or(crate::models::projects::VersionId(0)),
|
||||||
|
x.project_id
|
||||||
|
.unwrap_or(crate::models::projects::ProjectId(0))
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.next()
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
|
return Err(validator::ValidationError::new("duplicate dependency"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ pub enum SupportedGameVersions {
|
|||||||
All,
|
All,
|
||||||
PastDate(DateTime<Utc>),
|
PastDate(DateTime<Utc>),
|
||||||
Range(DateTime<Utc>, DateTime<Utc>),
|
Range(DateTime<Utc>, DateTime<Utc>),
|
||||||
#[allow(dead_code)] Custom(Vec<GameVersion>),
|
#[allow(dead_code)]
|
||||||
|
Custom(Vec<GameVersion>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Validator: Sync {
|
pub trait Validator: Sync {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub struct PackFile<'a> {
|
|||||||
pub downloads: Vec<&'a str>,
|
pub downloads: Vec<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_download_url(values: &Vec<&str>) -> Result<(), validator::ValidationError> {
|
fn validate_download_url(values: &[&str]) -> Result<(), validator::ValidationError> {
|
||||||
for value in values {
|
for value in values {
|
||||||
let url = url::Url::parse(value)
|
let url = url::Url::parse(value)
|
||||||
.ok()
|
.ok()
|
||||||
|
|||||||
Reference in New Issue
Block a user