Skip to content

Commit a13da3e

Browse files
authored
Merge branch 'main' into cal/dev-136
2 parents 35b016c + ad20853 commit a13da3e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

apps/labrinth/src/routes/v2/projects.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ pub async fn project_edit(
512512
moderation_message_body: v2_new_project.moderation_message_body,
513513
monetization_status: v2_new_project.monetization_status,
514514
side_types_migration_review_status: None, // Not to be exposed in v2
515+
loader_fields: HashMap::new(), // Loader fields are not a thing in v2
515516
};
516517

517518
// This returns 204 or failure so we don't need to do anything with it

apps/labrinth/src/routes/v3/projects.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::database::redis::RedisPool;
1111
use crate::database::{self, models as db_models};
1212
use crate::file_hosting::{FileHost, FileHostPublicity};
1313
use crate::models;
14-
use crate::models::ids::ProjectId;
14+
use crate::models::ids::{ProjectId, VersionId};
1515
use crate::models::images::ImageContext;
1616
use crate::models::notifications::NotificationBody;
1717
use crate::models::pats::Scopes;
@@ -250,6 +250,8 @@ pub struct EditProject {
250250
pub monetization_status: Option<MonetizationStatus>,
251251
pub side_types_migration_review_status:
252252
Option<SideTypesMigrationReviewStatus>,
253+
#[serde(flatten)]
254+
pub loader_fields: HashMap<String, serde_json::Value>,
253255
}
254256

255257
#[allow(clippy::too_many_arguments)]
@@ -870,6 +872,29 @@ pub async fn project_edit(
870872
.await?;
871873
}
872874

875+
if !new_project.loader_fields.is_empty() {
876+
for version in db_models::DBVersion::get_many(
877+
&project_item.versions,
878+
&**pool,
879+
&redis,
880+
)
881+
.await?
882+
{
883+
super::versions::version_edit_helper(
884+
req.clone(),
885+
(VersionId::from(version.inner.id),),
886+
pool.clone(),
887+
redis.clone(),
888+
super::versions::EditVersion {
889+
fields: new_project.loader_fields.clone(),
890+
..Default::default()
891+
},
892+
session_queue.clone(),
893+
)
894+
.await?;
895+
}
896+
}
897+
873898
// check new description and body for links to associated images
874899
// if they no longer exist in the description or body, delete them
875900
let checkable_strings: Vec<&str> =

0 commit comments

Comments
 (0)