Import upstream v0.16.22, stripped

Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f
Enterprise-only files removed or emptied: 63
Enterprise-only snippets removed: 117 in 50 files
Dangling module declarations removed: 5
Cargo edits turning enterprise off: 14
Verification: clean
Enterprise feature gates left for rebuilt features: 19 in 18 files

Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
This commit is contained in:
2026-09-18 10:21:56 -07:00
commit 7dae9b29fd
1650 changed files with 485521 additions and 0 deletions
+113
View File
@@ -0,0 +1,113 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use common::{Server, auth::AccessToken};
use jmap_proto::{
method::get::{GetRequest, GetResponse},
object::quota::{Quota, QuotaProperty, QuotaValue},
types::state::State,
};
use jmap_tools::{Map, Value};
use std::{borrow::Cow, future::Future};
use trc::AddContext;
use types::{id::Id, type_state::DataType};
pub trait QuotaGet: Sync + Send {
fn quota_get(
&self,
request: GetRequest<Quota>,
access_token: &AccessToken,
) -> impl Future<Output = trc::Result<GetResponse<Quota>>> + Send;
}
impl QuotaGet for Server {
async fn quota_get(
&self,
mut request: GetRequest<Quota>,
access_token: &AccessToken,
) -> trc::Result<GetResponse<Quota>> {
let (ids, not_found_ids) = request.unwrap_ids(self.core.jmap.get_max_objects)?;
let properties = request.unwrap_properties(&[
QuotaProperty::Id,
QuotaProperty::ResourceType,
QuotaProperty::Used,
QuotaProperty::WarnLimit,
QuotaProperty::SoftLimit,
QuotaProperty::HardLimit,
QuotaProperty::Scope,
QuotaProperty::Name,
QuotaProperty::Description,
QuotaProperty::Types,
]);
let account_id = request.account_id.document_id();
let account = self.account(account_id).await.caused_by(trc::location!())?;
let quota_ids = if account.disk_quota() > 0 {
vec![0u32]
} else {
vec![]
};
let ids = if let Some(ids) = ids {
ids
} else {
quota_ids.iter().map(|id| Id::from(*id)).collect()
};
let mut response = GetResponse {
account_id: request.account_id.into(),
state: State::Initial.into(),
list: Vec::with_capacity(ids.len()),
not_found: not_found_ids,
};
let account = if account_id == access_token.account_id() {
Cow::Borrowed(&account)
} else {
Cow::Owned(self.account(account_id).await.caused_by(trc::location!())?)
};
for id in ids {
// Obtain the sieve script object
let document_id = id.document_id();
if !quota_ids.contains(&document_id) {
response.push_not_found(id);
continue;
}
let mut result = Map::with_capacity(properties.len());
for property in &properties {
let value = match property {
QuotaProperty::Id => Value::Element(id.into()),
QuotaProperty::ResourceType => "octets".to_string().into(),
QuotaProperty::Used => {
(self.get_used_quota_account(account_id).await?.max(0) as u64).into()
}
QuotaProperty::HardLimit => account.as_ref().disk_quota().into(),
QuotaProperty::Scope => "account".to_string().into(),
QuotaProperty::Name => account.as_ref().name().to_string().into(),
QuotaProperty::Description => account
.as_ref()
.description
.as_ref()
.map(|s| s.to_string())
.into(),
QuotaProperty::Types => vec![
Value::Element(QuotaValue::Types(DataType::Email)),
Value::Element(QuotaValue::Types(DataType::SieveScript)),
Value::Element(QuotaValue::Types(DataType::FileNode)),
Value::Element(QuotaValue::Types(DataType::CalendarEvent)),
Value::Element(QuotaValue::Types(DataType::ContactCard)),
]
.into(),
_ => Value::Null,
};
result.insert_unchecked(property.clone(), value);
}
response.list.push(result.into());
}
Ok(response)
}
}
+8
View File
@@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
pub mod get;
pub mod query;
+44
View File
@@ -0,0 +1,44 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use common::{Server, auth::AccessToken};
use jmap_proto::{
method::query::{QueryRequest, QueryResponse},
object::quota::Quota,
types::state::State,
};
use std::future::Future;
use types::id::Id;
pub trait QuotaQuery: Sync + Send {
fn quota_query(
&self,
request: QueryRequest<Quota>,
access_token: &AccessToken,
) -> impl Future<Output = trc::Result<QueryResponse>> + Send;
}
impl QuotaQuery for Server {
async fn quota_query(
&self,
request: QueryRequest<Quota>,
access_token: &AccessToken,
) -> trc::Result<QueryResponse> {
Ok(QueryResponse {
account_id: request.account_id,
query_state: State::Initial,
can_calculate_changes: false,
position: 0,
ids: if self.account(access_token.account_id()).await?.disk_quota() > 0 {
vec![Id::new(0)]
} else {
vec![]
},
total: Some(1),
limit: None,
})
}
}