getlevels fix, moar config
This commit is contained in:
parent
cc1c365e5f
commit
d418896c82
6 changed files with 22 additions and 5 deletions
|
@ -29,6 +29,7 @@ pub struct ConfigDB {
|
|||
|
||||
#[derive(Deserialize)]
|
||||
pub struct ConfigLevels {
|
||||
pub max_objects: i32,
|
||||
pub blocklist: Vec<i32>
|
||||
}
|
||||
|
||||
|
|
|
@ -225,11 +225,19 @@ pub fn get_levels(input: Form<FormGetLevels>) -> status::Custom<&'static str> {
|
|||
|
||||
if user_id_val == input.str.parse::<i32>().expect("couldnt convert query input to i32") {
|
||||
can_see_unlisted = true;
|
||||
query = query.filter(levels::user_id.eq(user_id_val));
|
||||
count_query = count_query.filter(levels::user_id.eq(user_id_val))
|
||||
} else {
|
||||
return status::Custom(Status::Ok, "-1")
|
||||
}
|
||||
}
|
||||
}
|
||||
if let None = input.local {
|
||||
let user_id_val = input.str.parse::<i32>().expect("couldnt convert query input to i32");
|
||||
|
||||
query = query.filter(levels::user_id.eq(user_id_val));
|
||||
count_query = count_query.filter(levels::user_id.eq(user_id_val))
|
||||
}
|
||||
}
|
||||
// featured
|
||||
// 17 is gdworld
|
||||
|
|
|
@ -8,6 +8,7 @@ use base64::{Engine as _, engine::general_purpose};
|
|||
|
||||
use std::fs;
|
||||
|
||||
use crate::config::CONFIG;
|
||||
use crate::helpers;
|
||||
use crate::db;
|
||||
|
||||
|
@ -96,6 +97,11 @@ pub fn upload_level(input: Form<FormUploadLevel>) -> status::Custom<&'static str
|
|||
return status::Custom(Status::Ok, "-1")
|
||||
}
|
||||
|
||||
// too many objects
|
||||
if objects_val > CONFIG.levels.max_objects as usize {
|
||||
return status::Custom(Status::Ok, "-1")
|
||||
}
|
||||
|
||||
// forbidden object checking
|
||||
if let Some(_forbidden_object) = level_objects.iter().find(|obj| crate::CONFIG.levels.blocklist.contains(&obj.id())) {
|
||||
return status::Custom(Status::Ok, "-1")
|
||||
|
|
|
@ -8,8 +8,9 @@ use std::fs;
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rocket::fs::NamedFile;
|
||||
use rocket::data::{Limits, ToByteUnit};
|
||||
|
||||
use rocket_dyn_templates::{ Template };
|
||||
use rocket_dyn_templates::Template;
|
||||
|
||||
mod db;
|
||||
use db::*;
|
||||
|
@ -41,7 +42,8 @@ fn rocket() -> _ {
|
|||
// conf
|
||||
.configure(rocket::Config::figment()
|
||||
.merge(("port", CONFIG.general.port))
|
||||
.merge(("ip_header", CONFIG.general.realip_header.as_str())))
|
||||
.merge(("ip_header", CONFIG.general.realip_header.as_str()))
|
||||
.merge(("limits", Limits::new().limit("forms", 10.megabytes()))))
|
||||
// actual website
|
||||
.mount("/", routes![
|
||||
template_endpoints::index::index
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue