diff --git a/crates/api/src/site/admin_allow_instance.rs b/crates/api/src/site/admin_allow_instance.rs index 92de5e22b..ac1b964b0 100644 --- a/crates/api/src/site/admin_allow_instance.rs +++ b/crates/api/src/site/admin_allow_instance.rs @@ -22,12 +22,9 @@ pub async fn admin_allow_instance( ) -> LemmyResult> { is_admin(&local_user_view)?; - let allowlist = Instance::allowlist(&mut context.pool()).await?; - if !allowlist.is_empty() { - return Err( - LemmyErrorType::Unknown("Using allowlist requires that blocklist be empty".to_string()) - .into(), - ); + let blocklist = Instance::blocklist(&mut context.pool()).await?; + if !blocklist.is_empty() { + Err(LemmyErrorType::CannotCombineFederationBlocklistAndAllowlist)?; } let instance_block_form = AdminAllowInstanceForm { diff --git a/crates/api/src/site/admin_block_instance.rs b/crates/api/src/site/admin_block_instance.rs index b11bb0c6e..087b7f55e 100644 --- a/crates/api/src/site/admin_block_instance.rs +++ b/crates/api/src/site/admin_block_instance.rs @@ -24,10 +24,7 @@ pub async fn admin_block_instance( let allowlist = Instance::allowlist(&mut context.pool()).await?; if !allowlist.is_empty() { - return Err( - LemmyErrorType::Unknown("Using blocklist requires that allowlist be empty".to_string()) - .into(), - ); + Err(LemmyErrorType::CannotCombineFederationBlocklistAndAllowlist)?; } let instance_block_form = AdminBlockInstanceForm { diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 906a9006d..40f878747 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -151,6 +151,7 @@ pub enum LemmyErrorType { CommunityHasNoFollowers, PostScheduleTimeMustBeInFuture, TooManyScheduledPosts, + CannotCombineFederationBlocklistAndAllowlist, FederationError { #[cfg_attr(feature = "full", ts(optional))] error: Option,