mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-09-30 15:54:38 +08:00
Fix: Do not return JMAP Quota object when there is no quota configured
This commit is contained in:
parent
df45384fcd
commit
c0a779d889
4 changed files with 15 additions and 6 deletions
|
@ -231,7 +231,7 @@ impl JMAP {
|
|||
query::RequestArguments::Quota => {
|
||||
access_token.assert_is_member(req.account_id)?;
|
||||
|
||||
self.quota_query(req).await?.into()
|
||||
self.quota_query(req, access_token).await?.into()
|
||||
}
|
||||
},
|
||||
RequestMethod::Set(mut req) => match req.take_arguments() {
|
||||
|
|
|
@ -98,7 +98,7 @@ impl JMAP {
|
|||
query::RequestArguments::EmailSubmission => {
|
||||
self.email_submission_query(query).await?
|
||||
}
|
||||
query::RequestArguments::Quota => self.quota_query(query).await?,
|
||||
query::RequestArguments::Quota => self.quota_query(query, access_token).await?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
|
|
@ -50,11 +50,15 @@ impl JMAP {
|
|||
Property::Types,
|
||||
]);
|
||||
let account_id = request.account_id.document_id();
|
||||
let quota_ids = [0u32];
|
||||
let quota_ids = if access_token.quota > 0 {
|
||||
vec![0u32]
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let ids = if let Some(ids) = ids {
|
||||
ids
|
||||
} else {
|
||||
vec![Id::new(0)]
|
||||
quota_ids.iter().map(|id| Id::from(*id)).collect()
|
||||
};
|
||||
let mut response = GetResponse {
|
||||
account_id: request.account_id.into(),
|
||||
|
|
|
@ -27,19 +27,24 @@ use jmap_proto::{
|
|||
types::{id::Id, state::State},
|
||||
};
|
||||
|
||||
use crate::JMAP;
|
||||
use crate::{auth::AccessToken, JMAP};
|
||||
|
||||
impl JMAP {
|
||||
pub async fn quota_query(
|
||||
&self,
|
||||
request: QueryRequest<RequestArguments>,
|
||||
access_token: &AccessToken,
|
||||
) -> Result<QueryResponse, MethodError> {
|
||||
Ok(QueryResponse {
|
||||
account_id: request.account_id,
|
||||
query_state: State::Initial,
|
||||
can_calculate_changes: false,
|
||||
position: 0,
|
||||
ids: vec![Id::new(0)],
|
||||
ids: if access_token.quota > 0 {
|
||||
vec![Id::new(0)]
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
total: Some(1),
|
||||
limit: None,
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue