Profiles: fix spelling, don't hardcode handle max
This commit is contained in:
parent
df9a45137d
commit
6b08db0634
|
@ -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<Arc<Self>, 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),
|
||||
|
|
|
@ -61,9 +61,9 @@ pub struct Store {
|
|||
}
|
||||
|
||||
impl Store {
|
||||
pub fn build(db: &Db) -> Result<Store, sled::Error> {
|
||||
pub fn build(max_handle_length: usize, db: &Db) -> Result<Store, sled::Error> {
|
||||
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)?,
|
||||
|
|
|
@ -379,14 +379,14 @@ impl Profile {
|
|||
}
|
||||
|
||||
impl Store {
|
||||
pub(super) fn build(db: &Db) -> Result<Self, sled::Error> {
|
||||
pub(super) fn build(max_handle_length: usize, db: &Db) -> Result<Self, sled::Error> {
|
||||
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)?,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue