mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-10-06 02:34:43 +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 => {
|
query::RequestArguments::Quota => {
|
||||||
access_token.assert_is_member(req.account_id)?;
|
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() {
|
RequestMethod::Set(mut req) => match req.take_arguments() {
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl JMAP {
|
||||||
query::RequestArguments::EmailSubmission => {
|
query::RequestArguments::EmailSubmission => {
|
||||||
self.email_submission_query(query).await?
|
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!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,15 @@ impl JMAP {
|
||||||
Property::Types,
|
Property::Types,
|
||||||
]);
|
]);
|
||||||
let account_id = request.account_id.document_id();
|
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 {
|
let ids = if let Some(ids) = ids {
|
||||||
ids
|
ids
|
||||||
} else {
|
} else {
|
||||||
vec![Id::new(0)]
|
quota_ids.iter().map(|id| Id::from(*id)).collect()
|
||||||
};
|
};
|
||||||
let mut response = GetResponse {
|
let mut response = GetResponse {
|
||||||
account_id: request.account_id.into(),
|
account_id: request.account_id.into(),
|
||||||
|
|
|
@ -27,19 +27,24 @@ use jmap_proto::{
|
||||||
types::{id::Id, state::State},
|
types::{id::Id, state::State},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::JMAP;
|
use crate::{auth::AccessToken, JMAP};
|
||||||
|
|
||||||
impl JMAP {
|
impl JMAP {
|
||||||
pub async fn quota_query(
|
pub async fn quota_query(
|
||||||
&self,
|
&self,
|
||||||
request: QueryRequest<RequestArguments>,
|
request: QueryRequest<RequestArguments>,
|
||||||
|
access_token: &AccessToken,
|
||||||
) -> Result<QueryResponse, MethodError> {
|
) -> Result<QueryResponse, MethodError> {
|
||||||
Ok(QueryResponse {
|
Ok(QueryResponse {
|
||||||
account_id: request.account_id,
|
account_id: request.account_id,
|
||||||
query_state: State::Initial,
|
query_state: State::Initial,
|
||||||
can_calculate_changes: false,
|
can_calculate_changes: false,
|
||||||
position: 0,
|
position: 0,
|
||||||
ids: vec![Id::new(0)],
|
ids: if access_token.quota > 0 {
|
||||||
|
vec![Id::new(0)]
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
},
|
||||||
total: Some(1),
|
total: Some(1),
|
||||||
limit: None,
|
limit: None,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue