use models::space::spaces; use crate::authority; use crate::errors::SpaceError; use crate::services::service::SpaceService; pub async fn find_active_space_by_name( state: &SpaceService, space_name: &str, ) -> Result { let lower_name = space_name.trim().to_lowercase(); if lower_name.is_empty() { return Err(SpaceError::NotFound); } let space = authority::space_by_slug(state, &lower_name).await?; if !authority::space_is_active(&space) { return Err(SpaceError::NotFound); } Ok(space) } pub async fn lookup_space_by_name( service: &SpaceService, space_name: &str, ) -> Result { find_active_space_by_name(service, space_name).await }