mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 13:32:16 +00:00
dav: Implement some principal props for WebDAV ACL
This commit is contained in:
@@ -63,6 +63,15 @@ impl Resource for PrincipalResource {
|
||||
PrincipalPropName::CalendarUserAddressSet => {
|
||||
PrincipalProp::CalendarUserAddressSet(principal_url.into())
|
||||
}
|
||||
PrincipalPropName::GroupMembership => {
|
||||
PrincipalProp::GroupMembership(GroupMembership(
|
||||
user.memberships_without_self()
|
||||
.iter()
|
||||
.map(|principal| puri.principal_uri(principal).into())
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
||||
})
|
||||
}
|
||||
PrincipalPropWrapperName::Common(prop) => PrincipalPropWrapper::Common(
|
||||
|
||||
@@ -14,6 +14,10 @@ pub enum PrincipalProp {
|
||||
// WebDAV Access Control (RFC 3744)
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"principal-URL")]
|
||||
PrincipalUrl(HrefElement),
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||
GroupMembership(GroupMembership),
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
||||
AlternateUriSet,
|
||||
|
||||
// CalDAV (RFC 4791)
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV")]
|
||||
@@ -29,3 +33,6 @@ pub enum PrincipalPropWrapper {
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||
pub struct CalendarHomeSet(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||
|
||||
@@ -59,6 +59,15 @@ impl Resource for PrincipalResource {
|
||||
PrincipalProp::AddressbookHomeSet(home_set)
|
||||
}
|
||||
PrincipalPropName::PrincipalAddress => PrincipalProp::PrincipalAddress(None),
|
||||
PrincipalPropName::GroupMembership => {
|
||||
PrincipalProp::GroupMembership(GroupMembership(
|
||||
user.memberships_without_self()
|
||||
.iter()
|
||||
.map(|principal| puri.principal_uri(principal).into())
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
PrincipalPropName::AlternateUriSet => PrincipalProp::AlternateUriSet,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ pub enum PrincipalProp {
|
||||
#[xml(rename = b"principal-URL")]
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||
PrincipalUrl(HrefElement),
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||
GroupMembership(GroupMembership),
|
||||
#[xml(ns = "rustical_dav::namespace::NS_DAV", rename = b"alternate-URI-set")]
|
||||
AlternateUriSet,
|
||||
|
||||
// CardDAV (RFC 6352)
|
||||
#[xml(ns = "rustical_dav::namespace::NS_CARDDAV")]
|
||||
@@ -25,3 +29,6 @@ pub enum PrincipalPropWrapper {
|
||||
Principal(PrincipalProp),
|
||||
Common(CommonPropertiesProp),
|
||||
}
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub(super) Vec<HrefElement>);
|
||||
|
||||
@@ -108,6 +108,10 @@ impl User {
|
||||
memberships.push(self.id.as_str());
|
||||
memberships
|
||||
}
|
||||
|
||||
pub fn memberships_without_self(&self) -> Vec<&str> {
|
||||
self.memberships.iter().map(String::as_str).collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl rustical_dav::Principal for User {
|
||||
|
||||
Reference in New Issue
Block a user