getlevels fix, moar config
This commit is contained in:
parent
cc1c365e5f
commit
d418896c82
6 changed files with 22 additions and 5 deletions
|
@ -25,5 +25,7 @@ allow_registration = true
|
||||||
data_folder = "data"
|
data_folder = "data"
|
||||||
|
|
||||||
[levels]
|
[levels]
|
||||||
|
# max amount of objects in a level
|
||||||
|
max_objects = 80_000
|
||||||
# object ids to block
|
# object ids to block
|
||||||
blocklist = [ 31 ] # start position
|
blocklist = [ 31 ] # start position
|
|
@ -34,16 +34,14 @@ _these features are implemented_
|
||||||
|
|
||||||
## todo
|
## todo
|
||||||
|
|
||||||
- swap to chrono instead of `(TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS'))` (thats REALLY ugly!!) this would also make the `28` and `29` parameters work on downloadlevel
|
- swap to chrono instead of `(TO_CHAR(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS.MS'))` (thats REALLY ugly!!) this would also make the `28` (upload) and `29` (update) responses work on downloadlevel and the `4` (recent) on getlevels
|
||||||
- 2.2 friends only unlisted
|
- 2.2 friends only unlisted
|
||||||
- add more old endpoints + better support for older versions
|
- add more old endpoints + better support for older versions
|
||||||
- add dailies, events, weekly
|
- add dailies, events, weekly
|
||||||
- add defaults to more parameters
|
|
||||||
- better way for checking if song is custom (currently `id > 50`)
|
- better way for checking if song is custom (currently `id > 50`)
|
||||||
- sqlite would make sense for this
|
- sqlite would make sense for this
|
||||||
- unscuff difficulties
|
- unscuff difficulties
|
||||||
- moderation utilities
|
- moderation utilities
|
||||||
- probably make more things bools in the database
|
- probably make more things bools in the database
|
||||||
- ip actions
|
- ip actions
|
||||||
- fix downlopading levels
|
|
||||||
- better song support
|
- better song support
|
|
@ -29,6 +29,7 @@ pub struct ConfigDB {
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct ConfigLevels {
|
pub struct ConfigLevels {
|
||||||
|
pub max_objects: i32,
|
||||||
pub blocklist: Vec<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") {
|
if user_id_val == input.str.parse::<i32>().expect("couldnt convert query input to i32") {
|
||||||
can_see_unlisted = true;
|
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 {
|
} else {
|
||||||
return status::Custom(Status::Ok, "-1")
|
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
|
// featured
|
||||||
// 17 is gdworld
|
// 17 is gdworld
|
||||||
|
|
|
@ -8,6 +8,7 @@ use base64::{Engine as _, engine::general_purpose};
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use crate::config::CONFIG;
|
||||||
use crate::helpers;
|
use crate::helpers;
|
||||||
use crate::db;
|
use crate::db;
|
||||||
|
|
||||||
|
@ -96,6 +97,11 @@ pub fn upload_level(input: Form<FormUploadLevel>) -> status::Custom<&'static str
|
||||||
return status::Custom(Status::Ok, "-1")
|
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
|
// forbidden object checking
|
||||||
if let Some(_forbidden_object) = level_objects.iter().find(|obj| crate::CONFIG.levels.blocklist.contains(&obj.id())) {
|
if let Some(_forbidden_object) = level_objects.iter().find(|obj| crate::CONFIG.levels.blocklist.contains(&obj.id())) {
|
||||||
return status::Custom(Status::Ok, "-1")
|
return status::Custom(Status::Ok, "-1")
|
||||||
|
|
|
@ -8,8 +8,9 @@ use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use rocket::fs::NamedFile;
|
use rocket::fs::NamedFile;
|
||||||
|
use rocket::data::{Limits, ToByteUnit};
|
||||||
|
|
||||||
use rocket_dyn_templates::{ Template };
|
use rocket_dyn_templates::Template;
|
||||||
|
|
||||||
mod db;
|
mod db;
|
||||||
use db::*;
|
use db::*;
|
||||||
|
@ -41,7 +42,8 @@ fn rocket() -> _ {
|
||||||
// conf
|
// conf
|
||||||
.configure(rocket::Config::figment()
|
.configure(rocket::Config::figment()
|
||||||
.merge(("port", CONFIG.general.port))
|
.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
|
// actual website
|
||||||
.mount("/", routes![
|
.mount("/", routes![
|
||||||
template_endpoints::index::index
|
template_endpoints::index::index
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue