mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 07:02:24 +00:00
outsource owner property
This commit is contained in:
@@ -30,6 +30,7 @@ pub enum CommonPropertiesProp<R: Resource> {
|
||||
|
||||
// WebDAV Access Control Protocol (RFC 3477)
|
||||
CurrentUserPrivilegeSet(UserPrivilegeSet),
|
||||
Owner(Option<HrefElement>),
|
||||
|
||||
#[serde(untagged)]
|
||||
Invalid,
|
||||
@@ -47,6 +48,7 @@ pub enum CommonPropertiesPropName {
|
||||
Resourcetype,
|
||||
CurrentUserPrincipal,
|
||||
CurrentUserPrivilegeSet,
|
||||
Owner,
|
||||
}
|
||||
|
||||
impl<R: Resource, PR: Resource> ResourceExtension<R> for CommonPropertiesExtension<PR>
|
||||
@@ -77,6 +79,11 @@ where
|
||||
CommonPropertiesPropName::CurrentUserPrivilegeSet => {
|
||||
CommonPropertiesProp::CurrentUserPrivilegeSet(resource.get_user_privileges(user)?)
|
||||
}
|
||||
CommonPropertiesPropName::Owner => CommonPropertiesProp::Owner(
|
||||
resource
|
||||
.get_owner()
|
||||
.map(|owner| PR::get_url(rmap, &[owner]).unwrap().into()),
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ pub trait Resource: Clone {
|
||||
|
||||
fn resource_name() -> &'static str;
|
||||
|
||||
fn get_owner(&self) -> Option<&str> {
|
||||
None
|
||||
}
|
||||
|
||||
fn get_url<U, I>(rmap: &ResourceMap, elements: U) -> Result<String, UrlGenerationError>
|
||||
where
|
||||
U: IntoIterator<Item = I>,
|
||||
|
||||
Reference in New Issue
Block a user