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

@@ -8,7 +8,6 @@ use rustical_dav::{
extensions::{CommonPropertiesExtension, CommonPropertiesProp, CommonPropertiesPropName},
privileges::UserPrivilegeSet,
resource::{InvalidProperty, Resource, ResourceService},
xml::HrefElement,
};
use rustical_store::{auth::User, CalendarObject, CalendarStore};
use serde::{Deserialize, Serialize};
@@ -29,7 +28,6 @@ pub enum CalendarObjectPropName {
Getetag,
CalendarData,
Getcontenttype,
Owner,
#[from]
#[try_into]
#[strum(disabled)]
@@ -47,9 +45,6 @@ pub enum CalendarObjectProp {
#[serde(rename = "C:calendar-data")]
CalendarData(String),
// WebDAV Access Control (RFC 3744)
Owner(HrefElement),
#[serde(skip_deserializing, untagged)]
#[from]
#[try_into]
@@ -92,7 +87,7 @@ impl Resource for CalendarObjectResource {
fn get_prop(
&self,
rmap: &ResourceMap,
_rmap: &ResourceMap,
_user: &User,
prop: &Self::PropName,
) -> Result<Self::Prop, Self::Error> {
@@ -104,9 +99,6 @@ impl Resource for CalendarObjectResource {
CalendarObjectPropName::Getcontenttype => {
CalendarObjectProp::Getcontenttype("text/calendar;charset=utf-8".to_owned())
}
CalendarObjectPropName::Owner => CalendarObjectProp::Owner(
PrincipalResource::get_principal_url(rmap, &self.principal).into(),
),
_ => panic!("we shouldn't end up here"),
})
}
@@ -116,6 +108,10 @@ impl Resource for CalendarObjectResource {
"caldav_calendar_object"
}
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))
}