diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-02 18:35:11 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-02 18:35:11 +0100 |
commit | dba0dcdc4122ff73c94d733376a77e98cabd7478 (patch) | |
tree | 96daabcb46d9c3757b5390044c96e40251f15a96 /src/dav | |
parent | 2b2e3c032cb67668395c7301962669bc927bd854 (diff) | |
download | aerogramme-dba0dcdc4122ff73c94d733376a77e98cabd7478.tar.gz aerogramme-dba0dcdc4122ff73c94d733376a77e98cabd7478.zip |
Serialize CalDAV errors
Diffstat (limited to 'src/dav')
-rw-r--r-- | src/dav/calencoder.rs | 56 | ||||
-rw-r--r-- | src/dav/caltypes.rs | 8 |
2 files changed, 54 insertions, 10 deletions
diff --git a/src/dav/calencoder.rs b/src/dav/calencoder.rs index 5cd40ef..1016a20 100644 --- a/src/dav/calencoder.rs +++ b/src/dav/calencoder.rs @@ -262,14 +262,56 @@ impl<C: CalContext> QuickWritable<C> for ResourceType { // --------------------------- DAV::error ------------------------------------ impl<C: CalContext> QuickWritable<C> for Violation { async fn write(&self, xml: &mut Writer<impl AsyncWrite+Unpin>, ctx: C) -> Result<(), QError> { + let mut atom = async |c| xml.write_event_async(Event::Empty(ctx.create_cal_element(c))).await; + match self { - Self::ResourceMustBeNull => { - let start = ctx.create_cal_element("resource-must-be-null"); - xml.write_event_async(Event::Empty(start)).await?; - }, - _ => unimplemented!(), - }; - Ok(()) + //@FIXME + // DAV elements, should not be here but in RFC3744 on ACLs + // (we do not use atom as this error is in the DAV namespace, not the caldav one) + Self::NeedPrivileges => xml.write_event_async(Event::Empty(ctx.create_dav_element("need-privileges"))).await, + + // Regular CalDAV errors + Self::ResourceMustBeNull => atom("resource-must-be-null").await, + Self::CalendarCollectionLocationOk => atom("calendar-collection-location-ok").await, + Self::ValidCalendarData => atom("valid-calendar-data").await, + Self::InitializeCalendarCollection => atom("initialize-calendar-collection").await, + Self::SupportedCalendarData => atom("supported-calendar-data").await, + Self::ValidCalendarObjectResource => atom("valid-calendar-object-resource").await, + Self::SupportedCalendarComponent => atom("supported-calendar-component").await, + Self::ValidCalendarObjectResource => atom("valid-calendar-object-resource").await, + Self::SupportedCalendarComponent => atom("SupportedCalendarComponent").await, + Self::NoUidConflict(href) => { + let start = ctx.create_cal_element("no-uid-conflict"); + let end = start.to_end(); + + xml.write_event_async(Event::Start(start.clone())).await?; + href.write(xml, ctx.child()).await?; + xml.write_event_async(Event::End(end)).await + }, + Self::MaxResourceSize => atom("max-resource-size").await, + Self::MinDateTime => atom("min-date-time").await, + Self::MaxDateTime => atom("max-date-time").await, + Self::MaxInstances => atom("max-instances").await, + Self::MaxAttendeesPerInstance => atom("max-attendees-per-instance").await, + Self::ValidFilter => atom("valid-filter").await, + Self::SupportedFilter { comp, prop, param } => { + let start = ctx.create_cal_element("supported-filter"); + let end = start.to_end(); + + xml.write_event_async(Event::Start(start.clone())).await?; + for comp_item in comp.iter() { + comp_item.write(xml, ctx.child()).await?; + } + for prop_item in prop.iter() { + prop_item.write(xml, ctx.child()).await?; + } + for param_item in param.iter() { + param_item.write(xml, ctx.child()).await?; + } + xml.write_event_async(Event::End(end)).await + }, + Self::NumberOfMatchesWithinLimits => atom("number-of-matches-within-limits").await, + } } } diff --git a/src/dav/caltypes.rs b/src/dav/caltypes.rs index c803c0c..29dc02f 100644 --- a/src/dav/caltypes.rs +++ b/src/dav/caltypes.rs @@ -614,9 +614,11 @@ pub enum Violation { /// containing a single valid VTIMEZONE component. ValidCalendarData, - /// (DAV:needs-privilege): The DAV:bind privilege MUST be granted to + ///@FIXME should not be here but in RFC3744 + /// !!! ERRATA 1002 !!! + /// (DAV:need-privileges): The DAV:bind privilege MUST be granted to /// the current user on the parent collection of the Request-URI. - NeedsPrivilege, + NeedPrivileges, /// (CALDAV:initialize-calendar-collection): A new calendar collection /// exists at the Request-URI. The DAV:resourcetype of the calendar @@ -693,7 +695,7 @@ pub enum Violation { /// the resource will be stored; MaxAttendeesPerInstance, - /// The CALDAV:filter XML element (see + /// (CALDAV:valid-filter): The CALDAV:filter XML element (see /// Section 9.7) specified in the REPORT request MUST be valid. For /// instance, a CALDAV:filter cannot nest a <C:comp name="VEVENT"> /// element in a <C:comp name="VTODO"> element, and a CALDAV:filter |