This commit is contained in:
2025-10-29 22:19:54 +01:00
parent 15f79d3d8b
commit 7a6ac5f0be
6 changed files with 14 additions and 38 deletions
-21
View File
@@ -1,4 +1,3 @@
use axum::{async_trait, extract::FromRequestParts, http::request::Parts};
use diesel::{
dsl::{exists, select},
pg::PgConnection,
@@ -14,7 +13,6 @@ use crate::{
jobs::{enqueue_job, JOB_PROVISION_TENANT},
models::{Tenant, TenantStatus},
schema::tenants::dsl,
state::AppState,
};
pub struct TenantRepository;
@@ -136,25 +134,6 @@ pub fn apply_tenant_guc(conn: &mut PgConnection, tenant_id: Uuid) -> AppResult<(
.map_err(AppError::from)
}
pub struct TenantContext {
pub tenant: Tenant,
}
#[async_trait]
impl FromRequestParts<AppState> for TenantContext {
type Rejection = AppError;
async fn from_request_parts(
_parts: &mut Parts,
state: &AppState,
) -> Result<Self, Self::Rejection> {
let tenant = state
.tenants
.get_by_name(&state.config.default_tenant_name)?;
Ok(Self { tenant })
}
}
fn normalize_storage_root(raw: Option<&str>, tenant_id: Uuid) -> String {
match raw.map(str::trim) {
Some(root) if !root.is_empty() => {