site::{Site, SiteForm},
},
traits::Crud,
+ ListingType,
};
use lemmy_db_views::site_view::SiteView;
use lemmy_utils::{utils::check_slurs_opt, ConnectionId, LemmyError};
use lemmy_websocket::{messages::SendAllMessage, LemmyContext, UserOperationCrud};
-use std::default::Default;
+use std::{default::Default, str::FromStr};
#[async_trait::async_trait(?Send)]
impl PerformCrud for EditSite {
return Err(LemmyError::from_message("application_question_required"));
}
+ if let Some(default_post_listing_type) = &data.default_post_listing_type {
+ // only allow all or local as default listing types
+ let val = ListingType::from_str(default_post_listing_type);
+ if val != Ok(ListingType::All) && val != Ok(ListingType::Local) {
+ return Err(LemmyError::from_message(
+ "invalid_default_post_listing_type",
+ ));
+ }
+ }
+
let site_form = SiteForm {
name: data.name.to_owned().unwrap_or(local_site.name),
sidebar,
application_question,
private_instance: data.private_instance,
default_theme: data.default_theme.clone(),
+ default_post_listing_type: data.default_post_listing_type.clone(),
..SiteForm::default()
};