ACL enhancements.
parent
f5e9922294
commit
9461f63842
|
@ -188,6 +188,19 @@ impl Client {
|
|||
request.send_single::<QueryResponse>().await
|
||||
}
|
||||
|
||||
pub async fn email_query_changes(
|
||||
&self,
|
||||
since_query_state: impl Into<String>,
|
||||
filter: Option<impl Into<Filter<super::query::Filter>>>,
|
||||
) -> crate::Result<QueryChangesResponse> {
|
||||
let mut request = self.build();
|
||||
let query_request = request.query_email_changes(since_query_state);
|
||||
if let Some(filter) = filter {
|
||||
query_request.filter(filter);
|
||||
}
|
||||
request.send_single::<QueryChangesResponse>().await
|
||||
}
|
||||
|
||||
pub async fn email_parse(
|
||||
&self,
|
||||
blob_id: &str,
|
||||
|
|
|
@ -56,6 +56,10 @@ impl Mailbox<Get> {
|
|||
pub fn acl(&self) -> Option<&HashMap<String, Vec<ACL>>> {
|
||||
self.acl.as_ref()
|
||||
}
|
||||
|
||||
pub fn take_acl(&mut self) -> Option<HashMap<String, Vec<ACL>>> {
|
||||
self.acl.take()
|
||||
}
|
||||
}
|
||||
|
||||
impl MailboxRights {
|
||||
|
|
|
@ -93,7 +93,14 @@ pub struct Mailbox<State = Get> {
|
|||
#[serde(flatten)]
|
||||
#[serde(skip_deserializing)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
acl_patch: Option<HashMap<String, Vec<ACL>>>,
|
||||
acl_patch: Option<HashMap<String, ACLPatch>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum ACLPatch {
|
||||
Replace(Vec<ACL>),
|
||||
Set(bool),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
|||
|
||||
use crate::{core::set::SetObject, principal::ACL, Get, Set};
|
||||
|
||||
use super::{Mailbox, Role, SetArguments};
|
||||
use super::{ACLPatch, Mailbox, Role, SetArguments};
|
||||
|
||||
impl Mailbox<Set> {
|
||||
pub fn name(&mut self, name: impl Into<String>) -> &mut Self {
|
||||
|
@ -54,9 +54,18 @@ impl Mailbox<Set> {
|
|||
}
|
||||
|
||||
pub fn acl(&mut self, id: &str, acl: impl IntoIterator<Item = ACL>) -> &mut Self {
|
||||
self.acl_patch
|
||||
.get_or_insert_with(HashMap::new)
|
||||
.insert(format!("acl/{}", id), acl.into_iter().collect());
|
||||
self.acl_patch.get_or_insert_with(HashMap::new).insert(
|
||||
format!("acl/{}", id),
|
||||
ACLPatch::Replace(acl.into_iter().collect()),
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn acl_set(&mut self, id: &str, acl: ACL, set: bool) -> &mut Self {
|
||||
self.acl_patch.get_or_insert_with(HashMap::new).insert(
|
||||
format!("acl/{}/{}", id, acl.to_string()),
|
||||
ACLPatch::Set(set),
|
||||
);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,6 +159,25 @@ impl Display for Property {
|
|||
}
|
||||
}
|
||||
|
||||
impl Display for ACL {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
ACL::Read => write!(f, "read"),
|
||||
ACL::Modify => write!(f, "modify"),
|
||||
ACL::Delete => write!(f, "delete"),
|
||||
ACL::ReadItems => write!(f, "readItems"),
|
||||
ACL::AddItems => write!(f, "addItems"),
|
||||
ACL::ModifyItems => write!(f, "modifyItems"),
|
||||
ACL::RemoveItems => write!(f, "removeItems"),
|
||||
ACL::CreateChild => write!(f, "createChild"),
|
||||
ACL::Administer => write!(f, "administer"),
|
||||
ACL::SetSeen => write!(f, "setSeen"),
|
||||
ACL::SetKeywords => write!(f, "setKeywords"),
|
||||
ACL::Submit => write!(f, "submit"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Object for Principal<Set> {
|
||||
type Property = Property;
|
||||
|
||||
|
|
Loading…
Reference in New Issue