diff --git a/crates/caldav/src/calendar/methods/mkcalendar.rs b/crates/caldav/src/calendar/methods/mkcalendar.rs index 06128c1..baa2150 100644 --- a/crates/caldav/src/calendar/methods/mkcalendar.rs +++ b/crates/caldav/src/calendar/methods/mkcalendar.rs @@ -7,46 +7,34 @@ use rustical_xml::{XmlDeserialize, XmlDocument, XmlRootTag}; use tracing::instrument; use tracing_actix_web::RootSpan; -#[derive(XmlDeserialize, Clone, Debug)] -pub struct Resourcetype { - calendar: Option<()>, - collection: Option<()>, -} - -#[derive(XmlDeserialize, Clone, Debug)] -pub struct CalendarComponentElement { - #[xml(ty = "attr")] - name: String, -} - -#[derive(XmlDeserialize, Clone, Debug)] -pub struct SupportedCalendarComponentSetElement { - #[xml(flatten)] - comp: Vec, -} - #[derive(XmlDeserialize, Clone, Debug)] pub struct MkcolCalendarProp { - // TODO: Add namespaces - resourcetype: Option, + #[xml(ns = "rustical_dav::namespace::NS_DAV")] displayname: Option, + #[xml(ns = "rustical_dav::namespace::NS_CALDAV")] calendar_description: Option, + #[xml(ns = "rustical_dav::namespace::NS_ICAL")] calendar_color: Option, - order: Option, + #[xml(ns = "rustical_dav::namespace::NS_ICAL")] + calendar_order: Option, + #[xml(ns = "rustical_dav::namespace::NS_CALDAV")] calendar_timezone: Option, + #[xml(ns = "rustical_dav::namespace::NS_CALDAV")] calendar_timezone_id: Option, - supported_calendar_component_set: Option, } #[derive(XmlDeserialize, Clone, Debug)] -pub struct PropElement { - prop: T, +pub struct PropElement { + #[xml(ns = "rustical_dav::namespace::NS_DAV")] + prop: MkcolCalendarProp, } #[derive(XmlDeserialize, XmlRootTag, Clone, Debug)] #[xml(root = b"mkcalendar")] +#[xml(ns = "rustical_dav::namespace::NS_DAV")] struct MkcalendarRequest { - set: PropElement, + #[xml(ns = "rustical_dav::namespace::NS_DAV")] + set: PropElement, } #[instrument(parent = root_span.id(), skip(store, root_span))] @@ -68,7 +56,7 @@ pub async fn route_mkcalendar( let calendar = Calendar { id: cal_id.to_owned(), principal: principal.to_owned(), - order: request.order.unwrap_or(0), + order: request.calendar_order.unwrap_or(0), displayname: request.displayname, timezone: request.calendar_timezone, timezone_id: request.calendar_timezone_id, @@ -79,20 +67,6 @@ pub async fn route_mkcalendar( subscription_url: None, }; - match store.get_calendar(&principal, &cal_id).await { - Err(rustical_store::Error::NotFound) => { - // No conflict, no worries - } - Ok(_) => { - // oh no, there's a conflict - return Ok(HttpResponse::Conflict().body("A calendar already exists at this URI")); - } - Err(err) => { - // some other error - return Err(err.into()); - } - } - match store.insert_calendar(calendar).await { // The spec says we should return a mkcalendar-response but I don't know what goes into it. // However, it works without one but breaks on iPadOS when using an empty one :) @@ -112,7 +86,7 @@ mod tests { #[test] fn test_xml_mkcalendar() { - let mkcalendar_request = MkcalendarRequest::parse_str(r#" + MkcalendarRequest::parse_str(r#" diff --git a/crates/caldav/src/calendar/methods/report/mod.rs b/crates/caldav/src/calendar/methods/report/mod.rs index 0683632..b6cc358 100644 --- a/crates/caldav/src/calendar/methods/report/mod.rs +++ b/crates/caldav/src/calendar/methods/report/mod.rs @@ -131,6 +131,7 @@ mod tests { } }), timezone: None, + timezone_id: None, }) ) }