Skip to content

Commit 67d8607

Browse files
authored
Make new mods by verified developers be pending (#36)
* feat(mods): creating a mod as verified sets it to pending * fix(mods): remove unused variable
1 parent 3974dc1 commit 67d8607

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/types/models/mod_entity.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -669,20 +669,19 @@ impl Mod {
669669
developer: FetchedDeveloper,
670670
pool: &mut PgConnection,
671671
) -> Result<(), ApiError> {
672-
if semver::Version::parse(json.version.trim_start_matches('v')).is_err() {
672+
if Version::parse(json.version.trim_start_matches('v')).is_err() {
673673
return Err(ApiError::BadRequest(format!(
674674
"Invalid mod version semver {}",
675675
json.version
676676
)));
677677
};
678678

679-
if semver::Version::parse(json.geode.trim_start_matches('v')).is_err() {
679+
if Version::parse(json.geode.trim_start_matches('v')).is_err() {
680680
return Err(ApiError::BadRequest(format!(
681681
"Invalid geode version semver {}",
682682
json.geode
683683
)));
684684
};
685-
let dev_verified = developer.verified;
686685

687686
Mod::create(json, developer, pool).await?;
688687
if let Some(l) = &json.links {
@@ -698,7 +697,7 @@ impl Mod {
698697
).await?;
699698
}
700699
}
701-
ModVersion::create_from_json(json, dev_verified, pool).await?;
700+
ModVersion::create_from_json(json, false, pool).await?;
702701
Ok(())
703702
}
704703

src/types/models/mod_version.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,14 @@ impl ModVersion {
532532

533533
pub async fn create_from_json(
534534
json: &ModJson,
535-
dev_verified: bool,
535+
make_accepted: bool,
536536
pool: &mut PgConnection,
537537
) -> Result<(), ApiError> {
538538
if let Err(e) = sqlx::query!("SET CONSTRAINTS mod_versions_status_id_fkey DEFERRED")
539539
.execute(&mut *pool)
540540
.await
541541
{
542-
log::error!("{}", e);
542+
log::error!("Error while updating constraints for mod_version_statuses: {}", e);
543543
return Err(ApiError::DbError);
544544
};
545545

@@ -595,7 +595,7 @@ impl ModVersion {
595595
}
596596
}
597597

598-
let status = if dev_verified {
598+
let status = if make_accepted {
599599
ModVersionStatusEnum::Accepted
600600
} else {
601601
ModVersionStatusEnum::Pending
@@ -615,6 +615,7 @@ impl ModVersion {
615615
return Err(ApiError::DbError);
616616
}
617617

618+
// Revert deferred constraints
618619
if let Err(e) = sqlx::query!("SET CONSTRAINTS mod_versions_status_id_fkey IMMEDIATE")
619620
.execute(&mut *pool)
620621
.await

0 commit comments

Comments
 (0)