Multi-tenancy: recalculateQuota and resetTenantQuotas (MT-21)
This commit is contained in:
@@ -16,6 +16,7 @@ types = { path = "../types" }
|
|||||||
jmap_proto = { path = "../jmap-proto" }
|
jmap_proto = { path = "../jmap-proto" }
|
||||||
jmap-tools = { version = "0.1" }
|
jmap-tools = { version = "0.1" }
|
||||||
registry = { path = "../registry" }
|
registry = { path = "../registry" }
|
||||||
|
inbuxa-features = { path = "../features" }
|
||||||
smtp-proto = { version = "0.2", features = ["rkyv", "serde"] }
|
smtp-proto = { version = "0.2", features = ["rkyv", "serde"] }
|
||||||
tokio = { version = "1.53", features = ["rt"] }
|
tokio = { version = "1.53", features = ["rt"] }
|
||||||
mail-parser = { version = "0.11", features = ["full_encoding", "rkyv"] }
|
mail-parser = { version = "0.11", features = ["full_encoding", "rkyv"] }
|
||||||
|
|||||||
@@ -227,7 +227,6 @@ async fn store_maintenance(
|
|||||||
.await
|
.await
|
||||||
.caused_by(trc::location!())?;
|
.caused_by(trc::location!())?;
|
||||||
|
|
||||||
|
|
||||||
trc::event!(
|
trc::event!(
|
||||||
Store(StoreEvent::DataStorePurged),
|
Store(StoreEvent::DataStorePurged),
|
||||||
Elapsed = started.elapsed()
|
Elapsed = started.elapsed()
|
||||||
@@ -328,7 +327,12 @@ async fn store_maintenance(
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// inbuxa: MT-21: recompute every tenant's usage
|
||||||
TaskStoreMaintenanceType::ResetTenantQuotas => {
|
TaskStoreMaintenanceType::ResetTenantQuotas => {
|
||||||
|
for tenant_id in inbuxa_features::tenancy::quota::all_tenants(server.registry()).await?
|
||||||
|
{
|
||||||
|
recalculate_tenant_quota(server, tenant_id).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,10 +435,15 @@ async fn recalculate_quota(server: &Server, account_id: u32) -> trc::Result<()>
|
|||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// inbuxa: MT-21: recompute a tenant's usage from its members'
|
||||||
#[cfg(not(feature = "enterprise"))]
|
async fn recalculate_tenant_quota(server: &Server, tenant_id: u32) -> trc::Result<()> {
|
||||||
async fn recalculate_tenant_quota(_server: &Server, _tenant_id: u32) -> trc::Result<()> {
|
inbuxa_features::tenancy::quota::recalculate(
|
||||||
Ok(())
|
&server.core.storage.data,
|
||||||
|
server.registry(),
|
||||||
|
tenant_id,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn reset_imap_uids(server: &Server, account_id: u32) -> trc::Result<(u32, u32)> {
|
async fn reset_imap_uids(server: &Server, account_id: u32) -> trc::Result<(u32, u32)> {
|
||||||
|
|||||||
Reference in New Issue
Block a user