calendar: refactoring

This commit is contained in:
Lennart
2024-09-29 12:22:07 +02:00
parent 4597f67777
commit 3ac7e01b53

View File

@@ -90,7 +90,6 @@ impl InvalidProperty for CalendarProp {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CalendarFile { pub struct CalendarFile {
pub calendar: Calendar, pub calendar: Calendar,
pub principal: String,
} }
impl Resource for CalendarFile { impl Resource for CalendarFile {
@@ -102,11 +101,11 @@ impl Resource for CalendarFile {
Ok(match prop { Ok(match prop {
CalendarPropName::Resourcetype => CalendarProp::Resourcetype(Resourcetype::default()), CalendarPropName::Resourcetype => CalendarProp::Resourcetype(Resourcetype::default()),
CalendarPropName::CurrentUserPrincipal => CalendarProp::CurrentUserPrincipal( CalendarPropName::CurrentUserPrincipal => CalendarProp::CurrentUserPrincipal(
HrefElement::new(format!("{}/user/{}/", prefix, self.principal)), HrefElement::new(format!("{}/user/{}/", prefix, self.calendar.principal)),
), ),
CalendarPropName::Owner => CalendarProp::Owner(HrefElement::new(format!( CalendarPropName::Owner => CalendarProp::Owner(HrefElement::new(format!(
"{}/user/{}/", "{}/user/{}/",
prefix, self.principal prefix, self.calendar.principal
))), ))),
CalendarPropName::Displayname => { CalendarPropName::Displayname => {
CalendarProp::Displayname(self.calendar.displayname.clone()) CalendarProp::Displayname(self.calendar.displayname.clone())
@@ -248,10 +247,7 @@ impl<C: CalendarStore + ?Sized> ResourceService for CalendarResource<C> {
.get_calendar(&self.principal, &self.calendar_id) .get_calendar(&self.principal, &self.calendar_id)
.await .await
.map_err(|_e| Error::NotFound)?; .map_err(|_e| Error::NotFound)?;
Ok(CalendarFile { Ok(CalendarFile { calendar })
calendar,
principal: self.principal.to_owned(),
})
} }
async fn get_members( async fn get_members(