use lemmy_db_views::structs::SiteView;
use lemmy_utils::{
error::LemmyError,
- utils::{slurs::check_slurs_opt, validation::is_valid_body_field},
+ utils::{
+ slurs::check_slurs_opt,
+ validation::{check_site_visibility_valid, is_valid_body_field},
+ },
};
#[async_trait::async_trait(?Send)]
// Make sure user is an admin
is_admin(&local_user_view)?;
+ check_site_visibility_valid(
+ local_site.private_instance,
+ local_site.federation_enabled,
+ &data.private_instance,
+ &data.federation_enabled,
+ )?;
+
let slur_regex = local_site_to_slur_regex(&local_site);
check_slurs_opt(&data.name, &slur_regex)?;
}
}
- let enabled_private_instance_with_federation = data.private_instance == Some(true)
- && data
- .federation_enabled
- .unwrap_or(local_site.federation_enabled);
- let enabled_federation_with_private_instance = data.federation_enabled == Some(true)
- && data.private_instance.unwrap_or(local_site.private_instance);
-
- if enabled_private_instance_with_federation || enabled_federation_with_private_instance {
- return Err(LemmyError::from_message(
- "cant_enable_private_instance_and_federation_together",
- ));
- }
-
if let Some(discussion_languages) = data.discussion_languages.clone() {
SiteLanguage::update(context.pool(), discussion_languages.clone(), &site).await?;
}