You've already forked AstralRinth
forked from didirus/AstralRinth
Upgrade to sqlx 0.7.2 (#736)
* Update to sqlx 0.7.2 * Somehow missed one (and remove queries from other branch)
This commit is contained in:
@@ -232,7 +232,7 @@ pub async fn trolley_webhook(
|
||||
",
|
||||
user.id.0
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
} else {
|
||||
sqlx::query!(
|
||||
@@ -246,7 +246,7 @@ pub async fn trolley_webhook(
|
||||
recipient.status.map(|x| x.as_str()),
|
||||
user.id.0
|
||||
)
|
||||
.execute(&mut transaction).await?;
|
||||
.execute(&mut *transaction).await?;
|
||||
}
|
||||
|
||||
transaction.commit().await?;
|
||||
@@ -288,7 +288,7 @@ pub async fn trolley_webhook(
|
||||
payout.amount,
|
||||
payout.user_id,
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ pub async fn trolley_webhook(
|
||||
payment.status.as_str(),
|
||||
payment.id,
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
@@ -82,12 +82,15 @@ pub async fn collection_create(
|
||||
|
||||
let collection_id: CollectionId = generate_collection_id(&mut transaction).await?.into();
|
||||
|
||||
let initial_project_ids =
|
||||
project_item::Project::get_many(&collection_create_data.projects, &mut transaction, &redis)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|x| x.inner.id.into())
|
||||
.collect::<Vec<ProjectId>>();
|
||||
let initial_project_ids = project_item::Project::get_many(
|
||||
&collection_create_data.projects,
|
||||
&mut *transaction,
|
||||
&redis,
|
||||
)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|x| x.inner.id.into())
|
||||
.collect::<Vec<ProjectId>>();
|
||||
|
||||
let collection_builder_actual = collection_item::CollectionBuilder {
|
||||
collection_id: collection_id.into(),
|
||||
|
||||
@@ -379,8 +379,9 @@ async fn project_create_inner(
|
||||
let mut versions_map = std::collections::HashMap::new();
|
||||
let mut gallery_urls = Vec::new();
|
||||
|
||||
let all_game_versions = models::categories::GameVersion::list(&mut *transaction, redis).await?;
|
||||
let all_loaders = models::categories::Loader::list(&mut *transaction, redis).await?;
|
||||
let all_game_versions =
|
||||
models::categories::GameVersion::list(&mut **transaction, redis).await?;
|
||||
let all_loaders = models::categories::Loader::list(&mut **transaction, redis).await?;
|
||||
|
||||
{
|
||||
// The first multipart field must be named "data" and contain a
|
||||
@@ -427,7 +428,7 @@ async fn project_create_inner(
|
||||
",
|
||||
slug_project_id as models::ids::ProjectId
|
||||
)
|
||||
.fetch_one(&mut *transaction)
|
||||
.fetch_one(&mut **transaction)
|
||||
.await
|
||||
.map_err(|e| CreateError::DatabaseError(e.into()))?;
|
||||
|
||||
@@ -443,7 +444,7 @@ async fn project_create_inner(
|
||||
",
|
||||
create_data.slug
|
||||
)
|
||||
.fetch_one(&mut *transaction)
|
||||
.fetch_one(&mut **transaction)
|
||||
.await
|
||||
.map_err(|e| CreateError::DatabaseError(e.into()))?;
|
||||
|
||||
@@ -482,7 +483,7 @@ async fn project_create_inner(
|
||||
|
||||
let project_type_id = models::categories::ProjectType::get_id(
|
||||
project_create_data.project_type.as_str(),
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
@@ -647,7 +648,7 @@ async fn project_create_inner(
|
||||
let id = models::categories::Category::get_id_project(
|
||||
category,
|
||||
project_type_id,
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| CreateError::InvalidCategory(category.clone()))?;
|
||||
@@ -660,7 +661,7 @@ async fn project_create_inner(
|
||||
let id = models::categories::Category::get_id_project(
|
||||
category,
|
||||
project_type_id,
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| CreateError::InvalidCategory(category.clone()))?;
|
||||
@@ -680,7 +681,7 @@ async fn project_create_inner(
|
||||
}],
|
||||
};
|
||||
|
||||
let team_id = team.insert(&mut *transaction).await?;
|
||||
let team_id = team.insert(transaction).await?;
|
||||
|
||||
let status;
|
||||
if project_create_data.is_draft.unwrap_or(false) {
|
||||
@@ -703,7 +704,7 @@ async fn project_create_inner(
|
||||
|
||||
let client_side_id = models::categories::SideType::get_id(
|
||||
project_create_data.client_side.as_str(),
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
@@ -712,7 +713,7 @@ async fn project_create_inner(
|
||||
|
||||
let server_side_id = models::categories::SideType::get_id(
|
||||
project_create_data.server_side.as_str(),
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
@@ -729,7 +730,7 @@ async fn project_create_inner(
|
||||
if let Some(urls) = &project_create_data.donation_urls {
|
||||
for url in urls {
|
||||
let platform_id =
|
||||
models::categories::DonationPlatform::get_id(&url.id, &mut *transaction)
|
||||
models::categories::DonationPlatform::get_id(&url.id, &mut **transaction)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
CreateError::InvalidInput(format!(
|
||||
@@ -790,12 +791,12 @@ async fn project_create_inner(
|
||||
|
||||
let now = Utc::now();
|
||||
|
||||
let id = project_builder_actual.insert(&mut *transaction).await?;
|
||||
let id = project_builder_actual.insert(transaction).await?;
|
||||
User::clear_project_cache(&[current_user.id.into()], redis).await?;
|
||||
|
||||
for image_id in project_create_data.uploaded_images {
|
||||
if let Some(db_image) =
|
||||
image_item::Image::get(image_id.into(), &mut *transaction, redis).await?
|
||||
image_item::Image::get(image_id.into(), &mut **transaction, redis).await?
|
||||
{
|
||||
let image: Image = db_image.into();
|
||||
if !matches!(image.context, ImageContext::Project { .. })
|
||||
@@ -816,7 +817,7 @@ async fn project_create_inner(
|
||||
id as models::ids::ProjectId,
|
||||
image_id.0 as i64
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
image_item::Image::clear_cache(image.id.into(), redis).await?;
|
||||
@@ -834,7 +835,7 @@ async fn project_create_inner(
|
||||
project_id: Some(id),
|
||||
report_id: None,
|
||||
}
|
||||
.insert(&mut *transaction)
|
||||
.insert(transaction)
|
||||
.await?;
|
||||
|
||||
let response = crate::models::projects::Project {
|
||||
|
||||
@@ -1517,7 +1517,7 @@ pub async fn bulk_edit_project_categories(
|
||||
project_id as db_ids::ProjectId,
|
||||
is_additional
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
let mut mod_categories = Vec::new();
|
||||
@@ -1553,7 +1553,7 @@ pub async fn edit_project_categories(
|
||||
|
||||
let mut mod_categories = Vec::new();
|
||||
for category in categories {
|
||||
let category_id = db_models::categories::Category::get_id(category, &mut *transaction)
|
||||
let category_id = db_models::categories::Category::get_id(category, &mut **transaction)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
ApiError::InvalidInput(format!("Category {} does not exist.", category.clone()))
|
||||
|
||||
@@ -98,7 +98,7 @@ pub async fn report_create(
|
||||
"SELECT EXISTS(SELECT 1 FROM mods WHERE id = $1)",
|
||||
project_id.0 as i64
|
||||
)
|
||||
.fetch_one(&mut transaction)
|
||||
.fetch_one(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
if !result.exists.unwrap_or(false) {
|
||||
@@ -117,7 +117,7 @@ pub async fn report_create(
|
||||
"SELECT EXISTS(SELECT 1 FROM versions WHERE id = $1)",
|
||||
version_id.0 as i64
|
||||
)
|
||||
.fetch_one(&mut transaction)
|
||||
.fetch_one(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
if !result.exists.unwrap_or(false) {
|
||||
@@ -136,7 +136,7 @@ pub async fn report_create(
|
||||
"SELECT EXISTS(SELECT 1 FROM users WHERE id = $1)",
|
||||
user_id.0 as i64
|
||||
)
|
||||
.fetch_one(&mut transaction)
|
||||
.fetch_one(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
if !result.exists.unwrap_or(false) {
|
||||
|
||||
@@ -141,8 +141,9 @@ async fn version_create_inner(
|
||||
let mut initial_version_data = None;
|
||||
let mut version_builder = None;
|
||||
|
||||
let all_game_versions = models::categories::GameVersion::list(&mut *transaction, redis).await?;
|
||||
let all_loaders = models::categories::Loader::list(&mut *transaction, redis).await?;
|
||||
let all_game_versions =
|
||||
models::categories::GameVersion::list(&mut **transaction, redis).await?;
|
||||
let all_loaders = models::categories::Loader::list(&mut **transaction, redis).await?;
|
||||
|
||||
let user = get_user_from_headers(
|
||||
&req,
|
||||
@@ -200,7 +201,7 @@ async fn version_create_inner(
|
||||
"SELECT EXISTS(SELECT 1 FROM mods WHERE id=$1)",
|
||||
project_id as models::ProjectId
|
||||
)
|
||||
.fetch_one(&mut *transaction)
|
||||
.fetch_one(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
if !results.exists.unwrap_or(false) {
|
||||
@@ -214,14 +215,14 @@ async fn version_create_inner(
|
||||
let team_member = models::TeamMember::get_from_user_id_project(
|
||||
project_id,
|
||||
user.id.into(),
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Get organization attached, if exists, and the member project permissions
|
||||
let organization = models::Organization::get_associated_organization_project_id(
|
||||
project_id,
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -229,7 +230,7 @@ async fn version_create_inner(
|
||||
models::TeamMember::get_from_user_id(
|
||||
organization.team_id,
|
||||
user.id.into(),
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?
|
||||
} else {
|
||||
@@ -259,7 +260,7 @@ async fn version_create_inner(
|
||||
",
|
||||
project_id as models::ProjectId,
|
||||
)
|
||||
.fetch_one(&mut *transaction)
|
||||
.fetch_one(&mut **transaction)
|
||||
.await?
|
||||
.name;
|
||||
|
||||
@@ -332,7 +333,7 @@ async fn version_create_inner(
|
||||
",
|
||||
version.project_id as models::ProjectId,
|
||||
)
|
||||
.fetch_one(&mut *transaction)
|
||||
.fetch_one(&mut **transaction)
|
||||
.await?
|
||||
.name;
|
||||
|
||||
@@ -395,7 +396,7 @@ async fn version_create_inner(
|
||||
",
|
||||
builder.project_id as crate::database::models::ids::ProjectId
|
||||
)
|
||||
.fetch_many(&mut *transaction)
|
||||
.fetch_many(&mut **transaction)
|
||||
.try_filter_map(|e| async { Ok(e.right().map(|m| models::ids::UserId(m.follower_id))) })
|
||||
.try_collect::<Vec<models::ids::UserId>>()
|
||||
.await?;
|
||||
@@ -409,7 +410,7 @@ async fn version_create_inner(
|
||||
version_id,
|
||||
},
|
||||
}
|
||||
.insert_many(users, &mut *transaction, redis)
|
||||
.insert_many(users, transaction, redis)
|
||||
.await?;
|
||||
|
||||
let response = Version {
|
||||
@@ -461,7 +462,7 @@ async fn version_create_inner(
|
||||
|
||||
for image_id in version_data.uploaded_images {
|
||||
if let Some(db_image) =
|
||||
image_item::Image::get(image_id.into(), &mut *transaction, redis).await?
|
||||
image_item::Image::get(image_id.into(), &mut **transaction, redis).await?
|
||||
{
|
||||
let image: Image = db_image.into();
|
||||
if !matches!(image.context, ImageContext::Report { .. })
|
||||
@@ -482,7 +483,7 @@ async fn version_create_inner(
|
||||
version_id.0 as i64,
|
||||
image_id.0 as i64
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
image_item::Image::clear_cache(image.id.into(), redis).await?;
|
||||
@@ -494,8 +495,8 @@ async fn version_create_inner(
|
||||
}
|
||||
}
|
||||
|
||||
models::Project::update_game_versions(project_id, &mut *transaction).await?;
|
||||
models::Project::update_loaders(project_id, &mut *transaction).await?;
|
||||
models::Project::update_game_versions(project_id, transaction).await?;
|
||||
models::Project::update_loaders(project_id, transaction).await?;
|
||||
models::Project::clear_cache(project_id, None, Some(true), redis).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
@@ -588,7 +589,7 @@ async fn upload_file_to_version_inner(
|
||||
let team_member = models::TeamMember::get_from_user_id_project(
|
||||
version.inner.project_id,
|
||||
user.id.into(),
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -602,7 +603,7 @@ async fn upload_file_to_version_inner(
|
||||
models::TeamMember::get_from_user_id(
|
||||
organization.team_id,
|
||||
user.id.into(),
|
||||
&mut *transaction,
|
||||
&mut **transaction,
|
||||
)
|
||||
.await?
|
||||
} else {
|
||||
@@ -633,12 +634,12 @@ async fn upload_file_to_version_inner(
|
||||
",
|
||||
version.inner.project_id as models::ProjectId,
|
||||
)
|
||||
.fetch_one(&mut *transaction)
|
||||
.fetch_one(&mut **transaction)
|
||||
.await?
|
||||
.name;
|
||||
|
||||
let all_game_versions =
|
||||
models::categories::GameVersion::list(&mut *transaction, &redis).await?;
|
||||
models::categories::GameVersion::list(&mut **transaction, &redis).await?;
|
||||
|
||||
let mut error = None;
|
||||
while let Some(item) = payload.next().await {
|
||||
@@ -725,7 +726,7 @@ async fn upload_file_to_version_inner(
|
||||
"At least one file must be specified".to_string(),
|
||||
));
|
||||
} else {
|
||||
VersionFileBuilder::insert_many(file_builders, version_id, &mut *transaction).await?;
|
||||
VersionFileBuilder::insert_many(file_builders, version_id, transaction).await?;
|
||||
}
|
||||
|
||||
// Clear version cache
|
||||
@@ -785,7 +786,7 @@ pub async fn upload_file(
|
||||
"sha1",
|
||||
project_id.0 as i64
|
||||
)
|
||||
.fetch_one(&mut *transaction)
|
||||
.fetch_one(&mut **transaction)
|
||||
.await?
|
||||
.exists
|
||||
.unwrap_or(false);
|
||||
@@ -829,7 +830,7 @@ pub async fn upload_file(
|
||||
",
|
||||
&*hashes
|
||||
)
|
||||
.fetch_all(&mut *transaction)
|
||||
.fetch_all(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
for file in &format.files {
|
||||
|
||||
Reference in New Issue
Block a user