You've already forked AstralRinth
forked from didirus/AstralRinth
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:
@@ -1,14 +1,14 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::common::{api_v2::ApiV2, api_v3::ApiV3, dummy_data::TestFile};
|
||||
use actix_web::dev::ServiceResponse;
|
||||
use async_trait::async_trait;
|
||||
use labrinth::models::ids::ProjectId;
|
||||
use labrinth::models::{
|
||||
projects::{ProjectId, VersionType},
|
||||
projects::VersionType,
|
||||
teams::{OrganizationPermissions, ProjectPermissions},
|
||||
};
|
||||
|
||||
use crate::common::{api_v2::ApiV2, api_v3::ApiV3, dummy_data::TestFile};
|
||||
|
||||
use super::{
|
||||
Api, ApiProject, ApiTags, ApiTeams, ApiUser, ApiVersion,
|
||||
models::{CommonProject, CommonVersion},
|
||||
|
||||
@@ -5,18 +5,18 @@ use self::models::{
|
||||
CommonProject, CommonTeamMember, CommonVersion,
|
||||
};
|
||||
use self::request_data::{ImageData, ProjectCreationRequestData};
|
||||
use super::dummy_data::TestFile;
|
||||
use actix_web::dev::ServiceResponse;
|
||||
use async_trait::async_trait;
|
||||
use labrinth::models::ids::ProjectId;
|
||||
use labrinth::{
|
||||
LabrinthConfig,
|
||||
models::{
|
||||
projects::{ProjectId, VersionType},
|
||||
projects::VersionType,
|
||||
teams::{OrganizationPermissions, ProjectPermissions},
|
||||
},
|
||||
};
|
||||
|
||||
use super::dummy_data::TestFile;
|
||||
|
||||
pub mod generic;
|
||||
pub mod models;
|
||||
pub mod request_data;
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
use ariadne::ids::UserId;
|
||||
use chrono::{DateTime, Utc};
|
||||
use labrinth::models::ids::{
|
||||
ImageId, NotificationId, OrganizationId, ProjectId, ReportId, TeamId,
|
||||
ThreadId, ThreadMessageId, VersionId,
|
||||
};
|
||||
use labrinth::{
|
||||
auth::AuthProvider,
|
||||
models::{
|
||||
images::ImageId,
|
||||
notifications::NotificationId,
|
||||
organizations::OrganizationId,
|
||||
projects::{
|
||||
Dependency, GalleryItem, License, ModeratorMessage,
|
||||
MonetizationStatus, ProjectId, ProjectStatus, VersionFile,
|
||||
VersionId, VersionStatus, VersionType,
|
||||
MonetizationStatus, ProjectStatus, VersionFile, VersionStatus,
|
||||
VersionType,
|
||||
},
|
||||
reports::ReportId,
|
||||
teams::{ProjectPermissions, TeamId},
|
||||
threads::{ThreadId, ThreadMessageId},
|
||||
users::{Badges, Role, User, UserId, UserPayoutData},
|
||||
teams::ProjectPermissions,
|
||||
users::{Badges, Role, User, UserPayoutData},
|
||||
},
|
||||
};
|
||||
use rust_decimal::Decimal;
|
||||
use serde::Deserialize;
|
||||
|
||||
// Fields shared by every version of the API.
|
||||
// No struct in here should have ANY field that
|
||||
// is not present in *every* version of the API.
|
||||
|
||||
@@ -7,10 +7,8 @@ use crate::common::{
|
||||
},
|
||||
dummy_data::TestFile,
|
||||
};
|
||||
use labrinth::{
|
||||
models::projects::ProjectId,
|
||||
util::actix::{MultipartSegment, MultipartSegmentData},
|
||||
};
|
||||
use labrinth::models::ids::ProjectId;
|
||||
use labrinth::util::actix::{MultipartSegment, MultipartSegmentData};
|
||||
|
||||
pub fn get_public_project_creation_data(
|
||||
slug: &str,
|
||||
|
||||
@@ -19,11 +19,9 @@ use actix_web::{
|
||||
test::{self, TestRequest},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use labrinth::models::ids::ProjectId;
|
||||
use labrinth::{
|
||||
models::{
|
||||
projects::{ProjectId, VersionType},
|
||||
v2::projects::LegacyVersion,
|
||||
},
|
||||
models::{projects::VersionType, v2::projects::LegacyVersion},
|
||||
routes::v2::version_file::FileUpdateData,
|
||||
util::actix::AppendsMultipart,
|
||||
};
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
use crate::{
|
||||
assert_status,
|
||||
common::api_common::{Api, AppendsOptionalPat, request_data::ImageData},
|
||||
};
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::{
|
||||
dev::ServiceResponse,
|
||||
test::{self, TestRequest},
|
||||
};
|
||||
use ariadne::ids::UserId;
|
||||
use bytes::Bytes;
|
||||
use labrinth::models::{
|
||||
organizations::Organization, users::UserId, v3::projects::Project,
|
||||
};
|
||||
use labrinth::models::{organizations::Organization, v3::projects::Project};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{
|
||||
assert_status,
|
||||
common::api_common::{Api, AppendsOptionalPat, request_data::ImageData},
|
||||
};
|
||||
|
||||
use super::ApiV3;
|
||||
|
||||
impl ApiV3 {
|
||||
|
||||
@@ -7,10 +7,8 @@ use crate::common::{
|
||||
},
|
||||
dummy_data::TestFile,
|
||||
};
|
||||
use labrinth::{
|
||||
models::projects::ProjectId,
|
||||
util::actix::{MultipartSegment, MultipartSegmentData},
|
||||
};
|
||||
use labrinth::models::ids::ProjectId;
|
||||
use labrinth::util::actix::{MultipartSegment, MultipartSegmentData};
|
||||
|
||||
pub fn get_public_project_creation_data(
|
||||
slug: &str,
|
||||
|
||||
@@ -19,11 +19,9 @@ use actix_web::{
|
||||
test::{self, TestRequest},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use labrinth::models::ids::ProjectId;
|
||||
use labrinth::{
|
||||
models::{
|
||||
projects::{ProjectId, VersionType},
|
||||
v3::projects::Version,
|
||||
},
|
||||
models::{projects::VersionType, v3::projects::Version},
|
||||
routes::v3::version_file::FileUpdateData,
|
||||
util::actix::AppendsMultipart,
|
||||
};
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#![allow(dead_code)]
|
||||
use std::io::{Cursor, Write};
|
||||
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::test::{self, TestRequest};
|
||||
use labrinth::models::{
|
||||
oauth_clients::OAuthClient,
|
||||
organizations::Organization,
|
||||
pats::Scopes,
|
||||
projects::{Project, ProjectId, Version},
|
||||
};
|
||||
use serde_json::json;
|
||||
use sqlx::Executor;
|
||||
use zip::{CompressionMethod, ZipWriter, write::FileOptions};
|
||||
|
||||
use crate::{
|
||||
assert_status,
|
||||
common::{api_common::Api, api_v3, database::USER_USER_PAT},
|
||||
};
|
||||
use actix_http::StatusCode;
|
||||
use actix_web::test::{self, TestRequest};
|
||||
use labrinth::models::ids::ProjectId;
|
||||
use labrinth::models::{
|
||||
oauth_clients::OAuthClient,
|
||||
organizations::Organization,
|
||||
pats::Scopes,
|
||||
projects::{Project, Version},
|
||||
};
|
||||
use serde_json::json;
|
||||
use sqlx::Executor;
|
||||
use zip::{CompressionMethod, ZipWriter, write::FileOptions};
|
||||
|
||||
use super::{
|
||||
api_common::{ApiProject, AppendsOptionalPat, request_data::ImageData},
|
||||
|
||||
@@ -23,7 +23,7 @@ pub async fn create_test_pat(
|
||||
name: format!("test_pat_{}", scopes.bits()),
|
||||
access_token: format!("mrp_{}", id.0),
|
||||
scopes,
|
||||
user_id: database::models::ids::UserId(user_id),
|
||||
user_id: database::models::ids::DBUserId(user_id),
|
||||
created: Utc::now(),
|
||||
expires: Utc::now() + chrono::Duration::days(1),
|
||||
last_used: None,
|
||||
|
||||
Reference in New Issue
Block a user