outsource owner property

This commit is contained in:
Lennart
2024-11-03 23:00:20 +01:00
parent f1997f2c18
commit f2d39e3351
8 changed files with 44 additions and 61 deletions

View File

@@ -51,7 +51,7 @@ pub enum PrincipalProp {
#[serde(skip_deserializing, untagged)]
#[from]
#[try_into]
ExtRFC5397RFC3477(CommonPropertiesProp<PrincipalResource>),
ExtCommonProperties(CommonPropertiesProp<PrincipalResource>),
#[serde(untagged)]
Invalid,
@@ -73,7 +73,7 @@ pub enum PrincipalPropName {
#[from]
#[try_into]
#[strum(disabled)]
ExtRFC5397(CommonPropertiesPropName),
ExtCommonProperties(CommonPropertiesPropName),
}
impl PrincipalResource {
@@ -97,7 +97,7 @@ impl Resource for PrincipalResource {
fn get_prop(
&self,
rmap: &ResourceMap,
user: &User,
_user: &User,
prop: &Self::PropName,
) -> Result<Self::Prop, Self::Error> {
let principal_href = HrefElement::new(Self::get_principal_url(rmap, &self.principal));
@@ -117,6 +117,10 @@ impl Resource for PrincipalResource {
"carddav_principal"
}
fn get_owner(&self) -> Option<&str> {
Some(&self.principal)
}
fn get_user_privileges(&self, user: &User) -> Result<UserPrivilegeSet, Self::Error> {
Ok(UserPrivilegeSet::owner_only(self.principal == user.id))
}