Serialize CalDAV errors
This commit is contained in:
parent
2b2e3c032c
commit
dba0dcdc41
2 changed files with 54 additions and 10 deletions
|
@ -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?;
|
||||
//@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
|
||||
},
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
Ok(())
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue