Server: expose maximum length configs
This commit is contained in:
parent
6b08db0634
commit
b35b7680f1
|
@ -22,6 +22,7 @@ struct JobState {
|
||||||
pub(super) fn build(
|
pub(super) fn build(
|
||||||
base_url: Url,
|
base_url: Url,
|
||||||
pict_rs_upstream: Url,
|
pict_rs_upstream: Url,
|
||||||
|
content_config: hyaenidae_profiles::ContentConfig,
|
||||||
db: sled::Db,
|
db: sled::Db,
|
||||||
) -> Result<State, anyhow::Error> {
|
) -> Result<State, anyhow::Error> {
|
||||||
let storage = Storage::new();
|
let storage = Storage::new();
|
||||||
|
@ -32,6 +33,7 @@ pub(super) fn build(
|
||||||
Spawn(queue_handle.clone()),
|
Spawn(queue_handle.clone()),
|
||||||
base_url,
|
base_url,
|
||||||
pict_rs_upstream,
|
pict_rs_upstream,
|
||||||
|
content_config,
|
||||||
Arbiter::current(),
|
Arbiter::current(),
|
||||||
&db,
|
&db,
|
||||||
)?;
|
)?;
|
||||||
|
|
85
src/main.rs
85
src/main.rs
|
@ -82,6 +82,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let state = jobs::build(
|
let state = jobs::build(
|
||||||
config.base_url.clone(),
|
config.base_url.clone(),
|
||||||
config.pictrs_upstream.clone(),
|
config.pictrs_upstream.clone(),
|
||||||
|
config.content(),
|
||||||
db.clone(),
|
db.clone(),
|
||||||
)?;
|
)?;
|
||||||
let accounts_state = hyaenidae_accounts::state(&accounts_config, db.clone())?;
|
let accounts_state = hyaenidae_accounts::state(&accounts_config, db.clone())?;
|
||||||
|
@ -195,10 +196,92 @@ struct Config {
|
||||||
)]
|
)]
|
||||||
skip_signature_validation: bool,
|
skip_signature_validation: bool,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_BIO_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a profile bio",
|
||||||
|
default_value = "500"
|
||||||
|
)]
|
||||||
|
max_bio: usize,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_DISPLAY_NAME_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a profile display name",
|
||||||
|
default_value = "20"
|
||||||
|
)]
|
||||||
|
max_display_name: usize,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_HANDLE_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a profile handle",
|
||||||
|
default_value = "20"
|
||||||
|
)]
|
||||||
|
max_handle: usize,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_SUBMISSION_TITLE_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a submission title",
|
||||||
|
default_value = "50"
|
||||||
|
)]
|
||||||
|
max_submission_title: usize,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_SUBMISSION_BODY_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a submission body",
|
||||||
|
default_value = "1000"
|
||||||
|
)]
|
||||||
|
max_submission_body: usize,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_POST_TITLE_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a post title",
|
||||||
|
default_value = "50"
|
||||||
|
)]
|
||||||
|
max_post_title: usize,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_POST_BODY_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a post body",
|
||||||
|
default_value = "1000"
|
||||||
|
)]
|
||||||
|
max_post_body: usize,
|
||||||
|
|
||||||
|
#[structopt(
|
||||||
|
long,
|
||||||
|
env = "HYAENIDAE_MAX_COMMENT_LENGTH",
|
||||||
|
about = "Maximum allowed characters in a comment",
|
||||||
|
default_value = "500"
|
||||||
|
)]
|
||||||
|
max_comment: usize,
|
||||||
|
|
||||||
#[structopt(short, long, about = "enable debug logging")]
|
#[structopt(short, long, about = "enable debug logging")]
|
||||||
debug: bool,
|
debug: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
fn content(&self) -> hyaenidae_profiles::ContentConfig {
|
||||||
|
hyaenidae_profiles::ContentConfig {
|
||||||
|
max_bio_length: self.max_bio,
|
||||||
|
max_display_name_length: self.max_display_name,
|
||||||
|
max_handle_length: self.max_handle,
|
||||||
|
max_domain_length: 256,
|
||||||
|
max_submission_title_length: self.max_submission_title,
|
||||||
|
max_submission_body_length: self.max_submission_body,
|
||||||
|
max_post_title_length: self.max_post_title,
|
||||||
|
max_post_body_length: self.max_post_body,
|
||||||
|
max_comment_length: self.max_comment,
|
||||||
|
max_server_title_length: 50,
|
||||||
|
max_server_body_length: 1000,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct SecretKey {
|
struct SecretKey {
|
||||||
inner: Vec<u8>,
|
inner: Vec<u8>,
|
||||||
|
@ -245,6 +328,7 @@ impl State {
|
||||||
spawn: jobs::Spawn,
|
spawn: jobs::Spawn,
|
||||||
base_url: url::Url,
|
base_url: url::Url,
|
||||||
pict_rs_upstream: url::Url,
|
pict_rs_upstream: url::Url,
|
||||||
|
content_config: hyaenidae_profiles::ContentConfig,
|
||||||
arbiter: Arbiter,
|
arbiter: Arbiter,
|
||||||
db: &Db,
|
db: &Db,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
|
@ -263,6 +347,7 @@ impl State {
|
||||||
apub.clone(),
|
apub.clone(),
|
||||||
spawn.clone(),
|
spawn.clone(),
|
||||||
Urls,
|
Urls,
|
||||||
|
content_config,
|
||||||
arbiter,
|
arbiter,
|
||||||
db.clone(),
|
db.clone(),
|
||||||
)?,
|
)?,
|
||||||
|
|
Loading…
Reference in a new issue