diff --git a/profiles/src/lib.rs b/profiles/src/lib.rs index 9a38b79..7fecb00 100644 --- a/profiles/src/lib.rs +++ b/profiles/src/lib.rs @@ -141,7 +141,7 @@ pub struct ContentConfig { pub max_display_name_length: usize, pub max_handle_length: usize, pub max_domain_length: usize, - pub max_subission_title_length: usize, + pub max_submission_title_length: usize, pub max_submission_body_length: usize, pub max_post_title_length: usize, pub max_post_body_length: usize, @@ -180,7 +180,7 @@ impl State { db: Db, ) -> Result, sled::Error> { Ok(Arc::new(State { - store: store::Store::build(&db)?, + store: store::Store::build(content_config.max_handle_length, &db)?, apub: apub::Store::build(apub_info, &db)?, pictrs: pictrs::State::new(pictrs_upstream, image_info), spawner: Arc::new(spawner), diff --git a/profiles/src/store/mod.rs b/profiles/src/store/mod.rs index e6510f2..eaa2b93 100644 --- a/profiles/src/store/mod.rs +++ b/profiles/src/store/mod.rs @@ -61,9 +61,9 @@ pub struct Store { } impl Store { - pub fn build(db: &Db) -> Result { + pub fn build(max_handle_length: usize, db: &Db) -> Result { Ok(Store { - profiles: profile::Store::build(db)?, + profiles: profile::Store::build(max_handle_length, db)?, files: file::Store::build(db)?, submissions: submission::Store::build(db)?, comments: comment::Store::build(db)?, diff --git a/profiles/src/store/profile.rs b/profiles/src/store/profile.rs index eb4b335..7dbf25a 100644 --- a/profiles/src/store/profile.rs +++ b/profiles/src/store/profile.rs @@ -379,14 +379,14 @@ impl Profile { } impl Store { - pub(super) fn build(db: &Db) -> Result { + pub(super) fn build(max_handle_length: usize, db: &Db) -> Result { Ok(Store { profile_tree: db.open_tree("profiles/profiles")?, handle_tree: db.open_tree("profiles/profiles/handles")?, owner_created_tree: db.open_tree("/profiles/profiles/owner/created")?, created_tree: db.open_tree("/profiles/profiles/created")?, count_tree: db.open_tree("/profiles/profiles/count")?, - handle_index: TermSearch::build("handle", 20, db)?, + handle_index: TermSearch::build("handle", max_handle_length, db)?, }) } diff --git a/profiles/src/store/submission.rs b/profiles/src/store/submission.rs index c55e777..437fa7d 100644 --- a/profiles/src/store/submission.rs +++ b/profiles/src/store/submission.rs @@ -201,11 +201,11 @@ impl<'a> SubmissionChanges<'a> { pub(crate) fn title(&mut self, title: &str) -> &mut Self { let title = strip(title.trim()); - if title.len() > self.state.content_config.max_subission_title_length { + if title.len() > self.state.content_config.max_submission_title_length { self.errors.push(ValidationError { field: String::from("title"), kind: ValidationErrorKind::TooLong { - maximum: self.state.content_config.max_subission_title_length, + maximum: self.state.content_config.max_submission_title_length, proposed: title.len(), }, }); @@ -232,7 +232,7 @@ impl<'a> SubmissionChanges<'a> { self.errors.push(ValidationError { field: String::from("description"), kind: ValidationErrorKind::TooLong { - maximum: self.state.content_config.max_subission_title_length, + maximum: self.state.content_config.max_submission_body_length, proposed: description.len(), }, });