Labrinth ID cleanup (#3681)

* Put all ID types in the labrinth::models::ids, and reduce code duplication with them

* Rewrite labrinth::database::models::ids and rename most DB interface ID structs to be prefixed with DB

* Run sqlx prepare

---------

Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
This commit is contained in:
Josiah Glosson
2025-05-22 03:34:36 -05:00
committed by GitHub
parent c6022ad977
commit 9e527ff141
111 changed files with 1477 additions and 1965 deletions

View File

@@ -9,9 +9,8 @@ use crate::database::models::{
};
use crate::database::redis::RedisPool;
use crate::file_hosting::FileHost;
use crate::models::ids::{ThreadMessageId, VersionId};
use crate::models::ids::{ReportId, ThreadMessageId, VersionId};
use crate::models::images::{Image, ImageContext};
use crate::models::reports::ReportId;
use crate::queue::session::AuthQueue;
use crate::routes::ApiError;
use crate::util::img::upload_image_optimized;
@@ -205,13 +204,13 @@ pub async fn images_add(
raw_url: upload_result.raw_url,
size: content_length as u64,
created: chrono::Utc::now(),
owner_id: database::models::UserId::from(user.id),
owner_id: database::models::DBUserId::from(user.id),
context: context.context_as_str().to_string(),
project_id: if let ImageContext::Project {
project_id: Some(id),
} = context
{
Some(crate::database::models::ProjectId::from(id))
Some(crate::database::models::DBProjectId::from(id))
} else {
None
},
@@ -219,7 +218,7 @@ pub async fn images_add(
version_id: Some(id),
} = context
{
Some(database::models::VersionId::from(id))
Some(database::models::DBVersionId::from(id))
} else {
None
},
@@ -227,7 +226,7 @@ pub async fn images_add(
thread_message_id: Some(id),
} = context
{
Some(database::models::ThreadMessageId::from(id))
Some(database::models::DBThreadMessageId::from(id))
} else {
None
},
@@ -235,7 +234,7 @@ pub async fn images_add(
report_id: Some(id),
} = context
{
Some(database::models::ReportId::from(id))
Some(database::models::DBReportId::from(id))
} else {
None
},