Moderation + Mod Editing (#101)

* Moderation + Mod Editing WIP

* Run prepare, fix perms

* Make it compile

* Finish moderation and edit routes

* More fixes

* Use better queries

* Final Fixes
This commit is contained in:
Geometrically
2020-11-15 19:58:11 -07:00
committed by GitHub
parent da911bfeb8
commit 0500994def
14 changed files with 1830 additions and 332 deletions

View File

@@ -113,6 +113,8 @@ struct ModCreateData {
pub source_url: Option<String>,
/// An optional link to the mod's wiki page or other relevant information.
pub wiki_url: Option<String>,
/// An optional boolean. If true, the mod will be created as a draft.
pub is_draft: Option<bool>,
}
pub struct UploadedFile {
@@ -277,6 +279,12 @@ async fn mod_create_inner(
check_length(3..=2048, "mod description", &create_data.mod_description)?;
check_length(..65536, "mod body", &create_data.mod_body)?;
if create_data.categories.len() > 3 {
return Err(CreateError::InvalidInput(
"The maximum number of categories for a mod is four.".to_string(),
));
}
create_data
.categories
.iter()
@@ -444,7 +452,13 @@ async fn mod_create_inner(
let team_id = team.insert(&mut *transaction).await?;
let status = ModStatus::Processing;
let status;
if mod_create_data.is_draft.unwrap_or(false) {
status = ModStatus::Draft;
} else {
status = ModStatus::Processing;
}
let status_id = models::StatusId::get_id(&status, &mut *transaction)
.await?
.expect("No database entry found for status");