Urgent fixes
This commit is contained in:
parent
dd0aed4614
commit
e7b41f9a4c
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1393,7 +1393,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "labrinth"
|
name = "labrinth"
|
||||||
version = "2.3.0"
|
version = "2.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix",
|
"actix",
|
||||||
"actix-cors",
|
"actix-cors",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "labrinth"
|
name = "labrinth"
|
||||||
version = "2.3.0"
|
version = "2.3.1"
|
||||||
#Team members, please add your emails and usernames
|
#Team members, please add your emails and usernames
|
||||||
authors = ["geometrically <jai.a@tuta.io>", "Redblueflame <contact@redblueflame.com>", "Aeledfyr <aeledfyr@gmail.com>", "Charalampos Fanoulis <yo@fanoulis.dev>", "AppleTheGolden <scotsbox@protonmail.com>"]
|
authors = ["geometrically <jai.a@tuta.io>", "Redblueflame <contact@redblueflame.com>", "Aeledfyr <aeledfyr@gmail.com>", "Charalampos Fanoulis <yo@fanoulis.dev>", "AppleTheGolden <scotsbox@protonmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|||||||
@ -877,27 +877,6 @@
|
|||||||
"nullable": []
|
"nullable": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"331041c6a4f27f4a6ac2873332074c0127e7368c8ab803843760530d29aaef08": {
|
|
||||||
"query": "SELECT id FROM versions\n WHERE (version_number = $1 AND mod_id = $2)",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"ordinal": 0,
|
|
||||||
"name": "id",
|
|
||||||
"type_info": "Int8"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text",
|
|
||||||
"Int8"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"33a965c7dc615d3b701c05299889357db8dd36d378850625d2602ba471af4885": {
|
"33a965c7dc615d3b701c05299889357db8dd36d378850625d2602ba471af4885": {
|
||||||
"query": "\n UPDATE mods\n SET downloads = downloads + $1\n WHERE (id = $2)\n ",
|
"query": "\n UPDATE mods\n SET downloads = downloads + $1\n WHERE (id = $2)\n ",
|
||||||
"describe": {
|
"describe": {
|
||||||
@ -4471,6 +4450,33 @@
|
|||||||
"nullable": []
|
"nullable": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"c265db2e2cc1ba34ca1f30a9401018eb7760c8f0bafb1e3a7576e62bc9d3f83a": {
|
||||||
|
"query": "SELECT id, mod_id FROM versions\n WHERE (version_number = $1 AND mod_id = $2)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "id",
|
||||||
|
"type_info": "Int8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "mod_id",
|
||||||
|
"type_info": "Int8"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Text",
|
||||||
|
"Int8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"c3dcb5a8b798ea6c0922698a007dbc8ab549f5f85bad780da59163f4d6371238": {
|
"c3dcb5a8b798ea6c0922698a007dbc8ab549f5f85bad780da59163f4d6371238": {
|
||||||
"query": "\n SELECT id FROM mods\n WHERE status = (\n SELECT id FROM statuses WHERE status = $1\n )\n ORDER BY updated ASC\n LIMIT $2;\n ",
|
"query": "\n SELECT id FROM mods\n WHERE status = (\n SELECT id FROM statuses WHERE status = $1\n )\n ORDER BY updated ASC\n LIMIT $2;\n ",
|
||||||
"describe": {
|
"describe": {
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
|
use crate::models::ids::ProjectId;
|
||||||
use crate::routes::ApiError;
|
use crate::routes::ApiError;
|
||||||
use crate::util::guards::admin_key_guard;
|
use crate::util::guards::admin_key_guard;
|
||||||
use actix_web::{patch, web, HttpResponse};
|
use actix_web::{patch, web, HttpResponse};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use crate::models::ids::ProjectId;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct DownloadBody {
|
pub struct DownloadBody {
|
||||||
@ -18,17 +18,19 @@ pub async fn count_download(
|
|||||||
pool: web::Data<PgPool>,
|
pool: web::Data<PgPool>,
|
||||||
download_body: web::Json<DownloadBody>,
|
download_body: web::Json<DownloadBody>,
|
||||||
) -> Result<HttpResponse, ApiError> {
|
) -> Result<HttpResponse, ApiError> {
|
||||||
let project_id : crate::database::models::ids::ProjectId = download_body.hash.into();
|
let project_id: crate::database::models::ids::ProjectId =
|
||||||
|
download_body.hash.into();
|
||||||
|
|
||||||
let version_id = if let Some(version) = sqlx::query!(
|
let (version_id, project_id) = if let Some(version) = sqlx::query!(
|
||||||
"SELECT id FROM versions
|
"SELECT id, mod_id FROM versions
|
||||||
WHERE (version_number = $1 AND mod_id = $2)",
|
WHERE (version_number = $1 AND mod_id = $2)",
|
||||||
download_body.version_name,
|
download_body.version_name,
|
||||||
project_id as crate::database::models::ids::ProjectId
|
project_id as crate::database::models::ids::ProjectId
|
||||||
)
|
)
|
||||||
.fetch_optional(pool.as_ref())
|
.fetch_optional(pool.as_ref())
|
||||||
.await? {
|
.await?
|
||||||
version.id
|
{
|
||||||
|
(version.id, version.mod_id)
|
||||||
} else if let Some(version) = sqlx::query!(
|
} else if let Some(version) = sqlx::query!(
|
||||||
"
|
"
|
||||||
SELECT v.id id, v.mod_id project_id FROM files f
|
SELECT v.id id, v.mod_id project_id FROM files f
|
||||||
@ -38,10 +40,13 @@ pub async fn count_download(
|
|||||||
download_body.url,
|
download_body.url,
|
||||||
)
|
)
|
||||||
.fetch_optional(pool.as_ref())
|
.fetch_optional(pool.as_ref())
|
||||||
.await? {
|
.await?
|
||||||
version.id
|
{
|
||||||
|
(version.id, version.project_id)
|
||||||
} else {
|
} else {
|
||||||
return Err(ApiError::InvalidInput("Specified version does not exist!".to_string()));
|
return Err(ApiError::InvalidInput(
|
||||||
|
"Specified version does not exist!".to_string(),
|
||||||
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut transaction = pool.begin().await?;
|
let mut transaction = pool.begin().await?;
|
||||||
@ -59,7 +64,7 @@ pub async fn count_download(
|
|||||||
"UPDATE mods
|
"UPDATE mods
|
||||||
SET downloads = downloads + 1
|
SET downloads = downloads + 1
|
||||||
WHERE (id = $1)",
|
WHERE (id = $1)",
|
||||||
version_id
|
project_id
|
||||||
)
|
)
|
||||||
.execute(&mut *transaction)
|
.execute(&mut *transaction)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@ -145,12 +145,13 @@ pub async fn auth_callback(
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if let Some(result) = result_option {
|
if let Some(result) = result_option {
|
||||||
let now = OffsetDateTime::now_utc();
|
// let now = OffsetDateTime::now_utc();
|
||||||
let duration = now - result.expires;
|
// TODO: redo this condition later..
|
||||||
|
// let duration = now - result.expires;
|
||||||
if duration.whole_seconds() < 0 {
|
//
|
||||||
return Err(AuthorizationError::InvalidCredentials);
|
// if duration.whole_seconds() < 0 {
|
||||||
}
|
// return Err(AuthorizationError::InvalidCredentials);
|
||||||
|
// }
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"
|
"
|
||||||
|
|||||||
@ -445,14 +445,14 @@ pub async fn project_edit(
|
|||||||
} else if !project_item.status.is_searchable()
|
} else if !project_item.status.is_searchable()
|
||||||
&& status.is_searchable()
|
&& status.is_searchable()
|
||||||
{
|
{
|
||||||
let index_project =
|
// let index_project =
|
||||||
crate::search::indexing::local_import::query_one(
|
// crate::search::indexing::local_import::query_one(
|
||||||
id,
|
// id,
|
||||||
&mut *transaction,
|
// &mut *transaction,
|
||||||
)
|
// )
|
||||||
.await?;
|
// .await?;
|
||||||
|
//
|
||||||
indexing_queue.add(index_project);
|
// indexing_queue.add(index_project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user